use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.
the class IdentityProviderMgtServiceTestCase method testUpdateResidentIdP.
@Test(priority = 21, groups = "wso2.is", description = "test updateResidentIdP operation")
public void testUpdateResidentIdP() throws Exception {
String samlEntityId = "samlssoIdp";
String residentIdpRealm = "testHomeRealm";
IdentityProvider residentProvider = idpMgtServiceClient.getResidentIdP();
// get default value
residentIdpEnable = residentProvider.getEnable();
residentIdpPrimary = residentProvider.getPrimary();
residentIdpName = residentProvider.getIdentityProviderName();
residentIDPDefaultRealm = residentProvider.getHomeRealmId();
idpProperties = residentProvider.getIdpProperties();
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setEnable(true);
identityProvider.setPrimary(true);
identityProvider.setIdentityProviderName("LOCAL");
identityProvider.setHomeRealmId("testHomeRealm");
FederatedAuthenticatorConfig samlFedAuthn = new FederatedAuthenticatorConfig();
samlFedAuthn.setName(SAML2SSO_NAME);
Property[] properties = new Property[1];
Property property = new Property();
property.setName(SAML2SSO_IDP_ENTITY_ID);
property.setValue(samlEntityId);
properties[0] = property;
samlFedAuthn.setProperties(properties);
FederatedAuthenticatorConfig[] federatedAuthenticators = new FederatedAuthenticatorConfig[1];
federatedAuthenticators[0] = samlFedAuthn;
identityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticators);
idpMgtServiceClient.updateResidentIdP(identityProvider);
// check changes
IdentityProvider changedResidentIdp = idpMgtServiceClient.getResidentIdP();
Assert.assertNotNull(changedResidentIdp, "Resident idp retrieval failed");
Assert.assertEquals(changedResidentIdp.getHomeRealmId(), residentIdpRealm);
Assert.assertEquals(changedResidentIdp.getEnable(), true, "Resident idp enable failed");
Assert.assertEquals(changedResidentIdp.getPrimary(), true, "Resident idp primary failed");
boolean found = false;
for (FederatedAuthenticatorConfig fedConfig : changedResidentIdp.getFederatedAuthenticatorConfigs()) {
if (fedConfig.getName().equals(SAML2SSO_NAME)) {
for (Property prop : fedConfig.getProperties()) {
if (prop.getName().equals(SAML2SSO_IDP_ENTITY_ID)) {
found = true;
Assert.assertEquals(prop.getValue(), samlEntityId, "Updating federated authenticator property failed");
break;
}
}
break;
}
}
Assert.assertTrue(found, "Resident idp saml sso properties not found");
}
use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.
the class ApplicationManagementTestCase method testOutboundAuthenticatorConfiguration.
@Test(alwaysRun = true, description = "Testing update Outbound Authenticator Configuration")
public void testOutboundAuthenticatorConfiguration() {
String applicationName = "TestServiceProvider";
try {
ServiceProvider serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType("federated");
AuthenticationStep authStep = new AuthenticationStep();
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName("fed_idp");
FederatedAuthenticatorConfig customConfig = new FederatedAuthenticatorConfig();
customConfig.setName("test_auth");
customConfig.setEnabled(true);
idp.setDefaultAuthenticatorConfig(customConfig);
createIdp(idp);
authStep.setFederatedIdentityProviders(new IdentityProvider[] { idp });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri("subject_claim_uri");
applicationManagementServiceClient.updateApplicationData(serviceProvider);
ServiceProvider updatedServiceProvider = applicationManagementServiceClient.getApplication(applicationName);
Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps()[0].getFederatedIdentityProviders()[0].getIdentityProviderName(), "fed_idp", "Failed update Authentication step");
Assert.assertEquals(updatedServiceProvider.getLocalAndOutBoundAuthenticationConfig().getSubjectClaimUri(), "subject_claim_uri", "Failed update subject claim uri");
} catch (Exception e) {
Assert.fail("Error while trying to update Outbound Authenticator Configuration", e);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.
the class ApplicationManagementTestCase method createIdp.
private void createIdp(IdentityProvider idp) throws Exception {
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
IdentityProviderMgtServiceClient identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL, configContext);
org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider identityProvider = new org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider();
identityProvider.setIdentityProviderName(idp.getIdentityProviderName());
org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig federatedAuthenticatorConfig = new org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig();
federatedAuthenticatorConfig.setName(idp.getDefaultAuthenticatorConfig().getName());
federatedAuthenticatorConfig.setEnabled(idp.getDefaultAuthenticatorConfig().getEnabled());
identityProvider.setFederatedAuthenticatorConfigs(new org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig[] { federatedAuthenticatorConfig });
identityProvider.setDefaultAuthenticatorConfig(federatedAuthenticatorConfig);
identityProviderMgtServiceClient.addIdP(identityProvider);
}
use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.
the class SelfSignUpConsentTest method updateResidentIDP.
private void updateResidentIDP(IdentityProvider residentIdentityProvider, boolean isSuperTenant) throws Exception {
FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = residentIdentityProvider.getFederatedAuthenticatorConfigs();
for (FederatedAuthenticatorConfig authenticatorConfig : federatedAuthenticatorConfigs) {
if (!authenticatorConfig.getName().equalsIgnoreCase("samlsso")) {
federatedAuthenticatorConfigs = (FederatedAuthenticatorConfig[]) ArrayUtils.removeElement(federatedAuthenticatorConfigs, authenticatorConfig);
}
}
residentIdentityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticatorConfigs);
if (isSuperTenant) {
superTenantIDPMgtClient.updateResidentIdP(residentIdentityProvider);
} else {
tenantIDPMgtClient.updateResidentIdP(residentIdentityProvider);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig in project product-is by wso2.
the class EmailOTPTestCase method getEmailOTPIdP.
/**
* This method is to create and get the email otp identity provider.
*
* @return Identity provider.
* @throws Exception Error when adding Identity Provider information.
*/
private IdentityProvider getEmailOTPIdP() throws Exception {
IdentityProvider identityProvider = new IdentityProvider();
identityProvider.setIdentityProviderName(IDENTITY_PROVIDER_NAME);
identityProvider.setAlias(IDENTITY_PROVIDER_ALIAS);
identityProvider.setEnable(true);
FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig();
federatedAuthenticatorConfig.setName(AUTHENTICATOR_NAME);
federatedAuthenticatorConfig.setEnabled(true);
identityProvider.setDefaultAuthenticatorConfig(federatedAuthenticatorConfig);
identityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { federatedAuthenticatorConfig });
createIdP(identityProvider);
return identityProvider;
}
Aggregations