Search in sources :

Example 1 with GluuStatus

use of org.xdi.ldap.model.GluuStatus in project oxTrust by GluuFederation.

the class UpdateTrustRelationshipAction method save.

public String save() {
    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:
                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;
                }
                break;
            case FILE:
                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;
                }
                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) {
                    return "unable_download_metadata";
                }
                break;
            case FEDERATION:
                if (!update) {
                    this.trustRelationship.setStatus(GluuStatus.ACTIVE);
                }
                if (this.trustRelationship.getEntityId() == null) {
                    return "invalid_entity_id";
                }
                break;
            default:
                break;
        }
        trustService.updateReleasedAttributes(this.trustRelationship);
        boolean federation = shibboleth3ConfService.isFederation(this.trustRelationship);
        this.trustRelationship.setFederation(federation);
        trustContactsAction.saveContacts();
        if (update) {
            try {
                saveTR(update);
            } catch (LdapMappingException ex) {
                log.error("Failed to update trust relationship {}", ex, inum);
                return OxTrustConstants.RESULT_FAILURE;
            }
        } else {
            String dn = trustService.getDnForTrustRelationShip(this.inum);
            // Save trustRelationship
            this.trustRelationship.setDn(dn);
            try {
                saveTR(update);
            } catch (LdapMappingException ex) {
                log.error("Failed to add new trust relationship {}", ex, this.trustRelationship.getInum());
                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) GluuStatus(org.xdi.ldap.model.GluuStatus) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) CertificateEncodingException(java.security.cert.CertificateEncodingException) IOException(java.io.IOException)

Example 2 with GluuStatus

use of org.xdi.ldap.model.GluuStatus in project oxAuth by GluuFederation.

the class UserService method addUser.

public User addUser(User user, boolean active) {
    String peopleBaseDN = staticConfiguration.getBaseDn().getPeople();
    String inum = inumService.generatePeopleInum();
    user.setDn("inum=" + inum + "," + peopleBaseDN);
    user.setAttribute("inum", inum);
    GluuStatus status = active ? GluuStatus.ACTIVE : GluuStatus.REGISTER;
    user.setAttribute("gluuStatus", status.getValue());
    ldapEntryManager.persist(user);
    return getUserByDn(user.getDn());
}
Also used : GluuStatus(org.xdi.ldap.model.GluuStatus)

Aggregations

GluuStatus (org.xdi.ldap.model.GluuStatus)2 IOException (java.io.IOException)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)1 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)1