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;
}
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;
}
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);
}
}
}
}
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);
}
}
}
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;
}
Aggregations