Skip to content

Commit

Permalink
Fix case sensitivity issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Jul 1, 2024
1 parent 46ff23f commit e0fc1dd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ OAuthConsumerAppDTO registerAndRetrieveOAuthApplicationData(OAuthConsumerAppDTO
app.setTokenEndpointAuthMethod(tokenEndpointAuthMethod);
}
Boolean tokenEndpointAllowReusePvtKeyJwt = application.isTokenEndpointAllowReusePvtKeyJwt();
if (isInvalidTokenEPReusePvtKeyJWTRequest(tokenEndpointAuthMethod,
if (isInvalidTokenEPReusePvtKeyJwtRequest(tokenEndpointAuthMethod,
tokenEndpointAllowReusePvtKeyJwt)) {
throw handleClientError(INVALID_REQUEST,
"Invalid token endpoint authentication method requested.");
Expand Down Expand Up @@ -864,7 +864,7 @@ void updateConsumerApplication(OAuthConsumerAppDTO consumerAppDTO, boolean enabl
oAuthAppDO.setTokenEndpointAuthMethod(tokenEndpointAuthMethod);

Boolean tokenEndpointAllowReusePvtKeyJwt = consumerAppDTO.isTokenEndpointAllowReusePvtKeyJwt();
if (isInvalidTokenEPReusePvtKeyJWTRequest(tokenEndpointAuthMethod, tokenEndpointAllowReusePvtKeyJwt)) {
if (isInvalidTokenEPReusePvtKeyJwtRequest(tokenEndpointAuthMethod, tokenEndpointAllowReusePvtKeyJwt)) {
throw handleClientError(INVALID_REQUEST,
"Invalid token endpoint authentication method requested.");
}
Expand Down Expand Up @@ -2514,7 +2514,7 @@ private void handleInternalTokenRevocation(String consumerKey, Properties proper
* @param tokenEndpointAllowReusePvtKeyJwt During client authentication whether to reuse private key JWT.
* @return True if tokenEndpointAuthMethod and tokenEndpointAllowReusePvtKeyJwt is NOT in the correct format.
*/
private boolean isInvalidTokenEPReusePvtKeyJWTRequest(String tokenEndpointAuthMethod,
private boolean isInvalidTokenEPReusePvtKeyJwtRequest(String tokenEndpointAuthMethod,
Boolean tokenEndpointAllowReusePvtKeyJwt) {

if (StringUtils.isNotBlank(tokenEndpointAuthMethod)) {
Expand Down
32 changes: 16 additions & 16 deletions ...rg.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth/OAuthUtil.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1248,52 +1248,52 @@ private static void setOrganizationSSOUserDetails(AuthenticatedUser authenticate
/**
* Get the value of the Tenant configuration of Reuse Private key JWT from the tenant configuration.
*
* @param tokenEPAllowReusePvtKeyJWTValue Value of the tokenEPAllowReusePvtKeyJWT configuration.
* @param tokenEPAllowReusePvtKeyJwtValue Value of the tokenEPAllowReusePvtKeyJwt configuration.
* @param tokenAuthMethod Token authentication method.
* @return Value of the tokenEPAllowReusePvtKeyJWT configuration.
* @return Value of the tokenEPAllowReusePvtKeyJwt configuration.
* @throws IdentityOAuth2ServerException IdentityOAuth2ServerException exception.
*/
public static String getValueOfTokenEPAllowReusePvtKeyJWT(String tokenEPAllowReusePvtKeyJWTValue,
public static String getValueOfTokenEPAllowReusePvtKeyJwt(String tokenEPAllowReusePvtKeyJwtValue,
String tokenAuthMethod)
throws IdentityOAuth2ServerException {

if (tokenEPAllowReusePvtKeyJWTValue == null && StringUtils.isNotBlank(tokenAuthMethod)
if (tokenEPAllowReusePvtKeyJwtValue == null && StringUtils.isNotBlank(tokenAuthMethod)
&& OAuthConstants.PRIVATE_KEY_JWT.equals(tokenAuthMethod)) {
try {
tokenEPAllowReusePvtKeyJWTValue = readTenantConfigurationPvtKeyJWTReuse();
tokenEPAllowReusePvtKeyJwtValue = readTenantConfigurationPvtKeyJWTReuse();
} catch (ConfigurationManagementException e) {
throw new IdentityOAuth2ServerException("Unable to retrieve JWT Authenticator tenant configuration.",
e);
}
if (tokenEPAllowReusePvtKeyJWTValue == null) {
tokenEPAllowReusePvtKeyJWTValue = readServerConfigurationPvtKeyJWTReuse();
if (tokenEPAllowReusePvtKeyJWTValue == null) {
tokenEPAllowReusePvtKeyJWTValue = String.valueOf(DEFAULT_VALUE_FOR_PREVENT_TOKEN_REUSE);
if (tokenEPAllowReusePvtKeyJwtValue == null) {
tokenEPAllowReusePvtKeyJwtValue = readServerConfigurationPvtKeyJWTReuse();
if (tokenEPAllowReusePvtKeyJwtValue == null) {
tokenEPAllowReusePvtKeyJwtValue = String.valueOf(DEFAULT_VALUE_FOR_PREVENT_TOKEN_REUSE);
}
}
}
return tokenEPAllowReusePvtKeyJWTValue;
return tokenEPAllowReusePvtKeyJwtValue;
}

private static String readTenantConfigurationPvtKeyJWTReuse() throws ConfigurationManagementException {

String tokenEPAllowReusePvtKeyJWTTenantConfig = null;
String tokenEPAllowReusePvtKeyJwtTenantConfig = null;
Resource resource = OAuthComponentServiceHolder.getInstance().getConfigurationManager()
.getResource(JWT_CONFIGURATION_RESOURCE_TYPE_NAME, JWT_CONFIGURATION_RESOURCE_NAME);

if (resource != null) {
tokenEPAllowReusePvtKeyJWTTenantConfig = resource.getAttributes().stream()
tokenEPAllowReusePvtKeyJwtTenantConfig = resource.getAttributes().stream()
.filter(attribute -> ENABLE_TOKEN_REUSE.equals(attribute.getKey()))
.map(Attribute::getValue)
.findFirst()
.orElse(null);
}
return tokenEPAllowReusePvtKeyJWTTenantConfig;
return tokenEPAllowReusePvtKeyJwtTenantConfig;
}

private static String readServerConfigurationPvtKeyJWTReuse() {

String tokenEPAllowReusePvtKeyJWTTenantConfig = null;
String tokenEPAllowReusePvtKeyJwtTenantConfig = null;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty(
AbstractIdentityHandler.class.getName(), PVT_KEY_JWT_CLIENT_AUTHENTICATOR_CLASS_NAME);

Expand All @@ -1305,12 +1305,12 @@ private static String readServerConfigurationPvtKeyJWTReuse() {
String value = (String) property.getValue();
if (Objects.equals(key, PREVENT_TOKEN_REUSE)) {
boolean preventTokenReuse = Boolean.parseBoolean(value);
tokenEPAllowReusePvtKeyJWTTenantConfig = String.valueOf(!preventTokenReuse);
tokenEPAllowReusePvtKeyJwtTenantConfig = String.valueOf(!preventTokenReuse);
break;
}
}
}
}
return tokenEPAllowReusePvtKeyJWTTenantConfig;
return tokenEPAllowReusePvtKeyJwtTenantConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1806,10 +1806,10 @@ private void setSpOIDCProperties(Map<String, List<String>> spOIDCProperties, OAu
if (tokenAuthMethod != null) {
oauthApp.setTokenEndpointAuthMethod(tokenAuthMethod);
}
String tokenEPAllowReusePvtKeyJWT = OAuthUtil.getValueOfTokenEPAllowReusePvtKeyJWT(
String tokenEPAllowReusePvtKeyJwt = OAuthUtil.getValueOfTokenEPAllowReusePvtKeyJwt(
getFirstPropertyValue(spOIDCProperties, TOKEN_EP_ALLOW_REUSE_PVT_KEY_JWT), tokenAuthMethod);
if (tokenEPAllowReusePvtKeyJWT != null) {
oauthApp.setTokenEndpointAllowReusePvtKeyJwt(Boolean.parseBoolean(tokenEPAllowReusePvtKeyJWT));
if (tokenEPAllowReusePvtKeyJwt != null) {
oauthApp.setTokenEndpointAllowReusePvtKeyJwt(Boolean.parseBoolean(tokenEPAllowReusePvtKeyJwt));
}
String tokenSignatureAlgorithm = getFirstPropertyValue(spOIDCProperties, TOKEN_AUTH_SIGNATURE_ALGORITHM);
if (tokenSignatureAlgorithm != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ private void testInvalidReuseTokenRequestAndClientAuthMethod(String tokenEndpoin
OAuthAdminServiceImpl oAuthAdminService = new OAuthAdminServiceImpl();

Assert.assertEquals(invokePrivateMethod(oAuthAdminService,
"isInvalidTokenEPReusePvtKeyJWTRequest", new Class[]{String.class, Boolean.class},
"isInvalidTokenEPReusePvtKeyJwtRequest", new Class[]{String.class, Boolean.class},
tokenEndpointAuthMethod, tokenEndpointAllowReusePvtKeyJwt), expectedResult);
}

Expand Down

0 comments on commit e0fc1dd

Please sign in to comment.