use of org.wso2.carbon.idp.mgt.IdpManager in project carbon-identity-framework by wso2.
the class IdentityProviderDAOImpl method getIdentityProvider.
@Override
public /**
*/
IdentityProvider getIdentityProvider(String idpName) throws IdentityApplicationManagementException {
IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
try {
IdentityProvider idp = idpManager.getIdPByName(idpName, CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setIdentityProviderName(idp.getIdentityProviderName());
FederatedAuthenticatorConfig defaultAuthenticator = new FederatedAuthenticatorConfig();
defaultAuthenticator.setName(getDefaultAuthenticator(idp.getIdentityProviderName()));
List<FederatedAuthenticatorConfig> federatedAuthenticators = new ArrayList<FederatedAuthenticatorConfig>();
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = idp.getFederatedAuthenticatorConfigs();
if (federatedAuthenticatorConfigs != null && federatedAuthenticatorConfigs.length > 0) {
for (FederatedAuthenticatorConfig config : federatedAuthenticatorConfigs) {
if (config.isEnabled()) {
federatedAuthenticators.add(config);
}
}
}
if (CollectionUtils.isNotEmpty(federatedAuthenticators)) {
identityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticators.toArray(new FederatedAuthenticatorConfig[federatedAuthenticators.size()]));
}
List<ProvisioningConnectorConfig> provisioningConnectors = new ArrayList<ProvisioningConnectorConfig>();
ProvisioningConnectorConfig[] provisioningConnectorConfigs = idp.getProvisioningConnectorConfigs();
if (provisioningConnectorConfigs != null && provisioningConnectorConfigs.length > 0) {
for (ProvisioningConnectorConfig config : provisioningConnectorConfigs) {
if (config.isEnabled()) {
provisioningConnectors.add(config);
}
}
}
if (CollectionUtils.isNotEmpty(provisioningConnectors)) {
identityProvider.setProvisioningConnectorConfigs(provisioningConnectors.toArray(new ProvisioningConnectorConfig[provisioningConnectors.size()]));
}
identityProvider.setEnable(idp.isEnable());
return identityProvider;
} catch (IdentityProviderManagementException e) {
throw new IdentityApplicationManagementException("Error when retrieving identity provider " + idpName, e);
}
}
use of org.wso2.carbon.idp.mgt.IdpManager in project identity-governance by wso2-extensions.
the class IdentityGovernanceServiceImpl method updateConfiguration.
public void updateConfiguration(String tenantDomain, Map<String, String> configurationDetails) throws IdentityGovernanceException {
try {
IdpManager identityProviderManager = IdentityMgtServiceDataHolder.getInstance().getIdpManager();
IdentityProvider residentIdp = identityProviderManager.getResidentIdP(tenantDomain);
IdentityProviderProperty[] identityMgtProperties = residentIdp.getIdpProperties();
List<IdentityProviderProperty> newProperties = new ArrayList<>();
for (IdentityProviderProperty identityMgtProperty : identityMgtProperties) {
IdentityProviderProperty prop = new IdentityProviderProperty();
String key = identityMgtProperty.getName();
prop.setName(key);
if (configurationDetails.containsKey(key)) {
prop.setValue(configurationDetails.get(key));
} else {
prop.setValue(identityMgtProperty.getValue());
}
newProperties.add(prop);
configurationDetails.remove(key);
}
for (Map.Entry<String, String> entry : configurationDetails.entrySet()) {
IdentityProviderProperty prop = new IdentityProviderProperty();
prop.setName(entry.getKey());
prop.setValue(entry.getValue());
newProperties.add(prop);
}
residentIdp.setIdpProperties(newProperties.toArray(new IdentityProviderProperty[newProperties.size()]));
FederatedAuthenticatorConfig[] authenticatorConfigs = residentIdp.getFederatedAuthenticatorConfigs();
List<FederatedAuthenticatorConfig> configsToSave = new ArrayList<>();
for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
if (IdentityApplicationConstants.Authenticator.PassiveSTS.NAME.equals(authenticatorConfig.getName()) || IdentityApplicationConstants.Authenticator.SAML2SSO.NAME.equals(authenticatorConfig.getName())) {
configsToSave.add(authenticatorConfig);
}
}
residentIdp.setFederatedAuthenticatorConfigs(configsToSave.toArray(new FederatedAuthenticatorConfig[configsToSave.size()]));
identityProviderManager.updateResidentIdP(residentIdp, tenantDomain);
} catch (IdentityProviderManagementException e) {
log.error("Error while updating identityManagement Properties of Resident Idp.", e);
}
}
Aggregations