use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManager method forceDeleteIdp.
/**
* Force delete an Identity Provider from a given tenant. This will remove any associations this Identity
* Provider has with any Service Providers in authentication steps or provisioning.
*
* @param idpName name of IDP to be deleted
* @param tenantDomain tenantDomain to which the IDP belongs to
* @deprecated use {@link IdentityProviderManager#forceDeleteIdpByResourceId(String, String)} instead.
*/
@Deprecated
public void forceDeleteIdp(String idpName, String tenantDomain) throws IdentityProviderManagementException {
// Invoking the pre listeners.
Collection<IdentityProviderMgtListener> listeners = IdPManagementServiceComponent.getIdpMgtListeners();
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreDeleteIdP(idpName, tenantDomain)) {
return;
}
}
IdentityProvider identityProvider = this.getIdPByName(idpName, tenantDomain, true);
if (identityProvider == null) {
throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_IDP_NAME_DOES_NOT_EXIST, idpName);
}
forceDeleteIDP(identityProvider.getResourceId(), idpName, tenantDomain);
// Invoking the post listeners.
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostDeleteIdP(idpName, tenantDomain)) {
return;
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManager method buildSAMLProperties.
private FederatedAuthenticatorConfig buildSAMLProperties(IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException {
String samlSSOUrl = buildSAMLUrl(IdentityUtil.getProperty(IdentityConstants.ServerConfig.SSO_IDP_URL), tenantDomain, IdPManagementConstants.SAMLSSO, true);
String samlLogoutUrl = buildSAMLUrl(IdentityUtil.getProperty(IdentityConstants.ServerConfig.SSO_IDP_URL), tenantDomain, IdPManagementConstants.SAMLSSO, true);
String samlECPUrl = buildSAMLUrl(IdentityUtil.getProperty(IdentityConstants.ServerConfig.SAML_ECP_URL), tenantDomain, IdPManagementConstants.SAML_ECP_URL, true);
String samlArtifactUrl = buildSAMLUrl(IdentityUtil.getProperty(IdentityConstants.ServerConfig.SSO_ARTIFACT_URL), tenantDomain, IdPManagementConstants.SSO_ARTIFACT_URL, false);
FederatedAuthenticatorConfig samlFederatedAuthConfig = IdentityApplicationManagementUtil.getFederatedAuthenticator(identityProvider.getFederatedAuthenticatorConfigs(), IdentityApplicationConstants.Authenticator.SAML2SSO.NAME);
if (samlFederatedAuthConfig == null) {
samlFederatedAuthConfig = new FederatedAuthenticatorConfig();
samlFederatedAuthConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME);
}
List<Property> propertiesList = new ArrayList<>();
Property samlSSOUrlProperty = resolveFedAuthnProperty(samlSSOUrl, samlFederatedAuthConfig, IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL);
propertiesList.add(samlSSOUrlProperty);
Property samlLogoutUrlProperty = resolveFedAuthnProperty(samlLogoutUrl, samlFederatedAuthConfig, IdentityApplicationConstants.Authenticator.SAML2SSO.LOGOUT_REQ_URL);
propertiesList.add(samlLogoutUrlProperty);
Property samlECPUrlProperty = resolveFedAuthnProperty(samlECPUrl, samlFederatedAuthConfig, IdentityApplicationConstants.Authenticator.SAML2SSO.ECP_URL);
propertiesList.add(samlECPUrlProperty);
Property samlArtifactUrlProperty = resolveFedAuthnProperty(samlArtifactUrl, samlFederatedAuthConfig, IdentityApplicationConstants.Authenticator.SAML2SSO.ARTIFACT_RESOLVE_URL);
propertiesList.add(samlArtifactUrlProperty);
Property idPEntityIdProperty = IdentityApplicationManagementUtil.getProperty(samlFederatedAuthConfig.getProperties(), IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID);
if (idPEntityIdProperty == null) {
idPEntityIdProperty = new Property();
idPEntityIdProperty.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID);
idPEntityIdProperty.setValue(IdPManagementUtil.getResidentIdPEntityId());
}
propertiesList.add(idPEntityIdProperty);
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
// Add SSO URL as a destination URL if not already available.
addSSOUrlAsDestinationUrl(samlFederatedAuthConfig, samlSSOUrl, propertiesList);
}
for (Property property : samlFederatedAuthConfig.getProperties()) {
if (property != null && !IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL.equals(property.getName()) && !IdentityApplicationConstants.Authenticator.SAML2SSO.LOGOUT_REQ_URL.equals(property.getName()) && !IdentityApplicationConstants.Authenticator.SAML2SSO.ECP_URL.equals(property.getName()) && !IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID.equals(property.getName())) {
propertiesList.add(property);
}
}
Property samlMetadataValidityPeriodProperty = IdentityApplicationManagementUtil.getProperty(samlFederatedAuthConfig.getProperties(), IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_VALIDITY_PERIOD);
if (samlMetadataValidityPeriodProperty == null) {
samlMetadataValidityPeriodProperty = new Property();
samlMetadataValidityPeriodProperty.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_VALIDITY_PERIOD);
samlMetadataValidityPeriodProperty.setValue(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_VALIDITY_PERIOD_DEFAULT);
}
propertiesList.add(samlMetadataValidityPeriodProperty);
Property samlMetadataSigningEnabledProperty = IdentityApplicationManagementUtil.getProperty(samlFederatedAuthConfig.getProperties(), IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_SIGNING_ENABLED);
if (samlMetadataSigningEnabledProperty == null) {
samlMetadataSigningEnabledProperty = new Property();
samlMetadataSigningEnabledProperty.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_SIGNING_ENABLED);
samlMetadataSigningEnabledProperty.setValue(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_SIGNING_ENABLED_DEFAULT);
}
propertiesList.add(samlMetadataSigningEnabledProperty);
Property samlAuthnRequestSigningProperty = IdentityApplicationManagementUtil.getProperty(samlFederatedAuthConfig.getProperties(), IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_AUTHN_REQUESTS_SIGNING_ENABLED);
if (samlAuthnRequestSigningProperty == null) {
samlAuthnRequestSigningProperty = new Property();
samlAuthnRequestSigningProperty.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_AUTHN_REQUESTS_SIGNING_ENABLED);
samlAuthnRequestSigningProperty.setValue(IdentityApplicationConstants.Authenticator.SAML2SSO.SAML_METADATA_AUTHN_REQUESTS_SIGNING_DEFAULT);
}
propertiesList.add(samlAuthnRequestSigningProperty);
samlFederatedAuthConfig.setProperties(propertiesList.toArray(new Property[propertiesList.size()]));
return samlFederatedAuthConfig;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManager method handleMetadata.
/**
* If metadata file is available, creates a new FederatedAuthenticatorConfig from that
*
* @param identityProvider
* @throws IdentityProviderManagementException
*/
private void handleMetadata(int tenantId, IdentityProvider identityProvider) throws IdentityProviderManagementException {
if (IdpMgtServiceComponentHolder.getInstance().getMetadataConverters().isEmpty()) {
throw new IdentityProviderManagementException("Metadata Converter is not set");
}
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = identityProvider.getFederatedAuthenticatorConfigs();
for (FederatedAuthenticatorConfig federatedAuthenticatorConfig : federatedAuthenticatorConfigs) {
Property[] properties = federatedAuthenticatorConfig.getProperties();
if (ArrayUtils.isNotEmpty(properties)) {
for (Property property : properties) {
if (property != null) {
if (StringUtils.isNotBlank(property.getName()) && property.getName().contains(IdPManagementConstants.META_DATA)) {
for (MetadataConverter metadataConverter : IdpMgtServiceComponentHolder.getInstance().getMetadataConverters()) {
if (metadataConverter.canHandle(property)) {
try {
if (isMetadataFileExist(identityProvider.getIdentityProviderName(), property.getValue())) {
try {
metadataConverter.saveMetadataString(tenantId, identityProvider.getIdentityProviderName(), federatedAuthenticatorConfig.getName(), property.getValue());
} catch (IdentityProviderManagementException e) {
String data = "Couldn't save metadata in registry.SAML2SSOMetadataConverter" + " is not set. ";
throw IdPManagementUtil.handleServerException(IdPManagementConstants.ErrorMessage.ERROR_CODE_ADD_IDP, data);
}
}
StringBuilder certificate = new StringBuilder();
try {
FederatedAuthenticatorConfig metaFederated = metadataConverter.getFederatedAuthenticatorConfig(properties, certificate);
String spName = "";
for (Property value : properties) {
if (value != null && IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID.equals(value.getName())) {
spName = value.getValue();
}
}
if (spName.equals("")) {
throw new IdentityProviderManagementException("SP name can't be empty");
}
if (metaFederated != null && ArrayUtils.isNotEmpty(metaFederated.getProperties())) {
for (int y = 0; y < metaFederated.getProperties().length; y++) {
if (metaFederated.getProperties()[y] != null && IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID.equals(metaFederated.getProperties()[y].getName())) {
metaFederated.getProperties()[y].setValue(spName);
break;
}
}
}
if (metaFederated != null && ArrayUtils.isNotEmpty(metaFederated.getProperties())) {
federatedAuthenticatorConfig.setProperties(metaFederated.getProperties());
} else {
throw new IdentityProviderManagementException("Error setting metadata using file");
}
} catch (IdentityProviderManagementException ex) {
throw new IdentityProviderManagementException("Error converting metadata", ex);
}
if (certificate.toString().length() > 0) {
identityProvider.setCertificate(certificate.toString());
}
} catch (XMLStreamException e) {
throw new IdentityProviderManagementException("Error while configuring metadata", e);
}
break;
}
}
}
}
}
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManager method updateIdPByResourceId.
/**
* Updates a given Identity Provider information
*
* @param resourceId existing Identity Provider resourceId
* @param newIdentityProvider new IdP information
* @param tenantDomain tenant domain of IDP.
* @throws IdentityProviderManagementException Error when updating Identity Provider
* information
*/
@Override
public IdentityProvider updateIdPByResourceId(String resourceId, IdentityProvider newIdentityProvider, String tenantDomain) throws IdentityProviderManagementException {
// Invoking the pre listeners.
Collection<IdentityProviderMgtListener> listeners = IdPManagementServiceComponent.getIdpMgtListeners();
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreUpdateIdPByResourceId(resourceId, newIdentityProvider, tenantDomain)) {
return null;
}
}
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
IdentityProvider currentIdentityProvider = this.getIdPByResourceId(resourceId, tenantDomain, true);
validateUpdateIdPInputValues(currentIdentityProvider, resourceId, newIdentityProvider, tenantDomain);
updateIDP(currentIdentityProvider, newIdentityProvider, tenantId, tenantDomain);
// Invoking the post listeners.
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostUpdateIdPByResourceId(resourceId, currentIdentityProvider, newIdentityProvider, tenantDomain)) {
return null;
}
}
return dao.getUpdatedIdPByResourceId(resourceId, tenantId, tenantDomain);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class FileBasedIdPMgtDAO method getIdPByAuthenticatorPropertyValue.
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain, String authenticatorName) {
Map<String, IdentityProvider> identityProviders = IdPManagementServiceComponent.getFileBasedIdPs();
for (Entry<String, IdentityProvider> entry : identityProviders.entrySet()) {
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = entry.getValue().getFederatedAuthenticatorConfigs();
// Get SAML2 Web SSO authenticator
FederatedAuthenticatorConfig samlAuthenticatorConfig = IdentityApplicationManagementUtil.getFederatedAuthenticator(federatedAuthenticatorConfigs, authenticatorName);
if (samlAuthenticatorConfig != null) {
Property samlProperty = IdentityApplicationManagementUtil.getProperty(samlAuthenticatorConfig.getProperties(), property);
if (samlProperty != null) {
if (value.equalsIgnoreCase(samlProperty.getValue())) {
return entry.getValue();
}
}
}
}
return null;
}
Aggregations