use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImplTest method testCreateApplication.
@Test(dataProvider = "addApplicationDataProvider")
public void testCreateApplication(Object serviceProvider, String tenantDomain, String username) throws IdentityApplicationManagementException {
// Adding application.
addApplicationConfigurations((ServiceProvider) serviceProvider);
String resourceId = applicationManagementService.createApplication((ServiceProvider) serviceProvider, tenantDomain, username);
// Retrieving application by ResourceId
ServiceProvider expectedSP = applicationManagementService.getApplicationByResourceId(resourceId, tenantDomain);
Assert.assertEquals(resourceId, expectedSP.getApplicationResourceId());
ApplicationBasicInfo applicationBasicInfo = applicationManagementService.getApplicationBasicInfoByResourceId(resourceId, tenantDomain);
Assert.assertEquals(applicationBasicInfo.getApplicationName(), ((ServiceProvider) serviceProvider).getApplicationName());
// Deleting added application
applicationManagementService.deleteApplicationByResourceId(resourceId, tenantDomain, username);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationMgtUtilTest method testIsValidApplicationOwner.
@Test(dataProvider = "validApplicationOwnerDataProvider")
public void testIsValidApplicationOwner(String username, String tenantDomain, Boolean hasOwner, Boolean expected) throws IdentityApplicationManagementException, UserStoreException {
ServiceProvider serviceProvider = new ServiceProvider();
if (hasOwner) {
User user = new User();
user.setUserName(username);
user.setTenantDomain(tenantDomain);
serviceProvider.setOwner(user);
}
mockUserStoreManager();
when(mockUserStoreManager.isExistingUser(anyString())).thenReturn(FALSE);
when(mockUserRealm.getRealmConfiguration()).thenReturn(mockRealmConfiguration);
when(mockRealmConfiguration.getAdminUserName()).thenReturn("admin");
when(mockRealmConfiguration.getUserStoreProperty(anyString())).thenReturn("property");
when(mockCarbonContext.getTenantDomain()).thenReturn(TENANT_DOMAIN);
assertEquals(ApplicationMgtUtil.isValidApplicationOwner(serviceProvider), expected);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class FileBasedApplicationDAO method getServiceProviderToLocalIdPClaimMapping.
@Override
public Map<String, String> getServiceProviderToLocalIdPClaimMapping(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
ServiceProvider serviceProvider = ApplicationManagementServiceComponent.getFileBasedSPs().get(serviceProviderName);
Map<String, String> claimMap = new HashMap<String, String>();
if (serviceProvider == null || serviceProvider.getClaimConfig() == null) {
return claimMap;
}
ClaimMapping[] claimMappings = serviceProvider.getClaimConfig().getClaimMappings();
if (claimMappings != null && claimMappings.length > 0) {
for (ClaimMapping mapping : claimMappings) {
if (mapping.getLocalClaim() != null && mapping.getLocalClaim().getClaimUri() != null && mapping.getRemoteClaim() != null && mapping.getRemoteClaim().getClaimUri() != null) {
claimMap.put(mapping.getRemoteClaim().getClaimUri(), mapping.getLocalClaim().getClaimUri());
}
}
}
return claimMap;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationIdentityProviderMgtListener method doPostUpdateIdP.
@Override
public boolean doPostUpdateIdP(String oldIdPName, IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException {
try {
IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
ConnectedAppsResult connectedApplications;
String updatedIdpId = identityProvider.getResourceId();
ApplicationDAO applicationDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
int offset = 0;
do {
connectedApplications = identityProviderManager.getConnectedApplications(updatedIdpId, null, offset, tenantDomain);
for (String appResourceId : connectedApplications.getApps()) {
ServiceProvider serviceProvider = applicationDAO.getApplicationByResourceId(appResourceId, tenantDomain);
applicationDAO.clearApplicationFromCache(serviceProvider, tenantDomain);
}
offset = connectedApplications.getOffSet() + connectedApplications.getLimit();
} while (connectedApplications.getTotalAppCount() > offset);
} catch (IdentityApplicationManagementException e) {
throw new IdentityProviderManagementException("Error while running post IDP update tasks.", e);
}
return true;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationIdentityProviderMgtListener method updateApplicationWithFederatedAuthenticator.
/**
* Update the service providers, with the default authenticator of the identity provider.
*
* @param identityProvider
* @param tenantDomain
* @param serviceProvider
* @param authStep
* @throws IdentityApplicationManagementException
* @throws IdentityProviderManagementException
*/
private void updateApplicationWithFederatedAuthenticator(IdentityProvider identityProvider, String tenantDomain, ServiceProvider serviceProvider, AuthenticationStep authStep) throws IdentityApplicationManagementException, IdentityProviderManagementException {
IdentityProvider fedIdp = authStep.getFederatedIdentityProviders()[0];
if (StringUtils.equals(fedIdp.getIdentityProviderName(), identityProvider.getIdentityProviderName())) {
String defaultAuthName = fedIdp.getDefaultAuthenticatorConfig().getName();
if (identityProvider.getDefaultAuthenticatorConfig() != null) {
String currentDefaultAuthName = identityProvider.getDefaultAuthenticatorConfig().getName();
boolean isCurrentDefaultAuthEnabled = identityProvider.getDefaultAuthenticatorConfig().isEnabled();
if (!StringUtils.equals(currentDefaultAuthName, defaultAuthName)) {
FederatedAuthenticatorConfig currentDefaultAuthenticatorConfig = identityProvider.getDefaultAuthenticatorConfig();
fedIdp.setDefaultAuthenticatorConfig(currentDefaultAuthenticatorConfig);
fedIdp.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[] { currentDefaultAuthenticatorConfig });
ApplicationMgtSystemConfig.getInstance().getApplicationDAO().updateApplication(serviceProvider, tenantDomain);
} else if (!isCurrentDefaultAuthEnabled && StringUtils.equals(currentDefaultAuthName, defaultAuthName)) {
throw new IdentityProviderManagementException("Error in disabling default federated authenticator" + " as it is referred by service providers.");
}
}
}
}
Aggregations