Skip to content

Commit 9de2f82

Browse files
committed
Address review comments
1 parent c0eacc0 commit 9de2f82

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Diff for: components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/keys/APIKeyValidatorClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public APIKeyValidationInfoDTO getAPIKeyData(String context, String apiVersion,
5656
} catch (APIKeyMgtException | APIManagementException e) {
5757
log.error("Error while retrieving data from datastore", e);
5858
throw new APISecurityException(APISecurityConstants.API_AUTH_GENERAL_ERROR,
59-
"Error while retrieving data from datastore", e);
59+
e.getMessage(), e);
6060
}
6161

6262
}

Diff for: components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/keys/WSAPIKeyDataStore.java

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.wso2.carbon.apimgt.gateway.MethodStats;
2323
import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityConstants;
2424
import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException;
25+
import org.wso2.carbon.apimgt.impl.APIConstants;
2526
import org.wso2.carbon.apimgt.impl.dto.APIKeyValidationInfoDTO;
2627
import org.wso2.carbon.apimgt.keymgt.model.entity.Scope;
2728
import org.wso2.carbon.apimgt.keymgt.service.TokenValidationContext;
@@ -53,6 +54,10 @@ public APIKeyValidationInfoDTO getAPIKeyData(String context, String apiVersion,
5354
return client.getAPIKeyData(context, apiVersion, apiKey, requiredAuthenticationLevel,
5455
matchingResource, httpVerb, tenantDomain, keyManagers);
5556
} catch (APISecurityException ex) {
57+
if (ex.getMessage().equalsIgnoreCase(APIConstants.JWT_GENERATION_ERROR)) {
58+
throw new APISecurityException(ex.getErrorCode(),
59+
APISecurityConstants.API_AUTH_GENERAL_ERROR_MESSAGE, ex);
60+
}
5661
throw new APISecurityException(ex.getErrorCode(),
5762
"Resource forbidden", ex);
5863
} catch (Exception e) {

Diff for: components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java

+2
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,8 @@ public enum RegistryResourceTypesForUI {
19131913
public static final String MSG_TIER_RET_ERROR = "Error while retrieving API tiers from registry";
19141914
public static final String MSG_MALFORMED_XML_ERROR = "Malformed XML found in the API tier policy resource";
19151915

1916+
public static final String JWT_GENERATION_ERROR = "Error occurred while generating JWT";
1917+
19161918
//Doc search related constants
19171919

19181920
public static final String PUBLISHER_CLIENT = "Publisher";

Diff for: components/apimgt/org.wso2.carbon.apimgt.keymgt/src/main/java/org/wso2/carbon/apimgt/keymgt/handlers/AbstractKeyValidationHandler.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,15 @@ protected boolean hasTokenRequiredAuthLevel(String authScheme,
133133
@Override
134134
public boolean generateConsumerToken(TokenValidationContext validationContext) throws APIKeyMgtException {
135135

136-
String jwt;
136+
String jwt = null;
137137
try {
138138
jwt = getCachedJWTToken(validationContext);
139139
} catch (APIManagementException e) {
140140
if (!(ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration()
141141
.getJwtConfigurationDto().isContinueOnClaimRetrievalFailure())) {
142-
throw new APIKeyMgtException("Error occurred while generating JWT", e);
142+
throw new APIKeyMgtException(APIConstants.JWT_GENERATION_ERROR, e);
143143
} else {
144144
log.error("Error occurred while generating JWT. ", e);
145-
return false;
146145
}
147146
}
148147
validationContext.getValidationInfoDTO().setEndUserToken(jwt);

0 commit comments

Comments
 (0)