Search in sources :

Example 1 with RequestedClaim

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;
}
Also used : PIICategory(org.wso2.carbon.consent.mgt.core.model.PIICategory) ConsentManagementException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException) ArrayList(java.util.ArrayList) SSOConsentServiceException(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity) ConsentManagementClientException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementClientException)

Example 2 with RequestedClaim

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 } };
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyList(org.mockito.Matchers.anyList) RequestObject(org.wso2.carbon.identity.openidconnect.model.RequestObject) Matchers.anyString(org.mockito.Matchers.anyString) RequestObject(org.wso2.carbon.identity.openidconnect.model.RequestObject) DataProvider(org.testng.annotations.DataProvider)

Example 3 with RequestedClaim

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);
}
Also used : OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) ScopeClaimMappingDAOImpl(org.wso2.carbon.identity.openidconnect.dao.ScopeClaimMappingDAOImpl) RequestObjectService(org.wso2.carbon.identity.openidconnect.RequestObjectService) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with RequestedClaim

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);
}
Also used : OpenIDConnectClaimFilterImpl(org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl) RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim)

Example 5 with RequestedClaim

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;
}
Also used : RequestedClaim(org.wso2.carbon.identity.openidconnect.model.RequestedClaim) ArrayList(java.util.ArrayList)

Aggregations

RequestedClaim (org.wso2.carbon.identity.openidconnect.model.RequestedClaim)20 ArrayList (java.util.ArrayList)14 List (java.util.List)9 Test (org.testng.annotations.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)5 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)5 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 HashMap (java.util.HashMap)4 BeforeClass (org.testng.annotations.BeforeClass)4 Connection (java.sql.Connection)3 ResultSet (java.sql.ResultSet)3 Map (java.util.Map)3 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)3 RequestObjectException (org.wso2.carbon.identity.oauth2.RequestObjectException)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)2 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)2 OpenIDConnectClaimFilterImpl (org.wso2.carbon.identity.openidconnect.OpenIDConnectClaimFilterImpl)2 RequestObjectDAOImpl (org.wso2.carbon.identity.openidconnect.dao.RequestObjectDAOImpl)2