use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getServiceProviderByClientId.
/**
* @param clientId
* @param clientType
* @param tenantDomain
* @return
* @throws IdentityApplicationManagementException
*/
@Override
public ServiceProvider getServiceProviderByClientId(String clientId, String clientType, String tenantDomain) throws IdentityApplicationManagementException {
// invoking the listeners
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreGetServiceProviderByClientId(clientId, clientType, tenantDomain)) {
return null;
}
}
// client id can contain the @ to identify the tenant domain.
if (clientId != null && clientId.contains("@")) {
clientId = clientId.split("@")[0];
}
String serviceProviderName;
ServiceProvider serviceProvider = null;
serviceProviderName = getServiceProviderNameByClientId(clientId, clientType, tenantDomain);
try {
startTenantFlow(tenantDomain);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
serviceProvider = appDAO.getApplication(serviceProviderName, tenantDomain);
if (serviceProvider != null) {
// if "Authentication Type" is "Default" we must get the steps from the default SP
AuthenticationStep[] authenticationSteps = serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps();
if (authenticationSteps == null || authenticationSteps.length == 0) {
ServiceProvider defaultSP = ApplicationManagementServiceComponent.getFileBasedSPs().get(IdentityApplicationConstants.DEFAULT_SP_CONFIG);
authenticationSteps = defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps();
AuthenticationScriptConfig scriptConfig = defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationScriptConfig();
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(authenticationSteps);
if (scriptConfig != null) {
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(scriptConfig);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType(ApplicationConstants.AUTH_TYPE_FLOW);
}
}
}
} finally {
endTenantFlow();
}
if (serviceProvider == null && serviceProviderName != null && ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(serviceProviderName)) {
serviceProvider = ApplicationManagementServiceComponent.getFileBasedSPs().get(serviceProviderName);
}
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostGetServiceProviderByClientId(serviceProvider, clientId, clientType, tenantDomain)) {
return null;
}
}
return serviceProvider;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method setDefaultAuthenticationSeq.
private void setDefaultAuthenticationSeq(String sequenceName, String tenantDomain, ServiceProvider serviceProvider) throws IdentityApplicationManagementException {
// if "Authentication Type" is "Default", get the tenant wise default authentication sequence if
// available, otherwise the authentication sequence and adaptive script configuration in default SP
DefaultAuthSeqMgtService seqMgtService = DefaultAuthSeqMgtServiceImpl.getInstance();
DefaultAuthenticationSequence sequence;
try {
sequence = seqMgtService.getDefaultAuthenticationSeq(sequenceName, tenantDomain);
} catch (DefaultAuthSeqMgtException e) {
throw new IdentityApplicationManagementException("Error when retrieving default " + "authentication sequence in tenant: " + tenantDomain, e);
}
if (sequence != null && sequence.getContent() != null) {
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(sequence.getContent().getAuthenticationSteps());
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(sequence.getContent().getAuthenticationScriptConfig());
} else {
ServiceProvider defaultSP = ApplicationManagementServiceComponent.getFileBasedSPs().get(IdentityApplicationConstants.DEFAULT_SP_CONFIG);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationSteps());
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(defaultSP.getLocalAndOutBoundAuthenticationConfig().getAuthenticationScriptConfig());
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementAdminService method createApplicationTemplateFromSP.
/**
* Add configured service provider as a template.
*
* @param serviceProvider Service provider to be configured as a template
* @param spTemplate service provider template basic info
* @throws IdentityApplicationManagementClientException
*/
public void createApplicationTemplateFromSP(ServiceProvider serviceProvider, SpTemplate spTemplate) throws IdentityApplicationManagementClientException {
try {
applicationMgtService = ApplicationManagementService.getInstance();
applicationMgtService.createApplicationTemplateFromSP(serviceProvider, spTemplate, getTenantDomain());
} catch (IdentityApplicationManagementClientException e) {
throw e;
} catch (IdentityApplicationManagementException e) {
log.error(String.format("Error while creating service provider template for the configured SP: %s for " + "tenant: %s.", serviceProvider.getApplicationName(), getTenantDomain()), e);
throw new IdentityApplicationManagementClientException(new String[] { "Server error occurred." });
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method importSPApplication.
public ImportResponse importSPApplication(SpFileContent spFileContent, String tenantDomain, String username, boolean isUpdate) throws IdentityApplicationManagementException {
if (log.isDebugEnabled()) {
log.debug("Importing service provider from file " + spFileContent.getFileName());
}
ServiceProvider serviceProvider = unmarshalSP(spFileContent, tenantDomain);
ImportResponse importResponse = importSPApplication(serviceProvider, tenantDomain, username, isUpdate);
if (log.isDebugEnabled()) {
log.debug(String.format("Service provider %s@%s created successfully from file %s", serviceProvider.getApplicationName(), tenantDomain, spFileContent.getFileName()));
}
return importResponse;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class DirectoryServerApplicationMgtListener method doPreDeleteApplication.
@Override
public boolean doPreDeleteApplication(String applicationName, String tenantDomain, String userName) throws IdentityApplicationManagementException {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
ServiceProvider serviceProvider = appDAO.getApplication(applicationName, tenantDomain);
if (serviceProvider != null && serviceProvider.getInboundAuthenticationConfig() != null && serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs() != null) {
InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
for (InboundAuthenticationRequestConfig config : configs) {
if (KERBEROS.equalsIgnoreCase(config.getInboundAuthType()) && config.getInboundAuthKey() != null) {
DirectoryServerManager directoryServerManager = new DirectoryServerManager();
try {
directoryServerManager.removeServer(config.getInboundAuthKey());
} catch (DirectoryServerManagerException e) {
String error = "Error while removing a kerberos: " + config.getInboundAuthKey();
throw new IdentityApplicationManagementException(error, e);
}
break;
}
}
}
return true;
}
Aggregations