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);
}
}
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 = "";
}
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;
}
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();
}
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;
}
Aggregations