Search in sources :

Example 1 with IdpManager

use of org.wso2.carbon.idp.mgt.IdpManager 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;
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) ExternalIdPConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 2 with IdpManager

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

the class FrameworkUtils method getResidentIdpConfiguration.

/**
 * Get the configurations of a tenant from cache or database.
 *
 * @param tenantDomain Domain name of the tenant
 * @return Configurations belong to the tenant
 */
private static Property[] getResidentIdpConfiguration(String tenantDomain) throws FrameworkException {
    IdpManager identityProviderManager = IdentityProviderManager.getInstance();
    IdentityProvider residentIdp = null;
    try {
        residentIdp = identityProviderManager.getResidentIdP(tenantDomain);
    } catch (IdentityProviderManagementException e) {
        String errorMsg = String.format("Error while retrieving resident Idp for %s tenant.", tenantDomain);
        throw new FrameworkException(errorMsg, e);
    }
    IdentityProviderProperty[] identityMgtProperties = residentIdp.getIdpProperties();
    Property[] configMap = new Property[identityMgtProperties.length];
    int index = 0;
    for (IdentityProviderProperty identityMgtProperty : identityMgtProperties) {
        if (ALREADY_WRITTEN_PROPERTY.equals(identityMgtProperty.getName())) {
            continue;
        }
        Property property = new Property();
        property.setName(identityMgtProperty.getName());
        property.setValue(identityMgtProperty.getValue());
        configMap[index] = property;
        index++;
    }
    return configMap;
}
Also used : FrameworkException(org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) IdpManager(org.wso2.carbon.idp.mgt.IdpManager) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.Property)

Example 3 with IdpManager

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

the class IdPManagementServiceComponent method cleanUpRemovedIdps.

private void cleanUpRemovedIdps() {
    IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
    String superTenantDN = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    List<IdentityProvider> idPs;
    try {
        idPs = idpManager.getIdPs(superTenantDN);
    } catch (IdentityProviderManagementException e) {
        log.error("Error loading IDPs", e);
        return;
    }
    for (IdentityProvider idp : idPs) {
        if (isSharedIdP(idp) && !sharedIdps.contains(idp.getIdentityProviderName())) {
            // IDP config file has been deleted from filesystem
            try {
                idpManager.deleteIdP(idp.getIdentityProviderName(), superTenantDN);
                if (log.isDebugEnabled()) {
                    log.debug("Deleted shared IdP with the name : " + idp.getIdentityProviderName());
                }
            } catch (IdentityProviderManagementException e) {
                log.error("Error when deleting IdP " + idp.getIdentityProviderName(), e);
            }
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 4 with IdpManager

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

the class JITProvisioningPostAuthenticationHandler method setIDPData.

/**
 * Set the IDP releated data in the receipt service input.
 *
 * @param tenantDomain        Tenant domain.
 * @param receiptServiceInput Relevant receipt service input which the
 * @throws PostAuthenticationFailedException Post Authentication Failed Exception.
 */
private void setIDPData(String tenantDomain, ReceiptServiceInput receiptServiceInput) throws PostAuthenticationFailedException {
    String resideIdpDescription = "Resident IDP";
    IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
    IdentityProvider residentIdP = null;
    try {
        residentIdP = idpManager.getResidentIdP(tenantDomain);
    } catch (IdentityProviderManagementException e) {
        handleExceptions(String.format(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA.getMessage(), tenantDomain), ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA.getCode(), e);
    }
    if (residentIdP == null) {
        throw new PostAuthenticationFailedException(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA_IDP_IS_NULL.getCode(), String.format(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA_IDP_IS_NULL.getMessage(), tenantDomain));
    }
    if (StringUtils.isEmpty(receiptServiceInput.getService())) {
        if (log.isDebugEnabled()) {
            log.debug("No service name found. Hence adding resident IDP home realm ID");
        }
        receiptServiceInput.setService(residentIdP.getHomeRealmId());
    }
    if (StringUtils.isEmpty(receiptServiceInput.getTenantDomain())) {
        receiptServiceInput.setTenantDomain(tenantDomain);
    }
    if (StringUtils.isEmpty(receiptServiceInput.getSpDescription())) {
        if (StringUtils.isNotEmpty(residentIdP.getIdentityProviderDescription())) {
            receiptServiceInput.setSpDescription(residentIdP.getIdentityProviderDescription());
        } else {
            receiptServiceInput.setSpDescription(resideIdpDescription);
        }
    }
    if (StringUtils.isEmpty(receiptServiceInput.getSpDisplayName())) {
        if (StringUtils.isNotEmpty(residentIdP.getDisplayName())) {
            receiptServiceInput.setSpDisplayName(residentIdP.getDisplayName());
        } else {
            receiptServiceInput.setSpDisplayName(resideIdpDescription);
        }
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) PostAuthenticationFailedException(org.wso2.carbon.identity.application.authentication.framework.exception.PostAuthenticationFailedException) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 5 with IdpManager

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

the class IdentityProviderDAOImpl method getAllIdentityProviders.

@Override
public /**
 */
List<IdentityProvider> getAllIdentityProviders() throws IdentityApplicationManagementException {
    IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
    List<IdentityProvider> idps;
    try {
        idps = idpManager.getIdPs(CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
    } catch (IdentityProviderManagementException e) {
        throw new IdentityApplicationManagementException("Error when retrieving all identity providers in " + CarbonContext.getThreadLocalCarbonContext().getTenantDomain() + " tenant domain.", e);
    }
    List<IdentityProvider> federatedIdentityProviders = new ArrayList<IdentityProvider>();
    if (idps != null && !idps.isEmpty()) {
        for (IdentityProvider idp : idps) {
            federatedIdentityProviders.add(getIdentityProvider(idp.getIdentityProviderName()));
        }
    }
    return federatedIdentityProviders;
}
Also used : IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)12 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)11 IdentityProviderManager (org.wso2.carbon.idp.mgt.IdentityProviderManager)8 ArrayList (java.util.ArrayList)4 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)4 IdpManager (org.wso2.carbon.idp.mgt.IdpManager)4 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)3 ExternalIdPConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig)2 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)2 Property (org.wso2.carbon.identity.application.common.model.Property)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 OMElement (org.apache.axiom.om.OMElement)1 StAXOMBuilder (org.apache.axiom.om.impl.builder.StAXOMBuilder)1 FrameworkException (org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException)1 PostAuthenticationFailedException (org.wso2.carbon.identity.application.authentication.framework.exception.PostAuthenticationFailedException)1