use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class JsGraphBuilderTest method filterOptionsDataProvider.
@DataProvider
public Object[][] filterOptionsDataProvider() {
ApplicationAuthenticatorService.getInstance().getLocalAuthenticators().clear();
LocalAuthenticatorConfig basic = new LocalAuthenticatorConfig();
basic.setName("BasicAuthenticator");
basic.setDisplayName("basic");
LocalAuthenticatorConfig totp = new LocalAuthenticatorConfig();
totp.setName("TOTPAuthenticator");
totp.setDisplayName("totp");
ApplicationAuthenticatorService.getInstance().getLocalAuthenticators().add(basic);
ApplicationAuthenticatorService.getInstance().getLocalAuthenticators().add(totp);
IdentityProvider localIdp = new IdentityProvider();
localIdp.setId("LOCAL");
localIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[0]);
FederatedAuthenticatorConfig samlFederated = new FederatedAuthenticatorConfig();
samlFederated.setDisplayName("samlsso");
samlFederated.setName("SAMLAuthenticator");
FederatedAuthenticatorConfig oidcFederated = new FederatedAuthenticatorConfig();
oidcFederated.setDisplayName("oidc");
oidcFederated.setName("OIDCAuthenticator");
FederatedAuthenticatorConfig twitterFederated = new FederatedAuthenticatorConfig();
twitterFederated.setDisplayName("twitter");
twitterFederated.setName("TwitterAuthenticator");
IdentityProvider customIdp1 = new IdentityProvider();
customIdp1.setId("customIdp1");
customIdp1.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { samlFederated, oidcFederated });
customIdp1.setDefaultAuthenticatorConfig(samlFederated);
IdentityProvider customIdp2 = new IdentityProvider();
customIdp2.setId("customIdp2");
customIdp2.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { twitterFederated });
customIdp2.setDefaultAuthenticatorConfig(twitterFederated);
AuthenticatorConfig basicAuthConfig = new AuthenticatorConfig();
basicAuthConfig.setName("BasicAuthenticator");
basicAuthConfig.setEnabled(true);
basicAuthConfig.getIdps().put("LOCAL", localIdp);
AuthenticatorConfig totpAuthConfig = new AuthenticatorConfig();
totpAuthConfig.setName("TOTPAuthenticator");
totpAuthConfig.setEnabled(true);
totpAuthConfig.getIdps().put("LOCAL", localIdp);
AuthenticatorConfig samlAuthConfig = new AuthenticatorConfig();
samlAuthConfig.setName("SAMLAuthenticator");
samlAuthConfig.setEnabled(true);
samlAuthConfig.getIdps().put("customIdp1", customIdp1);
AuthenticatorConfig oidcAuthConfig = new AuthenticatorConfig();
oidcAuthConfig.setName("OIDCAuthenticator");
oidcAuthConfig.setEnabled(true);
oidcAuthConfig.getIdps().put("customIdp1", customIdp1);
AuthenticatorConfig twitterAuthConfig = new AuthenticatorConfig();
twitterAuthConfig.setName("TwitterAuthenticator");
twitterAuthConfig.setEnabled(true);
twitterAuthConfig.getIdps().put("customIdp2", customIdp2);
StepConfig stepWithSingleOption = new StepConfig();
stepWithSingleOption.setAuthenticatorList(Collections.singletonList(basicAuthConfig));
Map<String, Map<String, String>> singleOptionConfig = new HashMap<>();
singleOptionConfig.put("0", Collections.singletonMap("authenticator", "basic"));
StepConfig stepWithMultipleOptions = new StepConfig();
stepWithMultipleOptions.setAuthenticatorList(new ArrayList<>(Arrays.asList(basicAuthConfig, totpAuthConfig, oidcAuthConfig, twitterAuthConfig)));
Map<String, String> oidcOption = new HashMap<>();
oidcOption.put("idp", "customIdp1");
oidcOption.put("authenticator", "oidc");
Map<String, String> twitterOption = new HashMap<>();
twitterOption.put("idp", "customIdp2");
twitterOption.put("authenticator", "twitter");
Map<String, String> invalidOption = new HashMap<>();
invalidOption.put("idp", "customIdp1");
invalidOption.put("authenticator", "twitter");
Map<String, Map<String, String>> multipleOptionConfig = new HashMap<>();
multipleOptionConfig.put("0", Collections.singletonMap("authenticator", "basic"));
multipleOptionConfig.put("1", oidcOption);
multipleOptionConfig.put("2", twitterOption);
Map<String, Map<String, String>> multipleAndInvalidOptionConfig = new HashMap<>();
multipleAndInvalidOptionConfig.put("0", Collections.singletonMap("authenticator", "basic"));
multipleAndInvalidOptionConfig.put("1", oidcOption);
multipleAndInvalidOptionConfig.put("2", invalidOption);
Map<String, Map<String, String>> idpOnlyOptionConfig = new HashMap<>();
idpOnlyOptionConfig.put("0", Collections.singletonMap("authenticator", "basic"));
idpOnlyOptionConfig.put("1", Collections.singletonMap("idp", "customIdp1"));
Map<String, Map<String, String>> singleInvalidOptionConfig = new HashMap<>();
singleInvalidOptionConfig.put("0", invalidOption);
return new Object[][] { { singleOptionConfig, duplicateStepConfig(stepWithSingleOption), 1 }, { singleOptionConfig, duplicateStepConfig(stepWithMultipleOptions), 1 }, { multipleOptionConfig, duplicateStepConfig(stepWithMultipleOptions), 3 }, { multipleAndInvalidOptionConfig, duplicateStepConfig(stepWithMultipleOptions), 2 }, { singleInvalidOptionConfig, duplicateStepConfig(stepWithMultipleOptions), 4 }, { idpOnlyOptionConfig, duplicateStepConfig(stepWithMultipleOptions), 2 } };
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider 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.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManagementService method getPaginatedIdpInfo.
/**
* Retrieves Identity providers list of array for the logged-in tenant.
*
* @param filter searching value.
* @param pageNumber page number.
* @return Identity providers list of array.
* @throws IdentityProviderManagementException Error when getting list of Identity Providers.
*/
public IdentityProvider[] getPaginatedIdpInfo(String filter, int pageNumber) throws IdentityProviderManagementException {
validateRequestedPageNumber(pageNumber);
Integer limit = IdentityUtil.getDefaultItemsPerPage();
Integer offset = getIdpPageOffset(pageNumber, limit);
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
IdpSearchResult idpSearchResult = IdentityProviderManager.getInstance().getIdPs(limit, offset, filter, IdPManagementConstants.DEFAULT_SORT_ORDER, IdPManagementConstants.DEFAULT_SORT_BY, tenantDomain, new ArrayList<>());
return idpSearchResult.getIdPs().toArray(new IdentityProvider[0]);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider 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;
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdentityProviderManager method getIdPById.
@Override
public IdentityProvider getIdPById(String id, String tenantDomain, boolean ignoreFileBasedIdps) throws IdentityProviderManagementException {
if (StringUtils.isEmpty(id)) {
String msg = "Invalid argument: Identity Provider ID value is empty";
throw new IdentityProviderManagementException(msg);
}
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
Integer intId;
IdentityProvider identityProvider = null;
try {
intId = Integer.parseInt(id);
identityProvider = dao.getIdPById(null, intId, tenantId, tenantDomain);
} catch (NumberFormatException e) {
// Ignore this.
}
if (!ignoreFileBasedIdps) {
if (identityProvider == null) {
identityProvider = new FileBasedIdPMgtDAO().getIdPByName(id, tenantDomain);
}
if (identityProvider == null) {
identityProvider = IdPManagementServiceComponent.getFileBasedIdPs().get(IdentityApplicationConstants.DEFAULT_IDP_CONFIG);
}
}
return identityProvider;
}
Aggregations