Search in sources :

Example 1 with ClaimDialect

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

the class ApplicationManagementServiceImpl method getAllLocalClaimUris.

@Override
public String[] getAllLocalClaimUris(String tenantDomain) throws IdentityApplicationManagementException {
    try {
        startTenantFlow(tenantDomain);
        String claimDialect = ApplicationMgtSystemConfig.getInstance().getClaimDialect();
        List<String> claimUris = new ArrayList<>();
        if (UserCoreConstants.DEFAULT_CARBON_DIALECT.equalsIgnoreCase(claimDialect)) {
            // Local claims are retrieved via ClaimMetadataManagement service for consistency.
            List<LocalClaim> localClaims = ApplicationManagementServiceComponentHolder.getInstance().getClaimMetadataManagementService().getLocalClaims(tenantDomain);
            claimUris = getLocalClaimURIs(localClaims);
        } else {
            ClaimMapping[] claimMappings = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getClaimManager().getAllClaimMappings(claimDialect);
            for (ClaimMapping claimMap : claimMappings) {
                claimUris.add(claimMap.getClaim().getClaimUri());
            }
        }
        String[] allLocalClaimUris = (claimUris.toArray(new String[claimUris.size()]));
        if (ArrayUtils.isNotEmpty(allLocalClaimUris)) {
            Arrays.sort(allLocalClaimUris);
        }
        return allLocalClaimUris;
    } catch (Exception e) {
        String error = "Error while reading system claims" + ". " + e.getMessage();
        throw new IdentityApplicationManagementException(error, e);
    } finally {
        endTenantFlow();
    }
}
Also used : ClaimMapping(org.wso2.carbon.user.api.ClaimMapping) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) ArrayList(java.util.ArrayList) LocalClaim(org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim) IdentityApplicationManagementClientException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementClientException) TransformerException(javax.xml.transform.TransformerException) RegistryException(org.wso2.carbon.registry.api.RegistryException) IOException(java.io.IOException) IdentityApplicationManagementValidationException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementValidationException) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) JAXBException(javax.xml.bind.JAXBException) IdentityApplicationRegistrationFailureException(org.wso2.carbon.identity.application.common.IdentityApplicationRegistrationFailureException) SAXException(org.xml.sax.SAXException) DefaultAuthSeqMgtException(org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtException) UserStoreException(org.wso2.carbon.user.api.UserStoreException) IdentityApplicationManagementServerException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementServerException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 2 with ClaimDialect

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

the class ClaimMetadataManagementAdminService method renameClaimDialect.

@SuppressWarnings("unused")
public void renameClaimDialect(ClaimDialectDTO oldClaimDialect, ClaimDialectDTO newClaimDialect) throws ClaimMetadataException {
    try {
        ClaimDialect oldDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(oldClaimDialect);
        ClaimDialect newDialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(newClaimDialect);
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().renameClaimDialect(oldDialect, newDialect, tenantDomain);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ClaimDialect(org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)

Example 3 with ClaimDialect

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

the class ClaimMetadataManagementAdminService method removeClaimDialect.

@SuppressWarnings("unused")
public void removeClaimDialect(ClaimDialectDTO claimDialect) throws ClaimMetadataException {
    try {
        ClaimDialect dialect = ClaimMetadataUtils.convertClaimDialectDTOToClaimDialect(claimDialect);
        String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
        IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().removeClaimDialect(dialect, tenantDomain);
    } catch (Throwable e) {
        log.error(e.getMessage(), e);
        throw new ClaimMetadataException(e.getMessage(), e);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) ClaimDialect(org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)

Example 4 with ClaimDialect

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

the class ClaimDialectDAO method renameClaimDialect.

public void renameClaimDialect(ClaimDialect oldClaimDialect, ClaimDialect newClaimDialect, int tenantId) throws ClaimMetadataException {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.UPDATE_CLAIM_DIALECT;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, newClaimDialect.getClaimDialectURI());
        prepStmt.setString(2, oldClaimDialect.getClaimDialectURI());
        prepStmt.setInt(3, tenantId);
        prepStmt.executeUpdate();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new ClaimMetadataException("Error while renaming claim dialect " + oldClaimDialect.getClaimDialectURI(), e);
    } finally {
        IdentityDatabaseUtil.closeStatement(prepStmt);
        IdentityDatabaseUtil.closeConnection(connection);
    }
}
Also used : ClaimMetadataException(org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 5 with ClaimDialect

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

the class ClaimMetadataEventPublisherProxy method publishPreDeleteClaimDialect.

public void publishPreDeleteClaimDialect(int tenantId, ClaimDialect claimDialect) {
    Map<String, Object> eventProperties = new HashMap<>();
    eventProperties.put(IdentityEventConstants.EventProperty.TENANT_ID, tenantId);
    eventProperties.put(IdentityEventConstants.EventProperty.CLAIM_DIALECT_URI, claimDialect.getClaimDialectURI());
    Event event = createEvent(eventProperties, IdentityEventConstants.Event.PRE_DELETE_CLAIM_DIALECT);
    doPublishEvent(event);
}
Also used : HashMap(java.util.HashMap) Event(org.wso2.carbon.identity.event.event.Event)

Aggregations

ClaimDialect (org.wso2.carbon.identity.claim.metadata.mgt.model.ClaimDialect)19 ClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException)14 Test (org.testng.annotations.Test)9 HashMap (java.util.HashMap)8 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)8 ExternalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.ExternalClaim)7 ArrayList (java.util.ArrayList)6 Event (org.wso2.carbon.identity.event.event.Event)6 ClaimDialectDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 ClaimDialectDTO (org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimDialectDTO)4 RemoteException (java.rmi.RemoteException)3 ClaimMetadataManagementServiceClaimMetadataException (org.wso2.carbon.identity.claim.metadata.mgt.stub.ClaimMetadataManagementServiceClaimMetadataException)3 ClaimMapping (org.wso2.carbon.user.api.ClaimMapping)3 UserStoreException (org.wso2.carbon.user.api.UserStoreException)3 AutomationContext (org.wso2.carbon.automation.engine.context.AutomationContext)2 ClaimDialectDTO (org.wso2.carbon.claim.mgt.dto.ClaimDialectDTO)2 AttributeMapping (org.wso2.carbon.identity.claim.metadata.mgt.model.AttributeMapping)2