Search in sources :

Example 1 with BasePersistenceException

use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method save.

public String save() throws IOException {
    try {
        // Reload entry to include latest changes
        GluuConfiguration configuration = configurationService.getConfiguration();
        boolean updateAuthenticationMode = false;
        boolean updateOxTrustAuthenticationMode = false;
        String oldAuthName = getFirstConfigName(configuration.getOxIDPAuthentication());
        if (oldAuthName != null) {
            if (oldAuthName.equals(this.authenticationMode)) {
                updateAuthenticationMode = true;
            }
            if (oldAuthName.equals(this.oxTrustAuthenticationMode)) {
                updateOxTrustAuthenticationMode = true;
            }
        }
        updateAuthConf(configuration);
        String newAuthName = getFirstConfigName(configuration.getOxIDPAuthentication());
        String updatedAuthMode = updateAuthenticationMode ? newAuthName : this.authenticationMode;
        String updatedOxTrustAuthMode = updateOxTrustAuthenticationMode ? newAuthName : this.oxTrustAuthenticationMode;
        configuration.setAuthenticationMode(updatedAuthMode);
        configuration.setOxTrustAuthenticationMode(updatedOxTrustAuthMode);
        setAuthenticationRecaptcha();
        configuration.setPassportEnabled(passportEnable);
        configurationService.updateConfiguration(configuration);
    } catch (BasePersistenceException ex) {
        log.error("Failed to update configuration configuration", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update configuration");
        return OxTrustConstants.RESULT_FAILURE;
    }
    reset();
    facesMessages.add(FacesMessage.SEVERITY_INFO, facesMessages.evalResourceAsString("#{msgs['configuration.manageAuthentication.updateSucceed']}"));
    conversationService.endConversation();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration)

Example 2 with BasePersistenceException

use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.

the class UpdateClientAction method add.

public String add() throws Exception {
    if (this.client != null) {
        this.client.setOxAuthAppType(OxAuthApplicationType.WEB);
        this.client.setSubjectType(OxAuthSubjectType.PAIRWISE);
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.oxAttributesJson = getClientAttributesJson();
    this.client = new OxAuthClient();
    this.client.setOxAuthAppType(OxAuthApplicationType.WEB);
    this.client.setSubjectType(OxAuthSubjectType.PAIRWISE);
    try {
        this.loginUris = getNonEmptyStringList(client.getOxAuthRedirectURIs());
        this.logoutUris = getNonEmptyStringList(client.getOxAuthPostLogoutRedirectURIs());
        this.clientlogoutUris = getNonEmptyStringList(client.getLogoutUri());
        this.scopes = getInitialEntries();
        this.claims = getInitialClaimDisplayNameEntries();
        this.responseTypes = getInitialResponseTypes();
        this.grantTypes = getInitialGrantTypes();
        this.contacts = getNonEmptyStringList(client.getContacts());
        this.requestUris = getNonEmptyStringList(client.getRequestUris());
        this.authorizedOrigins = getNonEmptyStringList(client.getAuthorizedOrigins());
        this.claimRedirectURIList = getNonEmptyStringList(client.getClaimRedirectURI());
        this.customScripts = getInitialAcrs();
        this.postAuthnScripts = Lists.newArrayList();
        this.rptClaimsScripts = Lists.newArrayList();
        this.consentScripts = Lists.newArrayList();
        this.spontaneousScopesScripts = Lists.newArrayList();
    } catch (BasePersistenceException ex) {
        log.error("Failed to prepare lists", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new client");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 3 with BasePersistenceException

use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.

the class UpdateOrganizationAction method modifyOrganization.

private String modifyOrganization() {
    if (this.organization != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuOrganization tmpOrganization = organizationService.getOrganization();
        this.organization = new GluuOrganization();
        try {
            PropertyUtils.copyProperties(this.organization, tmpOrganization);
        } catch (Exception ex) {
            log.error("Failed to load organization", ex);
            this.organization = null;
        }
    } catch (BasePersistenceException ex) {
        log.error("Failed to load organization", ex);
    }
    if (this.organization == null) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.loginPageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_LOGIN_PAGE);
    this.welcomePageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_WELCOME_PAGE);
    this.welcomeTitleText = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_TITLE_TEXT);
    initOxAuthSetting();
    configurations = new ArrayList<GluuConfiguration>();
    configurations.addAll(configurationService.getConfigurations());
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) IOException(java.io.IOException)

Example 4 with BasePersistenceException

use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.

the class UpdateScopeAction method searchAvailableDynamicScripts.

public void searchAvailableDynamicScripts() {
    if (this.availableDynamicScripts != null) {
        selectAddedDynamicScripts();
        return;
    }
    try {
        List<CustomScript> availableScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.DYNAMIC_SCOPE), CUSTOM_SCRIPT_RETURN_ATTRIBUTES);
        List<SelectableEntity<CustomScript>> tmpAvailableDynamicScripts = new ArrayList<SelectableEntity<CustomScript>>();
        for (CustomScript dynamicScript : availableScripts) {
            if (dynamicScript.isEnabled()) {
                tmpAvailableDynamicScripts.add(new SelectableEntity<CustomScript>(dynamicScript));
            }
        }
        this.availableDynamicScripts = tmpAvailableDynamicScripts;
        selectAddedDynamicScripts();
    } catch (BasePersistenceException ex) {
        log.error("Failed to find available authorization policies", ex);
    }
}
Also used : CustomScript(org.gluu.model.custom.script.model.CustomScript) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) SelectableEntity(org.gluu.model.SelectableEntity) ArrayList(java.util.ArrayList)

Example 5 with BasePersistenceException

use of org.gluu.persist.exception.BasePersistenceException in project oxTrust by GluuFederation.

the class UpdateTrustRelationshipAction method delete.

public String delete() {
    String result = OxTrustConstants.RESULT_FAILURE;
    if (update) {
        try {
            if (GluuStatus.ACTIVE.equals(this.trustRelationship.getStatus()) && this.trustRelationship.isFederation()) {
                facesMessages.add(FacesMessage.SEVERITY_WARN, "'#{updateTrustRelationshipAction.trustRelationship.displayName}' has associated Trust Relationship(s) depending on it and cannot be deleted. Please disable the federation and try again.");
                return result;
            }
            synchronized (svnSyncTimer) {
                for (GluuSAMLTrustRelationship trust : trustService.getDeconstructedTrustRelationships(this.trustRelationship)) {
                    log.info("Deleting child:" + trust.getDisplayName());
                    trustService.removeTrustRelationship(trust);
                }
                shibboleth3ConfService.removeSpMetadataFile(this.trustRelationship.getSpMetaDataFN());
                trustService.removeTrustRelationship(this.trustRelationship);
                oxTrustAuditService.audit("TR " + this.trustRelationship.getInum() + " **" + this.trustRelationship.getDisplayName() + "** REMOVED", identity.getUser(), (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
            }
            result = OxTrustConstants.RESULT_SUCCESS;
        } catch (BasePersistenceException ex) {
            result = OxTrustConstants.RESULT_FAILURE;
            log.error("Failed to remove trust relationship {}", this.trustRelationship.getInum(), ex);
        } finally {
            List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
            updateShibboleth3ConfigurationForDelete(trustRelationships);
        }
    }
    if (OxTrustConstants.RESULT_SUCCESS.equals(result)) {
        facesMessages.add(FacesMessage.SEVERITY_INFO, "Relationship '#{updateTrustRelationshipAction.trustRelationship.displayName}' removed successfully");
    } else if (OxTrustConstants.RESULT_FAILURE.equals(result)) {
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to remove relationship '#{updateTrustRelationshipAction.trustRelationship.displayName}'");
    }
    return result;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException)

Aggregations

BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)22 ArrayList (java.util.ArrayList)4 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)4 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)3 OxAuthClient (org.gluu.oxtrust.model.OxAuthClient)3 LdapOxAuthConfiguration (org.gluu.config.oxtrust.LdapOxAuthConfiguration)2 SelectableEntity (org.gluu.model.SelectableEntity)2 CustomScript (org.gluu.model.custom.script.model.CustomScript)2 Scope (org.oxauth.persistence.model.Scope)2 IOException (java.io.IOException)1 Date (java.util.Date)1 WebKeysSettings (org.gluu.config.oxauth.WebKeysSettings)1 DbApplicationConfiguration (org.gluu.config.oxtrust.DbApplicationConfiguration)1 LdapOxTrustConfiguration (org.gluu.config.oxtrust.LdapOxTrustConfiguration)1 DisplayNameEntry (org.gluu.model.DisplayNameEntry)1 UmaResource (org.gluu.oxauth.model.uma.persistence.UmaResource)1 DuplicateEmailException (org.gluu.oxtrust.exception.DuplicateEmailException)1 GluuInumMap (org.gluu.oxtrust.ldap.cache.model.GluuInumMap)1 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)1 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)1