use of org.wso2.carbon.identity.oauth.user.UserInfoClaimRetriever in project identity-inbound-auth-oauth by wso2-extensions.
the class UserInfoEndpointConfigTest method testGetUserInfoClaimRetriever.
@Test(dataProvider = "getUserUserInfoClaimRetriever")
public void testGetUserInfoClaimRetriever(String validatorClass, Class validatorClassType, boolean isClassExisting) throws Exception {
mockStatic(EndpointUtil.class);
when(EndpointUtil.getUserInfoClaimRetriever()).thenReturn(validatorClass);
UserInfoClaimRetriever userInfoClaimRetriever = UserInfoEndpointConfig.getInstance().getUserInfoClaimRetriever();
if (isClassExisting) {
assertNotNull(userInfoClaimRetriever, "UserInfoResponseBuilder should not be null for class " + validatorClass);
assertEquals(validatorClassType, userInfoClaimRetriever.getClass(), "Expected type of " + "UserInfoClaimRetriever was not found");
} else {
assertNull(userInfoClaimRetriever, "Non-existing or invalid class passed. Hence validator should be " + "null");
}
}
use of org.wso2.carbon.identity.oauth.user.UserInfoClaimRetriever in project identity-inbound-auth-oauth by wso2-extensions.
the class UserInfoResponseBaseTest method prepareUserInfoEndpointConfig.
protected void prepareUserInfoEndpointConfig() {
UserInfoClaimRetriever claimsRetriever = mock(UserInfoClaimRetriever.class);
mockStatic(UserInfoEndpointConfig.class);
when(UserInfoEndpointConfig.getInstance()).thenReturn(userInfoEndpointConfig);
when(claimsRetriever.getClaimsMap(any(Map.class))).thenReturn(new HashMap());
when(userInfoEndpointConfig.getUserInfoClaimRetriever()).thenReturn(claimsRetriever);
}
use of org.wso2.carbon.identity.oauth.user.UserInfoClaimRetriever in project identity-inbound-auth-oauth by wso2-extensions.
the class ClaimUtil method getUserClaimsUsingTokenResponse.
public static Map<String, Object> getUserClaimsUsingTokenResponse(OAuth2TokenValidationResponseDTO tokenResponse) throws UserInfoEndpointException {
Map<ClaimMapping, String> userAttributes = getUserAttributesFromCache(tokenResponse);
Map<String, Object> userClaimsInOIDCDialect;
if (isEmpty(userAttributes)) {
if (log.isDebugEnabled()) {
log.debug("User attributes not found in cache against the token. Retrieved claims from user store.");
}
userClaimsInOIDCDialect = getClaimsFromUserStore(tokenResponse);
} else {
UserInfoClaimRetriever retriever = UserInfoEndpointConfig.getInstance().getUserInfoClaimRetriever();
userClaimsInOIDCDialect = retriever.getClaimsMap(userAttributes);
}
if (isEmpty(userClaimsInOIDCDialect)) {
userClaimsInOIDCDialect = new HashMap<>();
}
return userClaimsInOIDCDialect;
}
Aggregations