Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.

Commit ce938df

Browse files
authored
Manage JWTCreator get token parts exceptions (#38)
1 parent b15bdf4 commit ce938df

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

dotnet/dotnetframework/GeneXusJWT/JWT/JWTCreator.cs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,52 @@ public bool DoVerifySignature(String token, String expectedAlgorithm, JWTOptions
135135
public string GetPayload(string token)
136136
{
137137

138-
return getTokenPart(token, "payload");
138+
string res = "";
139+
try
140+
{
141+
res = getTokenPart(token, "payload");
142+
}
143+
catch (Exception e)
144+
{
145+
this.error.setError("JW009", e.Message);
146+
return "";
147+
}
148+
return res;
139149

140-
}
150+
}
141151

142152
[SecuritySafeCritical]
143153
public string GetHeader(string token)
144154
{
145-
return getTokenPart(token, "header");
146-
}
155+
string res = "";
156+
try
157+
{
158+
res = getTokenPart(token, "header");
159+
}
160+
catch (Exception e)
161+
{
162+
this.error.setError("JW010", e.Message);
163+
return "";
164+
}
165+
return res;
166+
}
147167

148168
[SecuritySafeCritical]
149169
public string GetTokenID(string token)
150170
{
151-
return getTokenPart(token, "id");
152-
}
171+
string res = "";
172+
try
173+
{
174+
175+
res = getTokenPart(token, "id");
176+
}
177+
catch (Exception e)
178+
{
179+
this.error.setError("JW011", e.Message);
180+
return "";
181+
}
182+
return res;
183+
}
153184

154185

155186
/******** EXTERNAL OBJECT PUBLIC METHODS - END ********/

0 commit comments

Comments
 (0)