Search in sources :

Example 11 with GluuAttribute

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

the class ScopeWebResourceTest method getScopeClaimsTest.

@Test
public void getScopeClaimsTest() {
    String inum = "C17A";
    HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.SCOPES + "/" + inum + ApiConstants.CLAIMS);
    HttpResponse response = handle(request);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    try {
        GluuAttribute[] claims = mapper.readValue(EntityUtils.toString(entity), GluuAttribute[].class);
        Assert.assertNotNull(claims);
        Assert.assertTrue(claims.length > 1);
    } catch (ParseException | IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) GluuAttribute(org.gluu.model.GluuAttribute) Test(org.junit.Test)

Example 12 with GluuAttribute

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

the class UpdateClientAction method acceptSelectClaims.

public void acceptSelectClaims() {
    if (this.availableClaims == null) {
        return;
    }
    Set<String> addedClaimInums = new HashSet<String>();
    for (DisplayNameEntry claim : claims) {
        addedClaimInums.add(claim.getInum());
    }
    for (GluuAttribute aClaim : this.availableClaims) {
        if (aClaim.isSelected() && !addedClaimInums.contains(aClaim.getInum())) {
            addClaim(aClaim);
        }
    }
    this.searchAvailableClaimPattern = "";
}
Also used : DisplayNameEntry(org.gluu.model.DisplayNameEntry) HashSet(java.util.HashSet) GluuAttribute(org.gluu.model.GluuAttribute)

Example 13 with GluuAttribute

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

the class PersonImportAction method convertTableToPersons.

protected List<GluuCustomPerson> convertTableToPersons(Table table, List<ImportAttribute> importAttributes) throws Exception {
    Map<String, List<AttributeData>> entriesAttributes = new HashMap<String, List<AttributeData>>();
    Map<String, String> uidPAsswords = new HashMap<String, String>();
    int rows = table.getCountRows();
    boolean validTable = true;
    for (int i = 1; i <= rows; i++) {
        List<AttributeData> attributeDataList = new ArrayList<AttributeData>();
        String uid = null;
        String password = null;
        for (ImportAttribute importAttribute : importAttributes) {
            if (importAttribute.getCol() == -1) {
                continue;
            }
            GluuAttribute attribute = importAttribute.getAttribute();
            String cellValue = table.getCellValue(importAttribute.getCol(), i);
            boolean isMultiValue = attribute.getOxMultiValuedAttribute();
            if (StringHelper.isEmpty(cellValue)) {
                if (attribute.isRequred()) {
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "Import failed. Empty '%s' not allowed", attribute.getDisplayName());
                    validTable = false;
                }
                continue;
            }
            String ldapValue = getTypedValue(attribute, cellValue);
            if (StringHelper.isEmpty(ldapValue)) {
                facesMessages.add(FacesMessage.SEVERITY_ERROR, "Invalid value '%s' in column '%s' at row %s were specified", cellValue, attribute.getDisplayName(), i + 1);
                validTable = false;
                continue;
            }
            if (attribute.getName().equalsIgnoreCase(UID)) {
                uid = ldapValue;
            }
            if (attribute.getName().equalsIgnoreCase(USER_PASSWORD)) {
                password = ldapValue;
            }
            if (isMultiValue) {
                AttributeData attributeData = new AttributeData(attribute.getName(), ldapValue.split(SEPARATOR));
                attributeDataList.add(attributeData);
            } else {
                AttributeData attributeData = new AttributeData(attribute.getName(), ldapValue);
                attributeDataList.add(attributeData);
            }
        }
        entriesAttributes.put(Integer.toString(i), attributeDataList);
        uidPAsswords.put(uid, password);
    }
    if (!validTable) {
        return null;
    }
    List<GluuCustomPerson> persons = personService.createEntities(entriesAttributes);
    log.trace("Found {} persons in input Excel file", persons.size());
    for (GluuCustomPerson person : persons) {
        if (person.getStatus() == null) {
            person.setStatus(appConfiguration.getSupportedUserStatus().get(1));
        }
        if (uidPAsswords.containsKey(person.getUid())) {
            String password = uidPAsswords.get(person.getUid());
            if (password != null) {
                person.setUserPassword(uidPAsswords.get(person.getUid().trim().toString()));
            } else {
                person.setUserPassword(person.getUid());
            }
        }
    }
    return persons;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ArrayList(java.util.ArrayList) List(java.util.List) AttributeData(org.gluu.persist.model.AttributeData)

Example 14 with GluuAttribute

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

the class PersonImportAction method getAttributesString.

private String getAttributesString(List<GluuAttribute> attributes) {
    StringBuilder sb = new StringBuilder();
    for (Iterator<GluuAttribute> iterator = attributes.iterator(); iterator.hasNext(); ) {
        GluuAttribute attribute = iterator.next();
        sb.append('\'').append(attribute.getDisplayName()).append('\'');
        if (!attribute.isRequred()) {
            sb.append(" (non mandatory)");
        }
        if (iterator.hasNext()) {
            sb.append(", ");
        }
    }
    return sb.toString();
}
Also used : GluuAttribute(org.gluu.model.GluuAttribute)

Example 15 with GluuAttribute

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

the class RegistrationManagementAction method lookupAttributeData.

public String lookupAttributeData() {
    GluuAttribute attribute = attributeService.getAttributeByName(attributeName);
    attributeData = "Uid:\t" + attributeName;
    attributeData += "<br/>Description:\t" + attribute.getDescription();
    attributeData += "<br/>Origin:\t" + attribute.getOrigin();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuAttribute(org.gluu.model.GluuAttribute)

Aggregations

GluuAttribute (org.gluu.model.GluuAttribute)68 ArrayList (java.util.ArrayList)21 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)10 IOException (java.io.IOException)8 Scope (org.oxauth.persistence.model.Scope)8 HttpEntity (org.apache.http.HttpEntity)7 HttpResponse (org.apache.http.HttpResponse)7 ParseException (org.apache.http.ParseException)7 Test (org.junit.Test)7 HttpGet (org.apache.http.client.methods.HttpGet)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 Filter (org.gluu.search.filter.Filter)5 JSONObject (org.json.JSONObject)4 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 FacesMessage (javax.faces.application.FacesMessage)3 UIInput (javax.faces.component.UIInput)3 AttributeValidation (org.gluu.model.attribute.AttributeValidation)3