Search in sources :

Example 6 with BaseMappingException

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

the class UpdateTrustRelationshipAction method markAsInactive.

private void markAsInactive() {
    // files in meta-data folder
    if (update) {
        try {
            GluuSAMLTrustRelationship tmpTrustRelationship = trustService.getRelationshipByInum(this.trustRelationship.getInum());
            tmpTrustRelationship.setStatus(GluuStatus.INACTIVE);
            saveTR(update);
        } catch (BaseMappingException ex) {
            log.error("Failed to update trust relationship {}", inum, ex);
        }
    } else {
        // Remove file name to generate new one during new save attempt.
        // Cover case when somebody else added new one simultaneously
        this.trustRelationship.setSpMetaDataFN(null);
        this.trustRelationship.setInum(null);
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 7 with BaseMappingException

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

the class UpdateTrustRelationshipAction method delete.

public String delete() {
    String result = OxTrustConstants.RESULT_FAILURE;
    if (update) {
        // Remove trust relationship
        try {
            synchronized (svnSyncTimer) {
                for (GluuSAMLTrustRelationship trust : trustService.getDeconstructedTrustRelationships(this.trustRelationship)) {
                    if (GluuStatus.ACTIVE.equals(trust.getStatus())) {
                        log.error("Failed to remove federation trust relationship {}, there are still active federated Trust Relationships left.", this.trustRelationship.getInum());
                        return result;
                    }
                }
                for (GluuSAMLTrustRelationship trust : trustService.getDeconstructedTrustRelationships(this.trustRelationship)) {
                    trustService.removeTrustRelationship(trust);
                    svnSyncTimer.removeTrustRelationship(trust, identity.getCredentials().getUsername());
                }
                shibboleth3ConfService.removeSpMetadataFile(this.trustRelationship.getSpMetaDataFN());
                trustService.removeTrustRelationship(this.trustRelationship);
                svnSyncTimer.removeTrustRelationship(this.trustRelationship, identity.getCredentials().getUsername());
            }
            result = OxTrustConstants.RESULT_SUCCESS;
        } catch (BaseMappingException ex) {
            result = OxTrustConstants.RESULT_FAILURE;
            log.error("Failed to remove trust relationship {}", this.trustRelationship.getInum(), ex);
        } catch (InterruptedException e) {
            log.error("Failed to add trust relationship to remove queue. It will be removed during next application restart", e);
        } finally {
            List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
            updateShibboleth3Configuration(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) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 8 with BaseMappingException

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

the class ScopeDescriptionDownloadAction method getScopeDescription.

private UmaScopeDescription getScopeDescription() {
    try {
        scopeDescriptionService.prepareScopeDescriptionBranch();
    } catch (Exception ex) {
        log.error("Failed to initialize download action", ex);
        return null;
    }
    log.debug("Loading UMA scope description '{}'", this.scopeId);
    UmaScopeDescription scopeDescription;
    try {
        List<UmaScopeDescription> scopeDescriptions = scopeDescriptionService.findScopeDescriptionsById(this.scopeId);
        if (scopeDescriptions.size() != 1) {
            log.error("Failed to find scope description '{}'. Found: '{}'", this.scopeId, scopeDescriptions.size());
            return null;
        }
        scopeDescription = scopeDescriptions.get(0);
    } catch (BaseMappingException ex) {
        log.error("Failed to find scope description '{}'", this.scopeId, ex);
        return null;
    }
    return scopeDescription;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) UmaScopeDescription(org.xdi.oxauth.model.uma.persistence.UmaScopeDescription) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException)

Example 9 with BaseMappingException

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

the class UpdateResourceAction method update.

private String update() {
    log.debug("Loading UMA resource set '{}'", this.oxId);
    try {
        String resourceDn = umaResourcesService.getDnForResource(this.oxId);
        this.resource = umaResourcesService.getResourceByDn(resourceDn);
    } catch (BaseMappingException ex) {
        log.error("Failed to find resource set '{}'", this.oxId, ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    if (this.resource == null) {
        log.error("Resource set is null");
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.scopes = getScopesDisplayNameEntries();
    this.clients = getClientDisplayNameEntries();
    List<String> list = this.resource.getClients();
    if (list != null) {
        clientList = new ArrayList<OxAuthClient>();
        for (String clientDn : list) {
            OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
            clientList.add(oxAuthClient);
        }
    }
    if (this.resource.getResources() == null) {
        this.resources = new ArrayList<String>();
    } else {
        this.resources = new ArrayList<String>(this.resource.getResources());
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 10 with BaseMappingException

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

the class UpdateScopeDescriptionAction method update.

private String update() {
    if (this.scopeDescription != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    log.debug("Loading UMA resource '{}'", this.scopeInum);
    try {
        String scopeDn = scopeDescriptionService.getDnForScopeDescription(this.scopeInum);
        this.scopeDescription = scopeDescriptionService.getScopeDescriptionByDn(scopeDn);
        this.authorizationPolicies = getInitialAuthorizationPolicies();
        List<UmaResource> umaResourceList = resourceSetService.findResourcesByScope(scopeDn);
        if (umaResourceList != null) {
            for (UmaResource umaResource : umaResourceList) {
                List<String> list = umaResource.getClients();
                if (list != null) {
                    clientList = new ArrayList<OxAuthClient>();
                    for (String clientDn : list) {
                        OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
                        clientList.add(oxAuthClient);
                    }
                }
            }
        }
    } catch (BaseMappingException ex) {
        log.error("Failed to find scope description '{}'", this.scopeInum, ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    if (this.scopeDescription == null) {
        log.error("Scope description is null");
        return OxTrustConstants.RESULT_FAILURE;
    }
    initIconImage();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) UmaResource(org.xdi.oxauth.model.uma.persistence.UmaResource)

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