use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.
the class DefaultAttributeFinder method getSupportedAttributes.
/*
* (non-Javadoc)
*
* @see org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder#getSupportedAttributes()
*/
public Set<String> getSupportedAttributes() {
try {
ClaimManager claimManager = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getClaimManager();
ClaimMapping[] claims = claimManager.getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT);
for (ClaimMapping claim : claims) {
supportedAttrs.add(claim.getClaim().getClaimUri());
}
} catch (Exception e) {
// ignore
}
return supportedAttrs;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.
the class MockRealm method init.
@Override
public void init(RealmConfiguration realmConfiguration, Map<String, ClaimMapping> claimMappingMap, Map<String, ProfileConfiguration> map1, int tenantId) throws UserStoreException {
this.realmConfiguration = realmConfiguration;
this.tenantId = tenantId;
DataSource dataSource = MockInitialContextFactory.initializeDatasource(UM_DB_JNDI_NAME, this.getClass(), new String[] { UM_DB_SQL_FILE });
userStoreManager = new MockUserStoreManager(dataSource);
((MockUserStoreManager) this.userStoreManager).setRealmConfiguration(this.realmConfiguration);
claimManager = new MockClaimManager(claimMappingMap);
((MockUserStoreManager) this.userStoreManager).setClaimManager(this.claimManager);
HybridRoleManager hybridRoleManager = new MockHybridRoleManager(dataSource, tenantId, realmConfiguration, this);
((MockUserStoreManager) this.userStoreManager).setHybridRoleManager(hybridRoleManager);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.
the class IdentityProviderManager method getMappedLocalClaims.
/**
* Retrieves Identity provider information about a given tenant
*
* @param idPName Unique Name of the IdP to which the given IdP claim URIs need to be mapped
* @param tenantDomain The tenant domain of whose local claim URIs to be mapped
* @param idPClaimURIs IdP claim URIs which need to be mapped to tenant's local claim URIs
* @throws IdentityProviderManagementException Error when getting claim mappings
*/
@Override
public Set<ClaimMapping> getMappedLocalClaims(String idPName, String tenantDomain, List<String> idPClaimURIs) throws IdentityProviderManagementException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
if (StringUtils.isEmpty(idPName)) {
String msg = "Invalid argument: Identity Provider Name value is empty";
throw new IdentityProviderManagementException(msg);
}
IdentityProvider identityProvider = dao.getIdPByName(null, idPName, tenantId, tenantDomain);
if (identityProvider == null) {
identityProvider = new FileBasedIdPMgtDAO().getIdPByName(idPName, tenantDomain);
}
if (identityProvider == null) {
identityProvider = IdPManagementServiceComponent.getFileBasedIdPs().get(IdentityApplicationConstants.DEFAULT_IDP_CONFIG);
}
ClaimConfig claimConfiguration = identityProvider.getClaimConfig();
if (claimConfiguration != null) {
ClaimMapping[] claimMappings = claimConfiguration.getClaimMappings();
if (claimMappings != null && claimMappings.length > 0 && idPClaimURIs != null) {
Set<ClaimMapping> returnSet = new HashSet<ClaimMapping>();
for (String idpClaim : idPClaimURIs) {
for (ClaimMapping claimMapping : claimMappings) {
if (claimMapping.getRemoteClaim().getClaimUri().equals(idpClaim)) {
returnSet.add(claimMapping);
break;
}
}
}
return returnSet;
}
}
return new HashSet<ClaimMapping>();
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.
the class IdPManagementUIUtil method buildClaimConfiguration.
/**
* @param fedIdp
* @param paramMap
* @throws IdentityApplicationManagementException
*/
private static void buildClaimConfiguration(IdentityProvider fedIdp, Map<String, String> paramMap, List<String> idpClaims, ClaimMapping[] currentClaimMapping) throws IdentityApplicationManagementException {
ClaimConfig claimConfiguration = new ClaimConfig();
if (idpClaims != null && idpClaims.size() > 0) {
List<Claim> idPClaimList = new ArrayList<Claim>();
for (Iterator<String> iterator = idpClaims.iterator(); iterator.hasNext(); ) {
String claimUri = iterator.next();
Claim idpClaim = new Claim();
idpClaim.setClaimUri(claimUri);
idPClaimList.add(idpClaim);
}
claimConfiguration.setIdpClaims(idPClaimList.toArray(new Claim[idPClaimList.size()]));
}
claimConfiguration.setUserClaimURI(paramMap.get("user_id_claim_dropdown"));
claimConfiguration.setRoleClaimURI(paramMap.get("role_claim_dropdown"));
ClaimConfig claimConfigurationUpdated = claimMappingFromUI(claimConfiguration, paramMap);
fedIdp.setClaimConfig(claimConfigurationUpdated);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping in project carbon-identity-framework by wso2.
the class IdPManagementDAO method getLocalIdPDefaultClaimValues.
/**
* @param dbConnection
* @param idPName
* @param userClaimUri
* @param roleClaimUri
* @param idpId
* @param tenantId
* @return
* @throws SQLException
*/
private ClaimConfig getLocalIdPDefaultClaimValues(Connection dbConnection, String idPName, String userClaimUri, String roleClaimUri, int idpId, int tenantId) throws SQLException {
PreparedStatement prepStmt = null;
ResultSet rs = null;
String sqlStmt;
ClaimConfig claimConfig = new ClaimConfig();
try {
claimConfig.setLocalClaimDialect(true);
claimConfig.setRoleClaimURI(roleClaimUri);
claimConfig.setUserClaimURI(userClaimUri);
sqlStmt = IdPManagementConstants.SQLQueries.GET_LOCAL_IDP_DEFAULT_CLAIM_VALUES_SQL;
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setInt(1, idpId);
prepStmt.setInt(2, tenantId);
List<ClaimMapping> claimMappings = new ArrayList<ClaimMapping>();
rs = prepStmt.executeQuery();
while (rs.next()) {
ClaimMapping claimMapping = new ClaimMapping();
// empty claim.
Claim remoteClaim = new Claim();
Claim localClaim = new Claim();
localClaim.setClaimUri(rs.getString("CLAIM_URI"));
claimMapping.setLocalClaim(localClaim);
claimMapping.setRemoteClaim(remoteClaim);
claimMapping.setDefaultValue(rs.getString("DEFAULT_VALUE"));
if ((IdPManagementConstants.IS_TRUE_VALUE).equals(rs.getString("IS_REQUESTED"))) {
claimMapping.setRequested(true);
} else if (rs.getString("IS_REQUESTED").equals(IdPManagementConstants.IS_TRUE_VALUE)) {
claimMapping.setRequested(false);
}
claimMappings.add(claimMapping);
}
claimConfig.setClaimMappings(claimMappings.toArray(new ClaimMapping[claimMappings.size()]));
return claimConfig;
} finally {
IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
}
}
Aggregations