Search in sources :

Example 21 with GluuCustomAttribute

use of org.gluu.oxtrust.model.GluuCustomAttribute 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 22 with GluuCustomAttribute

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

the class PersonService method getMandatoryAtributes.

/* (non-Javadoc)
	 * @see org.gluu.oxtrust.ldap.service.IPersonService#getMandatoryAtributes()
	 */
@Override
public List<GluuCustomAttribute> getMandatoryAtributes() {
    if (this.mandatoryAttributes == null) {
        mandatoryAttributes = new ArrayList<GluuCustomAttribute>();
        mandatoryAttributes.add(new GluuCustomAttribute("uid", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("givenName", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("displayName", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("sn", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("mail", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("userPassword", "", true, true));
        mandatoryAttributes.add(new GluuCustomAttribute("gluuStatus", "", true, true));
    }
    return mandatoryAttributes;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute)

Example 23 with GluuCustomAttribute

use of org.gluu.oxtrust.model.GluuCustomAttribute 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)

Example 24 with GluuCustomAttribute

use of org.gluu.oxtrust.model.GluuCustomAttribute 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);
        personService.updatePerson(person);
    } catch (LdapMappingException ex) {
        log.error("Failed to update profile {}", ex, person.getInum());
        return OxTrustConstants.RESULT_FAILURE;
    }
    customAttributeAction.savePhotos();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 25 with GluuCustomAttribute

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

the class WhitePagesAction method getReleasedAttributes.

public List<GluuCustomAttribute> getReleasedAttributes(GluuCustomPerson person) {
    if (person == null) {
        return Arrays.asList(new GluuCustomAttribute[0]);
    }
    List<GluuCustomAttribute> releasedAttributes = new ArrayList<GluuCustomAttribute>();
    for (GluuCustomAttribute attribute : person.getCustomAttributes()) {
        List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.USER);
        GluuAttribute metadata = attributeService.getAttributeByName(attribute.getName(), attributes);
        if (metadata != null && metadata.isWhitePagesCanView() && !tableAttributes.contains(attribute.getName())) {
            attribute.setMetadata(metadata);
            releasedAttributes.add(attribute);
        }
    }
    return releasedAttributes;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Aggregations

GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)42 ArrayList (java.util.ArrayList)19 GluuAttribute (org.xdi.model.GluuAttribute)15 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)12 ScimPersonEmails (org.gluu.oxtrust.model.scim.ScimPersonEmails)5 HashSet (java.util.HashSet)4 ConfigurableTest (org.gluu.oxtrust.action.test.ConfigurableTest)4 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)4 PersonMeta (org.gluu.oxtrust.model.scim.PersonMeta)4 ScimCustomAttributes (org.gluu.oxtrust.model.scim.ScimCustomAttributes)4 ScimName (org.gluu.oxtrust.model.scim.ScimName)4 ScimPerson (org.gluu.oxtrust.model.scim.ScimPerson)4 ScimPersonAddresses (org.gluu.oxtrust.model.scim.ScimPersonAddresses)4 ScimPersonGroups (org.gluu.oxtrust.model.scim.ScimPersonGroups)4 ScimPersonIms (org.gluu.oxtrust.model.scim.ScimPersonIms)4 ScimPersonPhones (org.gluu.oxtrust.model.scim.ScimPersonPhones)4 ScimPersonPhotos (org.gluu.oxtrust.model.scim.ScimPersonPhotos)4 ScimRoles (org.gluu.oxtrust.model.scim.ScimRoles)4 Scimx509Certificates (org.gluu.oxtrust.model.scim.Scimx509Certificates)4 IOException (java.io.IOException)3