Search in sources :

Example 1 with IdentityApplicationRegistrationFailureException

use of org.wso2.carbon.identity.application.common.IdentityApplicationRegistrationFailureException in project carbon-identity-framework by wso2.

the class ApplicationManagementServiceImpl method doPreAddApplicationChecks.

private void doPreAddApplicationChecks(ServiceProvider serviceProvider, String tenantDomain, String username) throws IdentityApplicationManagementException {
    String appName = serviceProvider.getApplicationName();
    if (StringUtils.isBlank(appName)) {
        // check for required attributes.
        throw buildClientException(INVALID_REQUEST, "Application name cannot be empty.");
    }
    ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
    if (appDAO.isApplicationExists(appName, tenantDomain)) {
        String msg = "An application with name: '" + appName + "' already exists in tenantDomain: " + tenantDomain;
        throw new IdentityApplicationRegistrationFailureException(APPLICATION_ALREADY_EXISTS.getCode(), msg);
    }
    if (ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(appName)) {
        String msg = "Application with name: '" + appName + "' already loaded from the file system.";
        throw buildClientException(APPLICATION_ALREADY_EXISTS, msg);
    }
    if (!isRegexValidated(appName)) {
        String message = "The Application name: '" + appName + "' is not valid! It is not adhering to the regex: " + ApplicationMgtUtil.getSPValidatorRegex();
        throw buildClientException(INVALID_REQUEST, message);
    }
    addUserIdAsDefaultSubject(serviceProvider);
    validateApplicationConfigurations(serviceProvider, tenantDomain, username);
}
Also used : PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) IdentityApplicationRegistrationFailureException(org.wso2.carbon.identity.application.common.IdentityApplicationRegistrationFailureException)

Aggregations

IdentityApplicationRegistrationFailureException (org.wso2.carbon.identity.application.common.IdentityApplicationRegistrationFailureException)1 ApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO)1 PaginatableFilterableApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO)1 FileBasedApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO)1