use of org.wso2.carbon.idp.mgt.IdentityProviderManager in project carbon-identity-framework by wso2.
the class ApplicationIdentityProviderMgtListener method doPreUpdateIdP.
@Override
public boolean doPreUpdateIdP(String oldIdPName, IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException {
try {
IdentityServiceProviderCache.getInstance().clear(tenantDomain);
IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
ConnectedAppsResult connectedApplications;
String idpId = identityProviderManager.getIdPByName(oldIdPName, tenantDomain).getResourceId();
if (identityProvider.getResourceId() == null && idpId != null) {
identityProvider.setResourceId(idpId);
}
int offset = 0;
do {
connectedApplications = identityProviderManager.getConnectedApplications(idpId, null, offset, tenantDomain);
List<ServiceProvider> serviceProvidersList = new ArrayList<>();
for (String appResourceId : connectedApplications.getApps()) {
ServiceProvider serviceProvider = ApplicationMgtSystemConfig.getInstance().getApplicationDAO().getApplicationByResourceId(appResourceId, tenantDomain);
serviceProvidersList.add(serviceProvider);
}
for (ServiceProvider serviceProvider : serviceProvidersList) {
LocalAndOutboundAuthenticationConfig localAndOutboundAuthConfig = serviceProvider.getLocalAndOutBoundAuthenticationConfig();
AuthenticationStep[] authSteps = localAndOutboundAuthConfig.getAuthenticationSteps();
OutboundProvisioningConfig outboundProvisioningConfig = serviceProvider.getOutboundProvisioningConfig();
IdentityProvider[] provisioningIdps = outboundProvisioningConfig.getProvisioningIdentityProviders();
// Check whether the identity provider is referred in a service provider
validateIdpDisable(identityProvider, authSteps, provisioningIdps);
// Validating Applications with Federated Authenticators configured.
updateApplicationWithFederatedAuthenticators(identityProvider, tenantDomain, serviceProvider, localAndOutboundAuthConfig, authSteps);
// Validating Applications with Outbound Provisioning Connectors configured.
updateApplicationWithProvisioningConnectors(identityProvider, provisioningIdps);
// Clear application caches if IDP name is updated.
if (!StringUtils.equals(oldIdPName, identityProvider.getIdentityProviderName())) {
CacheBackedApplicationDAO.clearAllAppCache(serviceProvider, tenantDomain);
}
}
offset = connectedApplications.getOffSet() + connectedApplications.getLimit();
} while (connectedApplications.getTotalAppCount() > offset);
} catch (IdentityApplicationManagementException e) {
throw new IdentityProviderManagementException("Error when updating default authenticator of service providers", e);
}
return true;
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager in project carbon-identity-framework by wso2.
the class IdentityProviderManager method updateIdP.
/**
* Updates a given Identity Provider information
*
* @param oldIdPName existing Identity Provider name
* @param newIdentityProvider new IdP information
* @throws IdentityProviderManagementException Error when updating Identity Provider
* information
* @deprecated use {@link IdentityProviderManager#updateIdPByResourceId(String, IdentityProvider, String)} instead.
*/
@Deprecated
@Override
public void updateIdP(String oldIdPName, IdentityProvider newIdentityProvider, String tenantDomain) throws IdentityProviderManagementException {
// Invoking the pre listeners.
Collection<IdentityProviderMgtListener> listeners = IdPManagementServiceComponent.getIdpMgtListeners();
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreUpdateIdP(oldIdPName, newIdentityProvider, tenantDomain)) {
return;
}
}
IdentityProvider currentIdentityProvider = this.getIdPByName(oldIdPName, tenantDomain, true);
if (currentIdentityProvider == null) {
throw IdPManagementUtil.handleClientException(IdPManagementConstants.ErrorMessage.ERROR_CODE_IDP_NAME_DOES_NOT_EXIST, oldIdPName);
}
updateIDP(currentIdentityProvider, newIdentityProvider, IdentityTenantUtil.getTenantId(tenantDomain), tenantDomain);
// Invoking the post listeners.
for (IdentityProviderMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostUpdateIdP(oldIdPName, newIdentityProvider, tenantDomain)) {
return;
}
}
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager in project identity-inbound-auth-oauth by wso2-extensions.
the class SAML2BearerGrantHandlerTest method prepareForGetIssuer.
private void prepareForGetIssuer() throws Exception {
when(tenantManager.getTenantId(anyString())).thenReturn(-1234);
when(realmService.getTenantManager()).thenReturn(tenantManager);
SAMLSSOUtil.setRealmService(realmService);
federatedAuthenticatorConfig.setProperties(new Property[] { getProperty(IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID, TestConstants.LOACALHOST_DOMAIN) });
federatedAuthenticatorConfig.setName(IdentityApplicationConstants.Authenticator.SAML2SSO.NAME);
FederatedAuthenticatorConfig[] fedAuthConfs = { federatedAuthenticatorConfig };
IdentityProvider identityProvider = getIdentityProvider("LOCAL", TestConstants.OAUTH2_TOKEN_EP);
identityProvider.setFederatedAuthenticatorConfigs(fedAuthConfs);
mockStatic(IdentityProviderManager.class);
when(IdentityProviderManager.getInstance()).thenReturn(identityProviderManager);
when(identityProviderManager.getResidentIdP(anyString())).thenReturn(identityProvider);
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager in project identity-inbound-auth-oauth by wso2-extensions.
the class RequestObjectValidatorImplTest method mockIdentityProviderManager.
private void mockIdentityProviderManager() throws Exception {
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName("LOCAL");
idp.setEnable(true);
PowerMockito.mockStatic(IdentityProviderManager.class);
IdentityProviderManager identityProviderManager = mock(IdentityProviderManager.class);
when(IdentityProviderManager.getInstance()).thenReturn(identityProviderManager);
when(identityProviderManager.getResidentIdP(anyString())).thenReturn(idp);
}
use of org.wso2.carbon.idp.mgt.IdentityProviderManager in project identity-inbound-auth-oauth by wso2-extensions.
the class SAML2BearerGrantHandlerTest method initIdentityProviderManager.
private IdentityProvider initIdentityProviderManager(String idpName, String alias) throws Exception {
mockStatic(IdentityApplicationManagementUtil.class);
IdentityProvider identityProviderIns = getIdentityProvider(idpName, alias);
when(IdentityProviderManager.getInstance()).thenReturn(identityProviderManager);
when(identityProviderManager.getIdPByAuthenticatorPropertyValue(anyString(), anyString(), anyString(), anyString(), anyBoolean())).thenReturn(identityProviderIns);
if (IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME.equals(idpName)) {
when(identityProviderManager.getResidentIdP(anyString())).thenReturn(identityProviderIns);
}
return identityProviderIns;
}
Aggregations