use of org.wso2.carbon.idp.mgt.IdentityProviderManager 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;
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager 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;
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager 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;
}
}
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager 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.idp.mgt.IdentityProviderManager 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);
}
}
}
}
Aggregations