Search in sources :

Example 41 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getAllPersonAtributesImpl.

/**
	 * Get all organization attributes
	 * 
	 * @param attributes
	 *            List of attributes
	 * @return List of organization attributes
	 */
private List<GluuAttribute> getAllPersonAtributesImpl(GluuUserRole gluuUserRole, Collection<GluuAttribute> attributes) {
    List<GluuAttribute> returnAttributeList = new ArrayList<GluuAttribute>();
    String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
    log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
    for (GluuAttribute attribute : attributes) {
        if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
            attribute.setCustom(true);
            returnAttributeList.add(attribute);
            continue;
        }
        for (String objectClassType : objectClassTypes) {
            if (attribute.getOrigin().equals(objectClassType) && ((attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole)))) {
                returnAttributeList.add(attribute);
                break;
            }
        }
    }
    return returnAttributeList;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Example 42 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getAllAttributeOrigins.

/**
	 * Get all origins
	 * 
	 * @param attributes
	 *            List of attributes
	 * @return List of origins
	 */
public List<String> getAllAttributeOrigins(Collection<GluuAttribute> attributes) {
    List<String> attributeOriginList = new ArrayList<String>();
    for (GluuAttribute attribute : attributes) {
        String origin = attribute.getOrigin();
        if (!attributeOriginList.contains(origin)) {
            attributeOriginList.add(attribute.getOrigin());
        }
    }
    String customOrigin = getCustomOrigin();
    if (!attributeOriginList.contains(customOrigin)) {
        attributeOriginList.add(customOrigin);
    }
    return attributeOriginList;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Example 43 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method addGluuSP.

/**
	 * Adds Trust relationship for own shibboleth SP and restarts services after
	 * done.
	 * 
	 * @author �Oleksiy Tataryn�
	 */
public void addGluuSP() {
    String gluuSPInum = trustService.generateInumForNewTrustRelationship();
    String metadataFN = getSpNewMetadataFileName(gluuSPInum);
    GluuSAMLTrustRelationship gluuSP = new GluuSAMLTrustRelationship();
    gluuSP.setInum(gluuSPInum);
    gluuSP.setDisplayName("gluu SP on appliance");
    gluuSP.setDescription("Trust Relationship for the SP");
    gluuSP.setSpMetaDataSourceType(GluuMetadataSourceType.FILE);
    gluuSP.setSpMetaDataFN(metadataFN);
    //TODO: 
    gluuSP.setEntityId(StringHelper.removePunctuation(gluuSP.getInum()));
    gluuSP.setUrl(appConfiguration.getApplianceUrl());
    String certificate = "";
    boolean result = false;
    try {
        certificate = FileUtils.readFileToString(new File(appConfiguration.getGluuSpCert())).replaceAll("-{5}.*?-{5}", "");
        generateSpMetadataFile(gluuSP, certificate);
        result = isCorrectSpMetadataFile(gluuSP.getSpMetaDataFN());
    } catch (IOException e) {
        log.error("Failed to gluu SP read certificate file.", e);
    }
    GluuAppliance appliance = null;
    if (result) {
        gluuSP.setStatus(GluuStatus.ACTIVE);
        String inum = gluuSP.getInum();
        String dn = trustService.getDnForTrustRelationShip(inum);
        gluuSP.setDn(dn);
        List<GluuCustomAttribute> customAttributes = new ArrayList<GluuCustomAttribute>();
        List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
        HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
        List<String> customAttributeDNs = new ArrayList<String>();
        List<String> attributeNames = new ArrayList<String>();
        for (String attributeName : appConfiguration.getGluuSpAttributes()) {
            GluuAttribute attribute = attributeService.getAttributeByName(attributeName, attributes);
            if (attribute != null) {
                customAttributeDNs.add(attribute.getDn());
            }
        }
        customAttributes.addAll(attributeService.getCustomAttributesByAttributeDNs(customAttributeDNs, attributesByDNs));
        gluuSP.setReleasedCustomAttributes(customAttributes);
        gluuSP.setReleasedAttributes(attributeNames);
        trustService.updateReleasedAttributes(gluuSP);
        trustService.addTrustRelationship(gluuSP);
        appliance = applianceService.getAppliance();
        appliance.setGluuSPTR(gluuSP.getInum());
    }
    if (result) {
        applianceService.updateAppliance(appliance);
        log.warn("gluuSP EntityID set to " + StringHelper.removePunctuation(gluuSP.getInum()) + ". Shibboleth3 configuration should be updated.");
    // applianceService.restartServices();
    } else {
        log.error("IDP configuration update failed. GluuSP was not generated.");
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ArrayList(java.util.ArrayList) IOException(java.io.IOException) GluuAttribute(org.xdi.model.GluuAttribute) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) SubversionFile(org.gluu.oxtrust.model.SubversionFile) File(java.io.File)

Example 44 with GluuAttribute

use of org.xdi.model.GluuAttribute 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(OxTrustConstants.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.xdi.model.GluuAttribute)

Example 45 with GluuAttribute

use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.

the class UserProfileAction method getPhotoThumbData.

public byte[] getPhotoThumbData() {
    List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.USER);
    GluuAttribute photoAttribute = attributeService.getAttributeByName("photo1", attributes);
    GluuCustomAttribute customAttribute = new GluuCustomAttribute("photo1", this.person.getAttribute("photo1"));
    customAttribute.setMetadata(photoAttribute);
    GluuImage image = imageService.getImage(customAttribute);
    if (image == null) {
        return imageService.getBlankPhotoData();
    }
    return imageService.getThumImageData(image);
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuImage(org.xdi.model.GluuImage) GluuAttribute(org.xdi.model.GluuAttribute)

Aggregations

GluuAttribute (org.xdi.model.GluuAttribute)64 ArrayList (java.util.ArrayList)24 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)15 JSONObject (org.codehaus.jettison.json.JSONObject)9 JSONArray (org.codehaus.jettison.json.JSONArray)8 GluuAttributeDataType (org.xdi.model.GluuAttributeDataType)6 IOException (java.io.IOException)5 BigDecimal (java.math.BigDecimal)5 Date (java.util.Date)5 HashMap (java.util.HashMap)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 Extension (org.gluu.oxtrust.model.scim2.Extension)5 JwtSubClaimObject (org.xdi.oxauth.model.jwt.JwtSubClaimObject)5 Filter (com.unboundid.ldap.sdk.Filter)4 List (java.util.List)4 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)4 Claim (org.xdi.oxauth.model.authorize.Claim)4 Scope (org.xdi.oxauth.model.common.Scope)4 PairwiseIdentifier (org.xdi.oxauth.model.ldap.PairwiseIdentifier)4 DynamicScopeExternalContext (org.xdi.oxauth.service.external.context.DynamicScopeExternalContext)4