use of org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig in project product-is by wso2.
the class TestPassiveSTS method testAddClaimConfiguration.
@Test(alwaysRun = true, description = "4.1.5.3", dependsOnMethods = { "testUpdateSP" })
public void testAddClaimConfiguration() throws Exception {
serviceProvider.getClaimConfig().setClaimMappings(getClaimMappings());
appMgtclient.updateApplicationData(serviceProvider);
ServiceProvider updatedServiceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
ClaimConfig updatedClaimConfig = updatedServiceProvider.getClaimConfig();
Assert.assertNotNull(updatedClaimConfig.getClaimMappings(), "Claim mapping is null. Claim mapping creation failed.");
for (ClaimMapping claimMapping : getClaimMappings()) {
boolean success = false;
for (ClaimMapping updatedClaimMapping : updatedClaimConfig.getClaimMappings()) {
if (claimMapping.getLocalClaim().getClaimUri().equals(updatedClaimMapping.getLocalClaim().getClaimUri())) {
success = true;
break;
}
}
Assert.assertTrue(success, "Failed to set claim uri: " + claimMapping.getLocalClaim().getClaimUri());
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method updateClaims.
private void updateClaims(IdentityProvider idp, Claims claims) {
if (claims != null) {
ClaimConfig claimConfig = new ClaimConfig();
List<ClaimMapping> claimMappings = new ArrayList<>();
List<org.wso2.carbon.identity.application.common.model.Claim> idpClaims = new ArrayList<>();
if (CollectionUtils.isNotEmpty(claims.getMappings())) {
claimConfig.setLocalClaimDialect(false);
for (org.wso2.carbon.identity.api.server.idp.v1.model.ClaimMapping mapping : claims.getMappings()) {
String idpClaimUri = mapping.getIdpClaim();
String localClaimUri = mapping.getLocalClaim().getUri();
ClaimMapping internalMapping = new ClaimMapping();
org.wso2.carbon.identity.application.common.model.Claim remoteClaim = new org.wso2.carbon.identity.application.common.model.Claim();
remoteClaim.setClaimUri(idpClaimUri);
org.wso2.carbon.identity.application.common.model.Claim localClaim = new org.wso2.carbon.identity.application.common.model.Claim();
localClaim.setClaimUri(localClaimUri);
internalMapping.setRemoteClaim(remoteClaim);
internalMapping.setLocalClaim(localClaim);
claimMappings.add(internalMapping);
idpClaims.add(remoteClaim);
}
} else {
claimConfig.setLocalClaimDialect(true);
}
if ((claims.getUserIdClaim() != null)) {
claimConfig.setUserClaimURI(claims.getUserIdClaim().getUri());
}
if (claims.getRoleClaim() != null) {
claimConfig.setRoleClaimURI(claims.getRoleClaim().getUri());
}
List<ProvisioningClaim> provClaims = claims.getProvisioningClaims();
for (ProvisioningClaim provClaim : provClaims) {
String provClaimUri = provClaim.getClaim().getUri();
if (CollectionUtils.isNotEmpty(claims.getMappings())) {
for (ClaimMapping internalMapping : claimMappings) {
if (StringUtils.equals(provClaimUri, internalMapping.getRemoteClaim().getClaimUri())) {
internalMapping.setDefaultValue(provClaim.getDefaultValue());
internalMapping.setRequested(true);
}
}
} else {
ClaimMapping internalMapping = new ClaimMapping();
org.wso2.carbon.identity.application.common.model.Claim localClaim = new org.wso2.carbon.identity.application.common.model.Claim();
localClaim.setClaimUri(provClaimUri);
internalMapping.setLocalClaim(localClaim);
internalMapping.setDefaultValue(provClaim.getDefaultValue());
internalMapping.setRequested(true);
claimMappings.add(internalMapping);
}
}
claimConfig.setClaimMappings(claimMappings.toArray(new ClaimMapping[0]));
claimConfig.setIdpClaims(idpClaims.toArray(new org.wso2.carbon.identity.application.common.model.Claim[0]));
idp.setClaimConfig(claimConfig);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method createClaimResponse.
private Claims createClaimResponse(ClaimConfig claimConfig) {
Claims apiClaims = new Claims();
List<org.wso2.carbon.identity.api.server.idp.v1.model.ClaimMapping> apiMappings = new ArrayList<>();
List<ProvisioningClaim> provClaims = new ArrayList<>();
if (claimConfig != null) {
if (claimConfig.getClaimMappings() != null) {
for (ClaimMapping mapping : claimConfig.getClaimMappings()) {
org.wso2.carbon.identity.api.server.idp.v1.model.ClaimMapping apiMapping = new org.wso2.carbon.identity.api.server.idp.v1.model.ClaimMapping();
Claim localClaim = new Claim();
localClaim.setId(base64URLEncode(mapping.getLocalClaim().getClaimUri()));
localClaim.setUri(mapping.getLocalClaim().getClaimUri());
localClaim.setDisplayName(getDisplayNameOfLocalClaim(mapping.getLocalClaim().getClaimUri()));
apiMapping.setLocalClaim(localClaim);
// need to validate this here.
if (StringUtils.isNotBlank(mapping.getRemoteClaim().getClaimUri())) {
apiMapping.setIdpClaim(mapping.getRemoteClaim().getClaimUri());
apiMappings.add(apiMapping);
}
if (StringUtils.isNotBlank(mapping.getDefaultValue()) && mapping.isRequested()) {
ProvisioningClaim provClaimResponse = new ProvisioningClaim();
Claim provClaim = new Claim();
if (StringUtils.isNotBlank(mapping.getRemoteClaim().getClaimUri())) {
provClaim.setUri(mapping.getRemoteClaim().getClaimUri());
} else {
provClaim.setId(base64URLEncode(mapping.getLocalClaim().getClaimUri()));
provClaim.setUri(mapping.getLocalClaim().getClaimUri());
provClaim.setDisplayName(getDisplayNameOfLocalClaim(mapping.getLocalClaim().getClaimUri()));
}
provClaimResponse.setClaim(provClaim);
provClaimResponse.setDefaultValue(mapping.getDefaultValue());
provClaims.add(provClaimResponse);
}
}
}
Claim roleClaim = new Claim();
if (getLocalClaim(claimConfig.getRoleClaimURI()) != null) {
roleClaim.setId(base64URLEncode(claimConfig.getRoleClaimURI()));
roleClaim.setDisplayName(getDisplayNameOfLocalClaim(claimConfig.getRoleClaimURI()));
}
roleClaim.setUri(claimConfig.getRoleClaimURI());
apiClaims.setRoleClaim(roleClaim);
Claim userIdClaim = new Claim();
if (getLocalClaim(claimConfig.getUserClaimURI()) != null) {
userIdClaim.setId(base64URLEncode(claimConfig.getUserClaimURI()));
userIdClaim.setDisplayName(getDisplayNameOfLocalClaim(claimConfig.getUserClaimURI()));
}
userIdClaim.setUri(claimConfig.getUserClaimURI());
apiClaims.setUserIdClaim(userIdClaim);
}
apiClaims.setMappings(apiMappings);
apiClaims.setProvisioningClaims(provClaims);
return apiClaims;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig in project identity-api-server by wso2.
the class UpdateClaimConfiguration method updateSubjectClaimConfigs.
private void updateSubjectClaimConfigs(SubjectConfig subjectApiModel, ServiceProvider application) {
if (subjectApiModel != null) {
LocalAndOutboundAuthenticationConfig authConfig = getLocalAndOutboundConfig(application);
if (subjectApiModel.getClaim() != null) {
setIfNotNull(subjectApiModel.getClaim().getUri(), authConfig::setSubjectClaimUri);
}
setIfNotNull(subjectApiModel.getIncludeTenantDomain(), authConfig::setUseTenantDomainInLocalSubjectIdentifier);
setIfNotNull(subjectApiModel.getIncludeUserDomain(), authConfig::setUseUserstoreDomainInLocalSubjectIdentifier);
ClaimConfig claimConfig = getClaimConfig(application);
setIfNotNull(subjectApiModel.getUseMappedLocalSubject(), claimConfig::setAlwaysSendMappedLocalSubjectId);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig in project carbon-apimgt by wso2.
the class APIAdminImpl method mergeIdpWithKeyManagerConfiguration.
private void mergeIdpWithKeyManagerConfiguration(IdentityProvider identityProvider, KeyManagerConfigurationDTO keyManagerDTO) {
keyManagerDTO.setDisplayName(identityProvider.getDisplayName());
keyManagerDTO.setDescription(identityProvider.getIdentityProviderDescription());
IdentityProviderProperty[] identityProviderProperties = identityProvider.getIdpProperties();
if (identityProviderProperties.length > 0) {
for (IdentityProviderProperty identityProviderProperty : identityProviderProperties) {
if (StringUtils.equals(identityProviderProperty.getName(), APIConstants.JWKS_URI)) {
keyManagerDTO.addProperty(APIConstants.KeyManager.CERTIFICATE_TYPE, APIConstants.KeyManager.CERTIFICATE_TYPE_JWKS_ENDPOINT);
keyManagerDTO.addProperty(APIConstants.KeyManager.CERTIFICATE_VALUE, identityProviderProperty.getValue());
}
if (StringUtils.equals(identityProviderProperty.getName(), IdentityApplicationConstants.IDP_ISSUER_NAME)) {
keyManagerDTO.addProperty(APIConstants.KeyManager.ISSUER, identityProviderProperty.getValue());
}
}
} else if (StringUtils.isNotBlank(identityProvider.getCertificate())) {
keyManagerDTO.addProperty(APIConstants.KeyManager.CERTIFICATE_TYPE, APIConstants.KeyManager.CERTIFICATE_TYPE_PEM_FILE);
keyManagerDTO.addProperty(APIConstants.KeyManager.CERTIFICATE_VALUE, identityProvider.getCertificate());
}
keyManagerDTO.setEnabled(identityProvider.isEnable());
keyManagerDTO.setAlias(identityProvider.getAlias());
ClaimConfig claimConfig = identityProvider.getClaimConfig();
JsonArray claimArray = new JsonArray();
for (ClaimMapping claimMapping : claimConfig.getClaimMappings()) {
JsonObject claimMappingEntryDTO = new JsonObject();
claimMappingEntryDTO.addProperty("localClaim", claimMapping.getLocalClaim().getClaimUri());
claimMappingEntryDTO.addProperty("remoteClaim", claimMapping.getRemoteClaim().getClaimUri());
claimArray.add(claimMappingEntryDTO);
}
keyManagerDTO.addProperty(APIConstants.KeyManager.CLAIM_MAPPING, claimArray);
}
Aggregations