use of org.wso2.carbon.identity.openidconnect.model.RequestedClaim in project carbon-identity-framework by wso2.
the class SSOConsentServiceImpl method getPiiCategoryValidityForRequestedClaims.
private List<PIICategoryValidity> getPiiCategoryValidityForRequestedClaims(List<ClaimMetaData> requestedClaims, boolean isConsented, String termination) throws SSOConsentServiceException {
List<PIICategoryValidity> piiCategoryIds = new ArrayList<>();
if (CollectionUtils.isEmpty(requestedClaims)) {
return piiCategoryIds;
}
for (ClaimMetaData requestedClaim : requestedClaims) {
if (requestedClaim == null || requestedClaim.getClaimUri() == null) {
continue;
}
PIICategory piiCategory;
try {
piiCategory = getConsentManager().getPIICategoryByName(requestedClaim.getClaimUri());
} catch (ConsentManagementClientException e) {
if (isInvalidPIICategoryError(e)) {
piiCategory = addPIICategoryForClaim(requestedClaim);
} else {
throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving" + " PII category: " + DEFAULT_PURPOSE_CATEGORY, e);
}
} catch (ConsentManagementException e) {
throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving " + "PII category: " + DEFAULT_PURPOSE_CATEGORY, e);
}
PIICategoryValidity piiCategoryValidity = new PIICategoryValidity(piiCategory.getId(), termination);
piiCategoryValidity.setConsented(isConsented);
piiCategoryIds.add(piiCategoryValidity);
}
return piiCategoryIds;
}
use of org.wso2.carbon.identity.openidconnect.model.RequestedClaim in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method provideRequestObject.
@DataProvider(name = "provideRequestObject")
public Object[][] provideRequestObject() {
List<String> claimValues = Arrays.asList("test", "test1", "test2");
String claimValue = "test";
RequestObject requestObjectWithValue = new RequestObject();
Map<String, List<RequestedClaim>> claimsforRequestParameter = new HashMap<>();
RequestedClaim requestedClaim = new RequestedClaim();
requestedClaim.setName(OAuthConstants.ACR);
requestedClaim.setValue(claimValue);
requestedClaim.setEssential(true);
claimsforRequestParameter.put(OIDCConstants.ID_TOKEN, Collections.singletonList(requestedClaim));
requestObjectWithValue.setRequestedClaims(claimsforRequestParameter);
RequestObject requestObjectWithValues = new RequestObject();
requestedClaim = new RequestedClaim();
requestedClaim.setName(OAuthConstants.ACR);
requestedClaim.setEssential(true);
claimsforRequestParameter = new HashMap<>();
requestedClaim.setValues(claimValues);
claimsforRequestParameter.put(OIDCConstants.ID_TOKEN, Collections.singletonList(requestedClaim));
requestObjectWithValues.setRequestedClaims(claimsforRequestParameter);
return new Object[][] { { null, null }, { new RequestObject(), null }, { requestObjectWithValue, Collections.singletonList(claimValue) }, { requestObjectWithValues, claimValues } };
}
use of org.wso2.carbon.identity.openidconnect.model.RequestedClaim in project identity-inbound-auth-oauth by wso2-extensions.
the class UserInfoJWTResponseTest method setup.
@BeforeClass
public void setup() throws Exception {
OAuth2ServiceComponentHolder.getInstance().setScopeClaimMappingDAO(new ScopeClaimMappingDAOImpl());
TestUtils.initiateH2Base();
con = TestUtils.getConnection();
userInfoJWTResponse = new UserInfoJWTResponse();
RequestObjectService requestObjectService = Mockito.mock(RequestObjectService.class);
List<RequestedClaim> requestedClaims = Collections.EMPTY_LIST;
when(requestObjectService.getRequestedClaimsForIDToken(anyString())).thenReturn(requestedClaims);
when(requestObjectService.getRequestedClaimsForUserInfo(anyString())).thenReturn(requestedClaims);
OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
OpenIDConnectServiceComponentHolder.setRequestObjectService(requestObjectService);
}
use of org.wso2.carbon.identity.openidconnect.model.RequestedClaim in project identity-inbound-auth-oauth by wso2-extensions.
the class UserInfoJSONResponseBuilderTest method setUpRequestObjectService.
private void setUpRequestObjectService() throws RequestObjectException {
List<RequestedClaim> requestedClaims = Collections.emptyList();
when(requestObjectService.getRequestedClaimsForIDToken(anyString())).thenReturn(requestedClaims);
when(requestObjectService.getRequestedClaimsForUserInfo(anyString())).thenReturn(requestedClaims);
OpenIDConnectServiceComponentHolder.getInstance().getOpenIDConnectClaimFilters().add(new OpenIDConnectClaimFilterImpl());
OpenIDConnectServiceComponentHolder.setRequestObjectService(requestObjectService);
}
use of org.wso2.carbon.identity.openidconnect.model.RequestedClaim in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2Util method essentialClaimsFromRequestParam.
/**
* This method returns essential:true claims list from the request parameter of OIDC authorization request
*
* @param claimRequestor claimrequestor is either id_token or userinfo
* @param requestedClaimsFromRequestParam claims defined in the value of the request parameter
* @return the claim list which have attribute vale essentail :true
*/
public static List<String> essentialClaimsFromRequestParam(String claimRequestor, Map<String, List<RequestedClaim>> requestedClaimsFromRequestParam) {
List<String> essentialClaimsfromRequestParam = new ArrayList<>();
List<RequestedClaim> claimsforClaimRequestor = requestedClaimsFromRequestParam.get(claimRequestor);
if (CollectionUtils.isNotEmpty(claimsforClaimRequestor)) {
for (RequestedClaim claimforClaimRequestor : claimsforClaimRequestor) {
String claim = claimforClaimRequestor.getName();
if (claimforClaimRequestor.isEssential()) {
essentialClaimsfromRequestParam.add(claim);
}
}
}
return essentialClaimsfromRequestParam;
}
Aggregations