Search in sources :

Example 21 with BaseMappingException

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

the class UpdateSectorIdentifierAction method add.

public String add() throws Exception {
    if (this.sectorIdentifier != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.sectorIdentifier = new OxAuthSectorIdentifier();
    try {
        this.loginUris = getNonEmptyStringList(sectorIdentifier.getRedirectUris());
        if (sectorIdentifier.getClientIds() != null && sectorIdentifier.getClientIds().size() > 0)
            this.loginUris.addAll(clientRedirectUriList(sectorIdentifier.getClientIds()));
        this.clientDisplayNameEntries = loadClientDisplayNameEntries();
    } catch (BaseMappingException ex) {
        log.error("Failed to load login Uris", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new sector identifier");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthSectorIdentifier(org.gluu.oxtrust.model.OxAuthSectorIdentifier)

Example 22 with BaseMappingException

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

the class UpdateTrustRelationshipAction method saveImpl.

public String saveImpl() {
    synchronized (svnSyncTimer) {
        if (StringHelper.isEmpty(this.trustRelationship.getInum())) {
            this.inum = trustService.generateInumForNewTrustRelationship();
            this.trustRelationship.setInum(this.inum);
        } else {
            this.inum = this.trustRelationship.getInum();
            if (this.trustRelationship.getSpMetaDataFN() == null)
                update = true;
        }
        boolean updateShib3Configuration = appConfiguration.isConfigGeneration();
        switch(trustRelationship.getSpMetaDataSourceType()) {
            case GENERATE:
                try {
                    String certificate = getCertForGeneratedSP();
                    GluuStatus status = StringHelper.isNotEmpty(certificate) ? GluuStatus.ACTIVE : GluuStatus.INACTIVE;
                    this.trustRelationship.setStatus(status);
                    if (generateSpMetaDataFile(certificate)) {
                        setEntityId();
                    } else {
                        log.error("Failed to generate SP meta-data file");
                        return OxTrustConstants.RESULT_FAILURE;
                    }
                } catch (IOException ex) {
                    log.error("Failed to download SP certificate", ex);
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to download SP certificate");
                    return OxTrustConstants.RESULT_FAILURE;
                }
                break;
            case FILE:
                try {
                    if (saveSpMetaDataFileSourceTypeFile()) {
                        // update = true;
                        updateSpMetaDataCert(certWrapper);
                        // setEntityId();
                        if (!update) {
                            this.trustRelationship.setStatus(GluuStatus.ACTIVE);
                        }
                    } else {
                        log.error("Failed to save SP meta-data file {}", fileWrapper);
                        return OxTrustConstants.RESULT_FAILURE;
                    }
                } catch (IOException ex) {
                    log.error("Failed to download SP metadata", ex);
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to download SP metadata");
                    return OxTrustConstants.RESULT_FAILURE;
                }
                break;
            case URI:
                try {
                    // if (saveSpMetaDataFileSourceTypeURI()) {
                    // setEntityId();
                    boolean result = shibboleth3ConfService.existsResourceUri(trustRelationship.getSpMetaDataURL());
                    if (result) {
                        newThreadSaveSpMetaDataFileSourceTypeURI();
                    } else {
                        log.info("There is no resource found Uri : {}", trustRelationship.getSpMetaDataURL());
                    }
                    if (!update) {
                        this.trustRelationship.setStatus(GluuStatus.ACTIVE);
                    }
                /*} else {
						log.error("Failed to save SP meta-data file {}", fileWrapper);
						return OxTrustConstants.RESULT_FAILURE;
					}*/
                } catch (Exception e) {
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "Unable to download metadata");
                    return "unable_download_metadata";
                }
                break;
            case FEDERATION:
                if (!update) {
                    this.trustRelationship.setStatus(GluuStatus.ACTIVE);
                }
                if (this.trustRelationship.getEntityId() == null) {
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "EntityID must be set to a value");
                    return "invalid_entity_id";
                }
                break;
            default:
                break;
        }
        trustService.updateReleasedAttributes(this.trustRelationship);
        // We call it from TR validation timer
        if (trustRelationship.getSpMetaDataSourceType().equals(GluuMetadataSourceType.GENERATE) || (trustRelationship.getSpMetaDataSourceType().equals(GluuMetadataSourceType.FEDERATION))) {
            boolean federation = shibboleth3ConfService.isFederation(this.trustRelationship);
            this.trustRelationship.setFederation(federation);
        }
        trustContactsAction.saveContacts();
        if (update) {
            try {
                saveTR(update);
            } catch (BaseMappingException ex) {
                log.error("Failed to update trust relationship {}", inum, ex);
                return OxTrustConstants.RESULT_FAILURE;
            }
        } else {
            String dn = trustService.getDnForTrustRelationShip(this.inum);
            // Save trustRelationship
            this.trustRelationship.setDn(dn);
            try {
                saveTR(update);
            } catch (BaseMappingException ex) {
                log.error("Failed to add new trust relationship {}", this.trustRelationship.getInum(), ex);
                return OxTrustConstants.RESULT_FAILURE;
            }
            this.update = true;
        }
        if (updateShib3Configuration) {
            List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
            updateShibboleth3Configuration(trustRelationships);
        }
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) GluuStatus(org.gluu.persist.model.base.GluuStatus) IOException(java.io.IOException) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException)

Example 23 with BaseMappingException

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

the class UserProfileAction method update.

public String update() {
    try {
        if (this.imapData != null) {
            List<GluuCustomAttribute> customAttributes = this.person.getCustomAttributes();
            for (GluuCustomAttribute gluuCustomAttribute : customAttributes) {
                if (gluuCustomAttribute.getName().equals("gluuIMAPData")) {
                    gluuCustomAttribute.setValue(imapDataService.getJsonStringFromImap(this.imapData));
                }
            }
        }
        GluuCustomPerson person = this.person;
        // TODO: Reffactor
        person.setGluuOptOuts(optOuts.size() == 0 ? null : optOuts);
        boolean runScript = externalUpdateUserService.isEnabled();
        if (runScript) {
            externalUpdateUserService.executeExternalUpdateUserMethods(this.person);
        }
        personService.updatePerson(this.person);
        if (runScript) {
            externalUpdateUserService.executeExternalPostUpdateUserMethods(this.person);
        }
    } catch (BaseMappingException ex) {
        log.error("Failed to update profile {}", person.getInum(), ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update profile '#{userProfileAction.person.displayName}'");
        return OxTrustConstants.RESULT_FAILURE;
    }
    customAttributeAction.savePhotos();
    facesMessages.add(FacesMessage.SEVERITY_INFO, "Profile '#{userProfileAction.person.displayName}' updated successfully");
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 24 with BaseMappingException

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

the class UpdateScopeDescriptionAction method save.

public String save() {
    updateAuthorizationPolicies();
    this.scopeDescription.setDisplayName(this.scopeDescription.getDisplayName().trim());
    if (this.update) {
        // Update scope description
        try {
            scopeDescriptionService.updateScopeDescription(this.scopeDescription);
        } catch (BaseMappingException ex) {
            log.error("Failed to update scope description '{}'", this.scopeDescription.getId(), ex);
            facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}'");
            return OxTrustConstants.RESULT_FAILURE;
        }
        log.debug("Scope description were updated successfully");
        facesMessages.add(FacesMessage.SEVERITY_INFO, "UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' updated successfully");
        return OxTrustConstants.RESULT_SUCCESS;
    } else {
        // Check if scope description with this name already exist
        UmaScopeDescription exampleScopeDescription = new UmaScopeDescription();
        exampleScopeDescription.setDn(scopeDescriptionService.getDnForScopeDescription(null));
        exampleScopeDescription.setId(scopeDescription.getId());
        String inum = scopeDescriptionService.generateInumForNewScopeDescription();
        String scopeDescriptionDn = scopeDescriptionService.getDnForScopeDescription(inum);
        this.scopeDescription.setInum(inum);
        this.scopeDescription.setDn(scopeDescriptionDn);
        this.scopeDescription.setOwner(identity.getUser().getDn());
        this.scopeDescription.setId(scopeDescription.getId());
        // Save scope description
        try {
            scopeDescriptionService.addScopeDescription(this.scopeDescription);
        } catch (BaseMappingException ex) {
            log.error("Failed to add new UMA resource '{}'", this.scopeDescription.getId(), ex);
            facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new UMA resource");
            return OxTrustConstants.RESULT_FAILURE;
        }
        log.debug("Scope description were add successfully");
        facesMessages.add(FacesMessage.SEVERITY_INFO, "New UMA resource '#{updateScopeDescriptionAction.scopeDescription.displayName}' added successfully");
        conversationService.endConversation();
        this.update = true;
        this.scopeInum = inum;
        return OxTrustConstants.RESULT_UPDATE;
    }
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)

Example 25 with BaseMappingException

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

the class UpdateScopeDescriptionAction method searchAvailableAuthorizationPolicies.

public void searchAvailableAuthorizationPolicies() {
    if (this.availableAuthorizationPolicies != null) {
        selectAddedAuthorizationPolicies();
        return;
    }
    try {
        List<CustomScript> availableScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.UMA_RPT_POLICY), CUSTOM_SCRIPT_RETURN_ATTRIBUTES);
        List<SelectableEntity<CustomScript>> tmpAvailableAuthorizationPolicies = new ArrayList<SelectableEntity<CustomScript>>();
        for (CustomScript authorizationPolicy : availableScripts) {
            tmpAvailableAuthorizationPolicies.add(new SelectableEntity<CustomScript>(authorizationPolicy));
        }
        this.availableAuthorizationPolicies = tmpAvailableAuthorizationPolicies;
        selectAddedAuthorizationPolicies();
    } catch (BaseMappingException ex) {
        log.error("Failed to find available authorization policies", ex);
    }
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) CustomScript(org.xdi.model.custom.script.model.CustomScript) SelectableEntity(org.xdi.model.SelectableEntity) ArrayList(java.util.ArrayList)

Aggregations

BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)29 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)5 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)4 Date (java.util.Date)3 OxAuthClient (org.gluu.oxtrust.model.OxAuthClient)3 LdapEntryManager (org.gluu.persist.ldap.impl.LdapEntryManager)3 CustomScript (org.xdi.model.custom.script.model.CustomScript)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)2 ParseException (java.text.ParseException)2 JsonParseException (org.codehaus.jackson.JsonParseException)2 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)2 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)2 GluuStatus (org.gluu.persist.model.base.GluuStatus)2 AppConfiguration (org.xdi.config.oxtrust.AppConfiguration)2 SelectableEntity (org.xdi.model.SelectableEntity)2 UmaScopeDescription (org.xdi.oxauth.model.uma.persistence.UmaScopeDescription)2 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1