Search in sources :

Example 1 with IdentityProviderMgtListener

use of org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener in project carbon-identity-framework by wso2.

the class IdentityProviderManager method deleteIdPs.

/**
 * Delete all Identity Providers from a given tenant.
 *
 * @param tenantDomain Domain of the tenant
 * @throws IdentityProviderManagementException
 */
@Override
public void deleteIdPs(String tenantDomain) throws IdentityProviderManagementException {
    // Invoking the pre listeners.
    Collection<IdentityProviderMgtListener> listeners = IdPManagementServiceComponent.getIdpMgtListeners();
    for (IdentityProviderMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPreDeleteIdPs(tenantDomain)) {
            return;
        }
    }
    // Delete metadata strings of each IDP
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    List<IdentityProvider> identityProviders = getIdPs(tenantDomain);
    for (IdentityProvider identityProvider : identityProviders) {
        deleteMetadataStrings(identityProvider.getIdentityProviderName(), tenantId);
    }
    dao.deleteIdPs(tenantId);
    // Invoking the post listeners.
    for (IdentityProviderMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPostDeleteIdPs(tenantDomain)) {
            return;
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)

Example 2 with IdentityProviderMgtListener

use of org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener in project carbon-identity-framework by wso2.

the class IdentityProviderManager method deleteIdPByResourceId.

/**
 * Deletes an Identity Provider from a given tenant.
 *
 * @param resourceId Resource ID of the IdP to be deleted
 * @throws IdentityProviderManagementException Error when deleting Identity Provider
 *                                             information
 */
@Override
public void deleteIdPByResourceId(String resourceId, String tenantDomain) throws IdentityProviderManagementException {
    // Invoking the pre listeners.
    Collection<IdentityProviderMgtListener> listeners = IdPManagementServiceComponent.getIdpMgtListeners();
    for (IdentityProviderMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPreDeleteIdPByResourceId(resourceId, tenantDomain)) {
            return;
        }
    }
    IdentityProvider identityProvider = getIdPByResourceId(resourceId, tenantDomain, true);
    if (identityProvider == null) {
        return;
    }
    deleteIDP(resourceId, identityProvider.getIdentityProviderName(), tenantDomain);
    // Invoking the post listeners.
    for (IdentityProviderMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPostDeleteIdPByResourceId(resourceId, identityProvider, tenantDomain)) {
            return;
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)

Example 3 with IdentityProviderMgtListener

use of org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener in project carbon-identity-framework by wso2.

the class IdentityProviderManager method deleteIdP.

/**
 * Deletes an Identity Provider from a given tenant
 *
 * @param idPName Name of the IdP to be deleted
 * @throws IdentityProviderManagementException Error when deleting Identity Provider
 *                                             information
 * @deprecated use {@link IdentityProviderManager#deleteIdPByResourceId(String, String)} instead.
 */
@Deprecated
@Override
public void deleteIdP(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;
        }
    }
    if (StringUtils.isEmpty(idPName)) {
        String data = "IdP name is empty.";
        throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_IDP_NAME_INVALID, data);
    }
    IdentityProvider identityProvider = this.getIdPByName(idPName, tenantDomain, true);
    if (identityProvider == null) {
        return;
    }
    deleteIDP(identityProvider.getResourceId(), idPName, tenantDomain);
    // Invoking the post listeners.
    for (IdentityProviderMgtListener listener : listeners) {
        if (listener.isEnable() && !listener.doPostDeleteIdP(idPName, tenantDomain)) {
            return;
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)

Example 4 with IdentityProviderMgtListener

use of org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener 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;
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)

Example 5 with IdentityProviderMgtListener

use of org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener 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);
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)10 IdentityProviderMgtListener (org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener)10 ArrayList (java.util.ArrayList)2 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)1 Property (org.wso2.carbon.identity.application.common.model.Property)1