Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ashera96 committed Oct 31, 2023
1 parent d084b8c commit a7e43ba
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.wso2.apk.enforcer.security.jwt.validator.JWTConstants;
import org.wso2.apk.enforcer.security.jwt.validator.JWTValidator;
import org.wso2.apk.enforcer.security.jwt.validator.RevokedJWTDataHolder;
import org.wso2.apk.enforcer.subscription.SubscriptionDataHolder;
import org.wso2.apk.enforcer.tracing.TracingConstants;
import org.wso2.apk.enforcer.tracing.TracingSpan;
import org.wso2.apk.enforcer.tracing.TracingTracer;
Expand Down Expand Up @@ -157,21 +158,15 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws
}

// Get consumer key from the JWT token claim set
try {
String consumerKey = claims.getStringClaim(APIConstants.JwtTokenConstants.CLIENT_ID);

// Subscription validation using consumer key
if (consumerKey != null) {
validateSubscriptionUsingConsumerKey(apiKeyValidationInfoDTO, name, version, context,
consumerKey, envType, APIConstants.API_SECURITY_OAUTH2, organization,
splitToken);
} else {
log.error("Error while extracting consumer key from JWT token claim set");
}
} catch (ParseException e) {
log.error("Error while retrieving clientId from JWT token. {}", e.getMessage());
throw new APISecurityException(APIConstants.StatusCodes.UNAUTHORIZED.getCode(),
APISecurityConstants.API_AUTH_FORBIDDEN, APISecurityConstants.API_AUTH_FORBIDDEN_MESSAGE);
String consumerKey = claims.get(APIConstants.JwtTokenConstants.CLIENT_ID).toString();

// Subscription validation using consumer key
if (consumerKey != null) {
validateSubscriptionUsingConsumerKey(apiKeyValidationInfoDTO, name, version, context,
consumerKey, envType, APIConstants.API_SECURITY_OAUTH2, organization,
splitToken);
} else {
log.error("Error while extracting consumer key from JWT token claim set");
}
} else {
// In this case, the application related properties are populated so that analytics
Expand Down Expand Up @@ -451,8 +446,8 @@ private JWTValidationInfo getJwtValidationInfo(String jwtToken, String organizat
try {
// Get issuer
String issuer = jwtClaimsSet.getIssuer();
JWTValidator jwtValidator = SubscriptionDataStoreImpl.getInstance().getJWTValidatorByIssuer(issuer,
organization, environment);
JWTValidator jwtValidator = SubscriptionDataHolder.getInstance().getSubscriptionDataStore()
.getJWTValidatorByIssuer(issuer, organization, environment);
// If no validator found for the issuer, we are not caching the token.
if (jwtValidator == null) {
throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(),
Expand Down

0 comments on commit a7e43ba

Please sign in to comment.