use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-apimgt by wso2.
the class APIAdminImpl method updateClaims.
private void updateClaims(IdentityProvider idp, Object 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<>();
JsonArray claimArray = (JsonArray) claims;
claimConfig.setLocalClaimDialect(false);
for (JsonElement claimMappingEntry : claimArray) {
if (claimMappingEntry instanceof JsonObject) {
JsonElement idpClaimUri = ((JsonObject) claimMappingEntry).get("remoteClaim");
JsonElement localClaimUri = ((JsonObject) claimMappingEntry).get("localClaim");
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.getAsString());
org.wso2.carbon.identity.application.common.model.Claim localClaim = new org.wso2.carbon.identity.application.common.model.Claim();
localClaim.setClaimUri(localClaimUri.getAsString());
internalMapping.setRemoteClaim(remoteClaim);
internalMapping.setLocalClaim(localClaim);
claimMappings.add(internalMapping);
idpClaims.add(remoteClaim);
}
}
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.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class FileBasedConfigurationBuilder method processIdPConfigElement.
private ExternalIdPConfig processIdPConfigElement(OMElement idpConfigElem) {
OMAttribute nameAttr = idpConfigElem.getAttribute(new QName("name"));
// if the name is not given, do not register this config
if (nameAttr == null) {
log.warn("Each IDP configuration should have a unique name attribute");
return null;
}
// read the config parameters
Map<String, String> parameterMap = new HashMap<>();
for (Iterator paramIterator = idpConfigElem.getChildrenWithLocalName("Parameter"); paramIterator.hasNext(); ) {
OMElement paramElem = (OMElement) paramIterator.next();
OMAttribute paramNameAttr = paramElem.getAttribute(new QName("name"));
if (paramNameAttr == null) {
log.warn("A Parameter should have a name attribute. Skipping the parameter.");
continue;
}
parameterMap.put(paramNameAttr.getAttributeValue(), paramElem.getText());
}
IdentityProvider fedIdp = new IdentityProvider();
fedIdp.setIdentityProviderName(nameAttr.getAttributeValue());
ExternalIdPConfig externalIdPConfig = new ExternalIdPConfig(fedIdp);
externalIdPConfig.setParameterMap(parameterMap);
return externalIdPConfig;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class UIBasedConfigurationLoader method loadLocalAuthenticators.
protected void loadLocalAuthenticators(AuthenticationStep authenticationStep, StepConfig stepConfig) {
LocalAuthenticatorConfig[] localAuthenticators = authenticationStep.getLocalAuthenticatorConfigs();
if (localAuthenticators != null) {
IdentityProvider localIdp = new IdentityProvider();
localIdp.setIdentityProviderName(FrameworkConstants.LOCAL_IDP_NAME);
// assign it to the step
for (LocalAuthenticatorConfig localAuthenticator : localAuthenticators) {
String actualAuthenticatorName = localAuthenticator.getName();
loadStepAuthenticator(stepConfig, localIdp, actualAuthenticatorName);
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class UIBasedConfigurationLoader method loadFederatedAuthenticators.
protected void loadFederatedAuthenticators(AuthenticationStep authenticationStep, StepConfig stepConfig, String tenantDomain) throws FrameworkException {
IdentityProvider[] federatedIDPs = authenticationStep.getFederatedIdentityProviders();
if (federatedIDPs != null) {
// for each idp in the step
for (IdentityProvider federatedIDP : federatedIDPs) {
FederatedAuthenticatorConfig federatedAuthenticator = federatedIDP.getDefaultAuthenticatorConfig();
// retrieve the federated IDP and load
if (federatedAuthenticator == null) {
try {
federatedAuthenticator = IdentityProviderManager.getInstance().getIdPByName(federatedIDP.getIdentityProviderName(), tenantDomain).getDefaultAuthenticatorConfig();
} catch (IdentityProviderManagementException e) {
throw new FrameworkException("Failed to load the default authenticator for IDP : " + federatedIDP.getIdentityProviderName(), e);
}
}
String actualAuthenticatorName = federatedAuthenticator.getName();
// assign it to the step
loadStepAuthenticator(stepConfig, federatedIDP, actualAuthenticatorName);
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class ConfigurationFacade method getIdPConfigByName.
public ExternalIdPConfig getIdPConfigByName(String idpName, String tenantDomain) throws IdentityProviderManagementException {
ExternalIdPConfig externalIdPConfig = null;
IdentityProvider idpDO = null;
if (log.isDebugEnabled()) {
log.debug("Trying to find the IdP for name: " + idpName);
}
try {
IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
idpDO = idpManager.getEnabledIdPByName(idpName, tenantDomain);
if (idpDO != null) {
if (log.isDebugEnabled()) {
log.debug("A registered IdP was found");
}
externalIdPConfig = new ExternalIdPConfig(idpDO);
} else {
if (log.isDebugEnabled()) {
log.debug("A registered IdP was not found the given name");
}
}
} catch (IdentityProviderManagementException e) {
throw new IdentityProviderManagementException("Exception while getting IdP by name", e);
}
return externalIdPConfig;
}
Aggregations