Search in sources :

Example 56 with GluuAttribute

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

the class RegistrationManagementAction method search.

public String search() {
    if (Util.equals(this.oldSearchPattern, this.searchPattern)) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    if (this.searchPattern == null || this.searchPattern.length() < 2) {
        return OxTrustConstants.RESULT_VALIDATION_ERROR;
    }
    try {
        this.attributes = attributeService.searchAttributes(this.searchPattern, OxTrustConstants.searchPersonsSizeLimit);
        for (GluuAttribute selectedAttribute : selectedAttributes) {
            if (!attributes.contains(selectedAttribute)) {
                attributes.add(selectedAttribute);
            }
        }
        this.oldSearchPattern = this.searchPattern;
    } catch (Exception ex) {
        log.error("Failed to find attributes", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuAttribute(org.xdi.model.GluuAttribute)

Example 57 with GluuAttribute

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

the class RegistrationManagementAction method init.

public String init() {
    customScriptTypes = new ArrayList<String>();
    customScriptTypes.add(OxTrustConstants.INIT_REGISTRATION_SCRIPT);
    customScriptTypes.add(OxTrustConstants.PRE_REGISTRATION_SCRIPT);
    customScriptTypes.add(OxTrustConstants.POST_REGISTRATION_SCRIPT);
    GluuOrganization org = organizationService.getOrganization();
    RegistrationConfiguration config = org.getOxRegistrationConfiguration();
    List<RegistrationInterceptorScript> newScripts = new ArrayList<RegistrationInterceptorScript>();
    String configLinksExpirationFrequency = null;
    String configAccountsExpirationServiceFrequency = null;
    String configAccountsExpirationPeriod = null;
    if (config != null) {
        List<RegistrationInterceptorScript> scripts = config.getRegistrationInterceptorScripts();
        if (scripts != null && !scripts.isEmpty()) {
            newScripts.addAll(scripts);
        }
        configureInterceptors = config.isRegistrationInterceptorsConfigured();
        captchaDisabled = config.isCaptchaDisabled();
        List<String> attributeList = config.getAdditionalAttributes();
        if (attributeList != null && !attributeList.isEmpty()) {
            configureRegistrationForm = true;
            for (String attributeInum : attributeList) {
                GluuAttribute attribute = attributeService.getAttributeByInum(attributeInum);
                selectedAttributes.add(attribute);
                attributes.add(attribute);
            }
        }
    }
    registrationInterceptors = newScripts;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : RegistrationInterceptorScript(org.gluu.oxtrust.model.RegistrationInterceptorScript) ArrayList(java.util.ArrayList) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuAttribute(org.xdi.model.GluuAttribute)

Example 58 with GluuAttribute

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

the class PersonImportAction method getAttributesForImport.

private List<ImportAttribute> getAttributesForImport(Table table) {
    List<ImportAttribute> importAttributes = new ArrayList<ImportAttribute>();
    if ((table == null) || (table.getCountCols() < 1) || (table.getCountRows() < 1)) {
        return importAttributes;
    }
    int cols = table.getCountCols();
    List<String> addedAttributes = new ArrayList<String>(this.attributes.size());
    for (int i = 0; i <= cols; i++) {
        String cellValue = table.getCellValue(i, 0);
        if (StringHelper.isEmpty(cellValue)) {
            continue;
        }
        String attributeName = cellValue.toLowerCase();
        GluuAttribute attribute = attributesDisplayNameMap.get(attributeName);
        if (attribute != null) {
            addedAttributes.add(attributeName);
            ImportAttribute importAttribute = new ImportAttribute(i, attribute);
            importAttributes.add(importAttribute);
        }
    }
    for (GluuAttribute attribute : this.attributes) {
        if (!addedAttributes.contains(attribute.getName())) {
            ImportAttribute importAttribute = new ImportAttribute(-1, attribute);
            importAttributes.add(importAttribute);
        }
    }
    return importAttributes;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Example 59 with GluuAttribute

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

the class UpdateAttributeAction method validateName.

public boolean validateName(String attributeName) {
    GluuAttribute tmpAttribute = new GluuAttribute();
    tmpAttribute.setBaseDn(attributeService.getDnForAttribute(null));
    tmpAttribute.setName(attributeName);
    if (attributeService.containsAttribute(tmpAttribute)) {
        facesMessages.add("nameId", FacesMessage.SEVERITY_ERROR, "Attribute with specified name already exist");
        return false;
    }
    return true;
}
Also used : GluuAttribute(org.xdi.model.GluuAttribute)

Example 60 with GluuAttribute

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

the class UserExtensionsTest method testCreatePersonFromJsonString.

@Test
@Parameters({ "test.scim2.userext.create_json" })
public void testCreatePersonFromJsonString(final String createJson) throws Exception {
    System.out.println(" testCreatePersonFromJsonString() ");
    // Create custom attributes
    // String, not
    GluuAttribute scimCustomFirst = null;
    // multi-valued
    if (attributeService.getAttributeByName("scimCustomFirst") == null) {
        scimCustomFirst = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomFirst", "Custom First", "First custom attribute", GluuAttributeDataType.STRING, OxMultivalued.FALSE);
    }
    // Date, multi-valued
    GluuAttribute scimCustomSecond = null;
    if (attributeService.getAttributeByName("scimCustomSecond") == null) {
        scimCustomSecond = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomSecond", "Custom Second", "Second custom attribute", GluuAttributeDataType.DATE, OxMultivalued.TRUE);
    }
    // Numeric, not
    GluuAttribute scimCustomThird = null;
    // multi-valued
    if (attributeService.getAttributeByName("scimCustomThird") == null) {
        scimCustomThird = createCustomAttribute(attributeService, schemaService, appConfiguration, "scimCustomThird", "Custom Third", "Third custom attribute", GluuAttributeDataType.NUMERIC, OxMultivalued.FALSE);
    }
    // String CREATEJSON =
    // "{\"schemas\":[\"urn:ietf:params:scim:schemas:core:2.0:User\",\"urn:ietf:params:scim:schemas:extension:gluu:2.0:User\"],\"urn:ietf:params:scim:schemas:extension:gluu:2.0:User\":
    // {\"scimCustomFirst\":\"[1000,2000]\",\"scimCustomSecond\":[\"2016-02-23T15:35:22Z\"],\"scimCustomThird\":3000},\"externalId\":\"scimclient\",\"userName\":\"userjson.add.username\",\"name\":{\"givenName\":\"json\",\"familyName\":\"json\",\"middleName\":\"N/A\",\"honorificPrefix\":\"N/A\",\"honorificSuffix\":\"N/A\"},\"displayName\":\"json
    // json\",\"nickName\":\"json\",\"profileUrl\":\"http://www.gluu.org/\",\"emails\":[{\"value\":\"json@gluu.org\",\"type\":\"work\",\"primary\":\"true\"},{\"value\":\"json2@gluu.org\",\"type\":\"home\",\"primary\":\"false\"}],\"addresses\":[{\"type\":\"work\",\"streetAddress\":\"621
    // East 6th Street Suite
    // 200\",\"locality\":\"Austin\",\"region\":\"TX\",\"postalCode\":\"78701\",\"country\":\"US\",\"formatted\":\"621
    // East 6th Street Suite 200 Austin , TX 78701
    // US\",\"primary\":\"true\"}],\"phoneNumbers\":[{\"value\":\"646-345-2346\",\"type\":\"work\"}],\"ims\":[{\"value\":\"nynytest_user\",\"type\":\"Skype\"}],\"userType\":\"CEO\",\"title\":\"CEO\",\"preferredLanguage\":\"en-us\",\"locale\":\"en_US\",\"active\":\"true\",\"password\":\"secret\",\"roles\":[{\"value\":\"Owner\"}],\"entitlements\":[{\"value\":\"full
    // access\"}],\"x509Certificates\":[{\"value\":\"MIIDQzCCAqygAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwTjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAoMC2V4YW1wbGUuY29tMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0xMTEwMjIwNjI0MzFaFw0xMjEwMDQwNjI0MzFa
    // MH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQKDAtleGFtcGxlLmNvbTEhMB8GA1UEAwwYTXMuIEJhcmJhcmEgSiBKZW5zZW4gSUlJMSIwIAYJKoZIhvcNAQkBFhNiamVuc2VuQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7Kr+Dcds/JQ5GwejJFcBIP682X3xpjis56AK02bc1FLgzdLI8auoR+cC9/Vrh5t66HkQIOdA4unHh0AaZ4xL5PhVbXIPMB5vAPKpzz5iPSi8xO8SL7I7SDhcBVJhqVqr3HgllEG6UClDdHO7nkLuwXq8HcISKkbT5WFTVfFZzidPl8HZ7DhXkZIRtJwBweq4bvm3hM1Os7UQH05ZS6cVDgweKNwdLLrT51ikSQG3DYrl+ft781UQRIqxgwqCfXEuDiinPh0kkvIi5jivVu1Z9QiwlYEdRbLJ4zJQBmDrSGTMYn4lRc2HgHO4DqB/bnMVorHB0CC6AV1QoFK4GPe1LwIDAQABo3sweTAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQU8pD0U0vsZIsaA16lL8En8bx0F/gwHwYDVR0jBBgwFoAUdGeKitcaF7gnzsNwDx708kqaVt0wDQYJKoZIhvcNAQEFBQADgYEAA81SsFnOdYJtNg5Tcq+/ByEDrBgnusx0jloUhByPMEVkoMZ3J7j1ZgI8rAbOkNngX8+pKfTiDz1RC4+dx8oU6Za+4NJXUjlL5CvV6BEYb1+QAEJwitTVvxB/A67g42/vzgAtoRUeDov1+GFiBZ+GNF/cAYKcMtGcrs2i97ZkJMo=\"}],\"meta\":{\"created\":\"2010-01-23T04:56:22Z\",\"lastModified\":\"2011-05-13T04:42:34Z\",\"version\":\"aversion\",\"location\":\"http://localhost:8080/identity/seam/resource/restv1/Users/8c4b6c26-efaf-4840-bddf-c0146a8eb2a9\"}}";
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
    SimpleModule simpleModule = new SimpleModule("SimpleModule", new Version(1, 0, 0, ""));
    simpleModule.addDeserializer(User.class, new UserDeserializer());
    mapper.registerModule(simpleModule);
    User user = mapper.readValue(createJson, User.class);
    String testUserName = user.getUserName() + " (" + System.currentTimeMillis() + ")";
    user.setUserName(testUserName);
    Extension extension = user.getExtension(Constants.USER_EXT_SCHEMA_ID);
    assertNotNull(extension, "(Deserialization) Custom extension not deserialized.");
    Extension.Field customFirstField = extension.getFields().get("scimCustomFirst");
    assertNotNull(customFirstField, "(Deserialization) \"scimCustomFirst\" field not deserialized.");
    assertEquals(customFirstField.getValue(), "[1000,2000]");
    System.out.println("##### (Deserialization) customFirstField.getValue() = " + customFirstField.getValue());
    Extension.Field customSecondField = extension.getFields().get("scimCustomSecond");
    assertNotNull(customSecondField, "(Deserialization) \"scimCustomSecond\" field not deserialized.");
    List<Date> dateList = Arrays.asList(mapper.readValue(customSecondField.getValue(), Date[].class));
    assertEquals(dateList.size(), 1);
    System.out.println("##### (Deserialization) dateList.get(0) = " + dateList.get(0));
    Extension.Field customThirdField = extension.getFields().get("scimCustomThird");
    assertNotNull(customThirdField, "(Deserialization) \"scimCustomThird\" field not deserialized.");
    assertEquals(new BigDecimal(customThirdField.getValue()), new BigDecimal(3000));
    System.out.println("##### (Deserialization) customThirdField.getValue() = " + customThirdField.getValue());
    // Create Person
    GluuCustomPerson gluuPerson = copyUtils2.copy(user, null, false);
    assertNotNull(gluuPerson, "gluuPerson is null!");
    System.out.println(">>>>> gluuPerson.getUid() = " + gluuPerson.getUid());
    String inum = personService.generateInumForNewPerson();
    String dn = personService.getDnForPerson(inum);
    String iname = personService.generateInameForNewPerson(user.getUserName());
    gluuPerson.setDn(dn);
    gluuPerson.setInum(inum);
    gluuPerson.setIname(iname);
    gluuPerson.setCommonName(gluuPerson.getGivenName() + " " + gluuPerson.getSurname());
    personService.addPerson(gluuPerson);
    // Retrieve Person
    GluuCustomPerson retrievedPerson = personService.getPersonByUid(gluuPerson.getUid());
    assertNotNull(retrievedPerson, "Failed to find person.");
    User newPerson = copyUtils2.copy(retrievedPerson, null);
    extension = newPerson.getExtension(Constants.USER_EXT_SCHEMA_ID);
    assertNotNull(extension, "(Persistence) Custom extension not persisted.");
    customFirstField = extension.getFields().get("scimCustomFirst");
    assertNotNull(customFirstField, "(Persistence) \"scimCustomFirst\" field not persisted.");
    assertEquals(customFirstField.getValue(), "[1000,2000]");
    System.out.println("##### (Persistence) customFirstField.getValue() = " + customFirstField.getValue());
    customSecondField = extension.getFields().get("scimCustomSecond");
    assertNotNull(customSecondField, "(Persistence) \"scimCustomSecond\" field not persisted.");
    dateList = Arrays.asList(mapper.readValue(customSecondField.getValue(), Date[].class));
    assertEquals(dateList.size(), 1);
    System.out.println("##### (Persistence) dateList.get(0) = " + dateList.get(0));
    customThirdField = extension.getFields().get("scimCustomThird");
    assertNotNull(customThirdField, "(Persistence) \"scimCustomThird\" field not persisted.");
    assertEquals(new BigDecimal(customThirdField.getValue()), new BigDecimal(3000));
    System.out.println("##### (Persistence) customThirdField.getValue() = " + customThirdField.getValue());
    // Remove Person
    memberService.removePerson(retrievedPerson);
// Remove custom attributes
// schemaService.removeAttributeTypeFromObjectClass(scimCustomFirst.getOrigin(),
// scimCustomFirst.getName());
// schemaService.removeStringAttribute(scimCustomFirst.getName());
// attributeService.removeAttribute(scimCustomFirst);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomSecond.getOrigin(),
// scimCustomSecond.getName());
// schemaService.removeStringAttribute(scimCustomSecond.getName());
// attributeService.removeAttribute(scimCustomSecond);
// schemaService.removeAttributeTypeFromObjectClass(scimCustomThird.getOrigin(),
// scimCustomThird.getName());
// schemaService.removeStringAttribute(scimCustomThird.getName());
// attributeService.removeAttribute(scimCustomThird);
}
Also used : UserDeserializer(org.gluu.oxtrust.service.scim2.jackson.custom.UserDeserializer) User(org.gluu.oxtrust.model.scim2.User) Date(java.util.Date) BigDecimal(java.math.BigDecimal) GluuAttribute(org.xdi.model.GluuAttribute) Extension(org.gluu.oxtrust.model.scim2.Extension) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Version(org.codehaus.jackson.Version) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) SimpleModule(org.codehaus.jackson.map.module.SimpleModule) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(org.gluu.oxtrust.action.test.BaseTest)

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