diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/apikey/ApiKeyAuthenticator.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/apikey/ApiKeyAuthenticator.java index 6445d766a9cb..83732353ffd4 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/apikey/ApiKeyAuthenticator.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/apikey/ApiKeyAuthenticator.java @@ -516,7 +516,7 @@ private String generateAndRetrieveBackendJWTToken(String tokenSignature, JWTInfo endUserToken = (String) token; String[] splitToken = ((String) token).split("\\."); JSONObject payload; - if (jwtConfigurationDto.getJwtDecoding().equals("base64url")) { + if (APIConstants.JwtTokenConstants.DECODING_ALGORITHM_BASE64URL.equals(jwtConfigurationDto.getJwtDecoding())) { payload = new JSONObject(new String(Base64.getUrlDecoder().decode(splitToken[1]))); } else { payload = new JSONObject(new String(Base64.getDecoder().decode(splitToken[1]))); diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt/JWTValidator.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt/JWTValidator.java index f242c9087984..4116e0bc2c1a 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt/JWTValidator.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/jwt/JWTValidator.java @@ -291,7 +291,7 @@ private String generateAndRetrieveJWTToken(String tokenSignature, JWTInfoDto jwt endUserToken = (String) token; String[] splitToken = ((String) token).split("\\."); JSONObject payload; - if (jwtConfigurationDto.getJwtDecoding().equals("base64url")) { + if (APIConstants.JwtTokenConstants.DECODING_ALGORITHM_BASE64URL.equals(jwtConfigurationDto.getJwtDecoding())) { payload = new JSONObject(new String(Base64.getUrlDecoder().decode(splitToken[1]))); } else { payload = new JSONObject(new String(Base64.getDecoder().decode(splitToken[1]))); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java index 00179b6a1781..73838d29ee13 100755 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConstants.java @@ -2101,6 +2101,7 @@ public static class JwtTokenConstants { public static final String INTERNAL_KEY_TOKEN_TYPE = "InternalKey"; public static final String TOKEN_TYPE = "token_type"; public static final String API_KEY_TOKEN_TYPE = "apiKey"; + public static final String DECODING_ALGORITHM_BASE64URL = "base64url"; } public static final String SIGNATURE_ALGORITHM_RS256 = "RS256";