Search in sources :

Example 11 with LocalClaim

use of org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim in project carbon-identity-framework by wso2.

the class ClaimMetadataEventPublisherProxy method publishPostUpdateLocalClaim.

public void publishPostUpdateLocalClaim(int tenantId, LocalClaim localClaim) {
    Map<String, Object> eventProperties = new HashMap<>();
    eventProperties.put(IdentityEventConstants.EventProperty.TENANT_ID, tenantId);
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_URI, localClaim.getClaimURI());
    eventProperties.put(IdentityEventConstants.EventProperty.CLAIM_DIALECT_URI, localClaim.getClaimDialectURI());
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_PROPERTIES, localClaim.getClaimProperties());
    eventProperties.put(IdentityEventConstants.EventProperty.MAPPED_ATTRIBUTES, localClaim.getMappedAttributes());
    Event event = createEvent(eventProperties, IdentityEventConstants.Event.POST_UPDATE_LOCAL_CLAIM);
    doPublishEvent(event);
}
Also used : HashMap(java.util.HashMap) Event(org.wso2.carbon.identity.event.event.Event)

Example 12 with LocalClaim

use of org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim in project carbon-identity-framework by wso2.

the class ClaimMetadataEventPublisherProxy method publishPostDeleteLocalClaim.

public void publishPostDeleteLocalClaim(int tenantId, String localClaim) {
    Map<String, Object> eventProperties = new HashMap<>();
    eventProperties.put(IdentityEventConstants.EventProperty.TENANT_ID, tenantId);
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_URI, localClaim);
    Event event = createEvent(eventProperties, IdentityEventConstants.Event.POST_DELETE_LOCAL_CLAIM);
    doPublishEvent(event);
}
Also used : HashMap(java.util.HashMap) Event(org.wso2.carbon.identity.event.event.Event)

Example 13 with LocalClaim

use of org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim in project carbon-identity-framework by wso2.

the class ClaimMetadataEventPublisherProxy method publishPreAddLocalClaim.

public void publishPreAddLocalClaim(int tenantId, LocalClaim localClaim) {
    Map<String, Object> eventProperties = new HashMap<>();
    eventProperties.put(IdentityEventConstants.EventProperty.TENANT_ID, tenantId);
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_URI, localClaim.getClaimURI());
    eventProperties.put(IdentityEventConstants.EventProperty.CLAIM_DIALECT_URI, localClaim.getClaimDialectURI());
    eventProperties.put(IdentityEventConstants.EventProperty.MAPPED_ATTRIBUTES, localClaim.getMappedAttributes());
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_PROPERTIES, localClaim.getClaimProperties());
    Event event = createEvent(eventProperties, IdentityEventConstants.Event.PRE_ADD_LOCAL_CLAIM);
    doPublishEvent(event);
}
Also used : HashMap(java.util.HashMap) Event(org.wso2.carbon.identity.event.event.Event)

Example 14 with LocalClaim

use of org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim in project carbon-identity-framework by wso2.

the class ClaimMetadataEventPublisherProxy method publishPreDeleteLocalClaim.

public void publishPreDeleteLocalClaim(int tenantId, String localClaim) {
    Map<String, Object> eventProperties = new HashMap<>();
    eventProperties.put(IdentityEventConstants.EventProperty.TENANT_ID, tenantId);
    eventProperties.put(IdentityEventConstants.EventProperty.LOCAL_CLAIM_URI, localClaim);
    Event event = createEvent(eventProperties, IdentityEventConstants.Event.PRE_DELETE_LOCAL_CLAIM);
    doPublishEvent(event);
}
Also used : HashMap(java.util.HashMap) Event(org.wso2.carbon.identity.event.event.Event)

Example 15 with LocalClaim

use of org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim in project carbon-identity-framework by wso2.

the class ClaimMetadataHandler method getMappingsFromOtherDialectToCarbon.

/**
 * @param otherDialectURI
 * @param otherClaimURIs
 * @param tenantDomain
 * @return
 * @throws ClaimMetadataException
 */
public Set<ExternalClaim> getMappingsFromOtherDialectToCarbon(String otherDialectURI, Set<String> otherClaimURIs, String tenantDomain) throws ClaimMetadataException {
    Set<ExternalClaim> returnSet = new HashSet<ExternalClaim>();
    if (otherDialectURI == null) {
        String message = "Invalid argument: \'otherDialectURI\' is \'NULL\'";
        log.error(message);
        throw new ClaimMetadataException(message);
    }
    try {
        ClaimMetadataManagementServiceImpl claimMetadataService = new ClaimMetadataManagementServiceImpl();
        if (otherDialectURI.equals(UserCoreConstants.DEFAULT_CARBON_DIALECT)) {
            List<LocalClaim> localClaims = claimMetadataService.getLocalClaims(tenantDomain);
            if (otherClaimURIs == null || otherClaimURIs.isEmpty()) {
                for (LocalClaim localClaim : localClaims) {
                    ExternalClaim claimMapping = new ExternalClaim(localClaim.getClaimDialectURI(), localClaim.getClaimURI(), localClaim.getClaimURI());
                    returnSet.add(claimMapping);
                }
                return returnSet;
            } else {
                for (LocalClaim localClaim : localClaims) {
                    if (otherClaimURIs.contains(localClaim.getClaimURI())) {
                        ExternalClaim claimMapping = new ExternalClaim(otherDialectURI, localClaim.getClaimURI(), localClaim.getClaimURI());
                        returnSet.add(claimMapping);
                    }
                }
                return returnSet;
            }
        } else {
            List<ExternalClaim> externalClaims = claimMetadataService.getExternalClaims(otherDialectURI, tenantDomain);
            if (otherClaimURIs == null || otherClaimURIs.isEmpty()) {
                returnSet = new HashSet<ExternalClaim>(externalClaims);
            } else {
                for (ExternalClaim externalClaim : externalClaims) {
                    if (otherClaimURIs.contains(externalClaim.getClaimURI())) {
                        returnSet.add(externalClaim);
                    }
                }
            }
            return returnSet;
        }
    } catch (ClaimMetadataException e) {
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ExternalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim) LocalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim) HashSet(java.util.HashSet)

Aggregations

LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)52 ArrayList (java.util.ArrayList)38 HashMap (java.util.HashMap)26 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)23 ExternalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim)19 AttributeMapping (org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping)17 Test (org.testng.annotations.Test)15 Map (java.util.Map)11 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)10 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)8 ClaimDialect (org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)8 ClaimMapping (org.wso2.carbon.user.api.ClaimMapping)7 Event (org.wso2.carbon.identity.event.event.Event)6 PreparedStatement (java.sql.PreparedStatement)5 HashSet (java.util.HashSet)5 Claim (org.wso2.carbon.identity.application.common.model.Claim)5 ClaimMapping (org.wso2.carbon.user.core.claim.ClaimMapping)5 Attribute (org.wso2.charon3.core.attributes.Attribute)5 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)5