Search in sources :

Example 46 with GluuSAMLTrustRelationship

use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.

the class UpdateTrustRelationshipAction method initFederatedSites.

private void initFederatedSites(GluuSAMLTrustRelationship trustRelationship) {
    List<GluuAttribute> attributes = getAllAttributes();
    this.federatedSites = new ArrayList<GluuSAMLTrustRelationship>();
    for (GluuSAMLTrustRelationship deconstructedTrustRelationship : trustService.getDeconstructedTrustRelationships(trustRelationship)) {
        initTrustRelationship(deconstructedTrustRelationship, attributes);
        this.federatedSites.add(deconstructedTrustRelationship);
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) GluuAttribute(org.gluu.model.GluuAttribute)

Example 47 with GluuSAMLTrustRelationship

use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method initAttributes.

/*
     * Init attributes
     */
private void initAttributes(List<GluuSAMLTrustRelationship> trustRelationships) {
    List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
    HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
    GluuAttribute uid = attributeService.getAttributeByName(OxConstants.UID);
    // Load attributes definition
    for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
        // Add first attribute uid
        List<String> oldAttributes = trustRelationship.getReleasedAttributes();
        List<String> releasedAttributes = new ArrayList<String>();
        if (oldAttributes != null) {
            releasedAttributes.addAll(oldAttributes);
        }
        if (uid != null) {
            if (releasedAttributes.remove(uid.getDn())) {
                releasedAttributes.add(0, uid.getDn());
            }
        }
        // Resolve custom attributes by DNs
        trustRelationship.setReleasedCustomAttributes(attributeService.getCustomAttributesByAttributeDNs(releasedAttributes, attributesByDNs));
        // Set attribute meta-data
        attributeService.setAttributeMetadata(trustRelationship.getReleasedCustomAttributes(), attributes);
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Example 48 with GluuSAMLTrustRelationship

use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.

the class TrustService method getAllActiveTrustRelationships.

public List<GluuSAMLTrustRelationship> getAllActiveTrustRelationships() {
    GluuSAMLTrustRelationship trustRelationship = new GluuSAMLTrustRelationship();
    trustRelationship.setBaseDn(getDnForTrustRelationShip(null));
    trustRelationship.setStatus(GluuStatus.ACTIVE);
    return persistenceEntryManager.findEntries(trustRelationship);
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship)

Example 49 with GluuSAMLTrustRelationship

use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.

the class TrustService method removeAttribute.

/**
 * Remove attribute
 *
 * @param attribute
 *            Attribute
 */
public boolean removeAttribute(GluuAttribute attribute) {
    log.trace("Removing attribute from trustRelationships");
    List<GluuSAMLTrustRelationship> trustRelationships = getAllTrustRelationships();
    log.trace(String.format("Iterating '%d' trustRelationships", trustRelationships.size()));
    for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
        log.trace("Analyzing '%s'.", trustRelationship.getDisplayName());
        List<String> customAttrs = trustRelationship.getReleasedAttributes();
        if (customAttrs != null) {
            for (String attrDN : customAttrs) {
                log.trace("'%s' has custom attribute '%s'", trustRelationship.getDisplayName(), attrDN);
                if (attrDN.equals(attribute.getDn())) {
                    log.trace("'%s' matches '%s'.  deleting it.", attrDN, attribute.getDn());
                    List<String> updatedAttrs = new ArrayList<String>();
                    updatedAttrs.addAll(customAttrs);
                    updatedAttrs.remove(attrDN);
                    if (updatedAttrs.size() == 0) {
                        trustRelationship.setReleasedAttributes(null);
                    } else {
                        trustRelationship.setReleasedAttributes(updatedAttrs);
                    }
                    updateTrustRelationship(trustRelationship);
                    break;
                }
            }
        }
    }
    attributeService.removeAttribute(attribute);
    return true;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) ArrayList(java.util.ArrayList)

Example 50 with GluuSAMLTrustRelationship

use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method generateSpAttributeMapFile.

public String generateSpAttributeMapFile(GluuSAMLTrustRelationship trustRelationship) {
    List<GluuSAMLTrustRelationship> trustRelationships = Arrays.asList(trustRelationship);
    initAttributes(trustRelationships);
    HashMap<String, Object> attrParams = initAttributeParamMap(trustRelationships);
    if (attrParams == null) {
        return null;
    }
    VelocityContext context = prepareVelocityContext(null, attrParams, null, null, null);
    String spAttributeMap = generateConfFile(SHIB3_SP_ATTRIBUTE_MAP_FILE, context);
    return spAttributeMap;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) VelocityContext(org.apache.velocity.VelocityContext)

Aggregations

GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)51 ArrayList (java.util.ArrayList)17 IOException (java.io.IOException)15 CertificateEncodingException (java.security.cert.CertificateEncodingException)11 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)10 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)6 List (java.util.List)6 File (java.io.File)5 HashSet (java.util.HashSet)5 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)4 VelocityContext (org.apache.velocity.VelocityContext)4 SubversionFile (org.gluu.oxtrust.model.SubversionFile)4 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 TreeSet (java.util.TreeSet)3 GluuAttribute (org.gluu.model.GluuAttribute)3