public static void addAttrTOsToContext(final Collection<AttrTO> attrs, final JexlContext jexlContext) { attrs.stream().filter(attr -> attr.getSchema() != null).forEach(attr -> { String expressionValue = attr.getValues().isEmpty() ? StringUtils.EMPTY : attr.getValues().get(0); LOG.debug("Add attribute {} with value {}", attr.getSchema(), expressionValue); jexlContext.set(attr.getSchema(), expressionValue); }); }
private AttrTO evaluateAttr(final AttrTO template, final MapContext jexlContext) { AttrTO result = new AttrTO(); result.setSchema(template.getSchema()); if (template.getValues() != null && !template.getValues().isEmpty()) { template.getValues().forEach(value -> { String evaluated = JexlUtils.evaluate(value, jexlContext); if (StringUtils.isNotBlank(evaluated)) { result.getValues().add(evaluated); } }); } return result; }
/** * Builds {@link ConnObjectTO} out of a collection of {@link Attribute} instances. * * @param attrs attributes * @return transfer object */ public static ConnObjectTO getConnObjectTO(final Set<Attribute> attrs) { final ConnObjectTO connObjectTO = new ConnObjectTO(); if (attrs != null) { connObjectTO.getAttrs().addAll(attrs.stream().map(attr -> { AttrTO attrTO = new AttrTO(); attrTO.setSchema(attr.getName()); if (attr.getValue() != null) { attr.getValue().stream().filter(value -> value != null).forEachOrdered(value -> { if (value instanceof GuardedString || value instanceof GuardedByteArray) { attrTO.getValues().add(getPassword(value)); } else if (value instanceof byte[]) { attrTO.getValues().add(Base64.getEncoder().encodeToString((byte[]) value)); } else if (value != null) { attrTO.getValues().add(value.toString()); } }); } return attrTO; }).collect(Collectors.toList())); } return connObjectTO; }
@JsonIgnore @Override public Optional<AttrTO> getDerAttr(final String schema) { return derAttrs.stream().filter(attr -> attr.getSchema().equals(schema)).findFirst(); }
String groupName = membership.getGroupName(); membership.getPlainAttrs().stream().map(attr -> { attr.setSchema(groupName.concat(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR). concat(attr.getSchema())); return attr; }).forEachOrdered(attr -> { membership.getPlainAttrs().clear(); membership.getDerAttrs().stream().map(attr -> { attr.setSchema(groupName.concat(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR). concat(attr.getSchema())); return attr; }).forEachOrdered(attr -> { membership.getDerAttrs().clear(); membership.getVirAttrs().stream().map((attr) -> { attr.setSchema(groupName.concat(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR). concat(attr.getSchema())); return attr; }).forEachOrdered(attr -> {
@PreAuthorize("hasRole('" + StandardEntitlement.CONFIGURATION_GET + "')") @Transactional(readOnly = true) public AttrTO get(final String schema) { AttrTO result; Optional<? extends CPlainAttr> conf = confDAO.find(schema); if (conf.isPresent()) { result = binder.getAttrTO(conf.get()); } else { PlainSchema plainSchema = plainSchemaDAO.find(schema); if (plainSchema == null) { throw new NotFoundException("Configuration schema " + schema); } result = new AttrTO(); result.setSchema(schema); } return result; }
public Builder schema(final String schema) { instance.setSchema(schema); return this; }
AttrTO attrTO = new AttrTO(); attrTO.setSchema(StringUtils.EMPTY); if (values.isEmpty() || values.get(0) == null) { attrTO.getValues().add(StringUtils.EMPTY); } else { attrTO.getValues().add(values.get(0).toString()); AttrTO attrTO = new AttrTO(); attrTO.setSchema(intAttrName.getSchemaName()); if (value != null) { if (schemaType == AttrSchemaType.Binary) { attrTO.getValues().add(Base64.getEncoder().encodeToString((byte[]) value)); } else { attrTO.getValues().add(value.toString()); attrTO = new AttrTO(); attrTO.setSchema(intAttrName.getSchemaName()); attrTO = new AttrTO(); attrTO.setSchema(intAttrName.getSchemaName()); attr.getValue().stream(). filter(value -> value != null). forEachOrdered(value -> attrTO.getValues().add(value.toString()));
public Builder value(final String value) { instance.getValues().add(value); return this; }
@JsonIgnore @Override public Optional<AttrTO> getVirAttr(final String schema) { return virAttrs.stream().filter(attr -> attr.getSchema().equals(schema)).findFirst(); }
filter(attr -> (attr.getSchema(). contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered(attr -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream(). clone.setSchema(simpleAttrs[1]); membership.getPlainAttrs().add(clone); membAttrs.add(attr); filter(attr -> (attr.getSchema(). contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered(attr -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream(). clone.setSchema(simpleAttrs[1]); membership.getDerAttrs().add(clone); membAttrs.add(attr); filter(attr -> (attr.getSchema(). contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered(attr -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream().
private static boolean validateAttributes(final Map<String, AttrTO> attrMap, final CustomAttributesInfo customAttrInfo, final boolean checkDefaultValues) { return customAttrInfo == null || customAttrInfo.getAttributes().isEmpty() || attrMap.entrySet().stream().allMatch(entry -> { String schemaKey = entry.getKey(); AttrTO attrTO = entry.getValue(); CustomAttribute customAttr = customAttrInfo.getAttributes().get(schemaKey); boolean compliant = customAttr != null && (!checkDefaultValues || isValid(attrTO, customAttr)); if (!compliant) { LOG.trace("Attribute [{}] or its values [{}] are not allowed by form customization rules", attrTO.getSchema(), attrTO.getValues()); } return compliant; }); }
AttrTO attrTO = new AttrTO(); attrTO.setSchema(item.getExtAttrName()); switch (item.getExtAttrName()) { case UserInfo.PREFERRED_USERNAME_CLAIM: attrTO.getValues().add(userInfo.getPreferredUserName()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getProfile()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getEmail()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getName()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getFamilyName()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getMiddleName()); responseTO.getAttrs().add(attrTO); if (item.isConnObjectKey()) { attrTO.getValues().add(userInfo.getGivenName());
public Builder values(final Collection<String> values) { instance.getValues().addAll(values); return this; }
@JsonIgnore @Override public Optional<AttrTO> getPlainAttr(final String schema) { return plainAttrs.stream().filter(attr -> attr.getSchema().equals(schema)).findFirst(); }
filter(attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered((attr) -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream(). clone.setSchema(simpleAttrs[1]); membership.getPlainAttrs().add(clone); membAttrs.add(attr); filter(attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered(attr -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream(). clone.setSchema(simpleAttrs[1]); membership.getDerAttrs().add(clone); membAttrs.add(attr); filter(attr -> (attr.getSchema().contains(SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR))). forEachOrdered((attr) -> { String[] simpleAttrs = attr.getSchema().split( SyncopeEnduserConstants.MEMBERSHIP_ATTR_SEPARATOR); MembershipTO membership = userTO.getMemberships().stream(). clone.setSchema(simpleAttrs[1]); membership.getVirAttrs().add(clone); membAttrs.add(attr);
protected void millisToDate(final Set<AttrTO> attrs, final PlainSchemaTO plainSchema) throws IllegalArgumentException { final FastDateFormat fmt = FastDateFormat.getInstance(plainSchema.getConversionPattern()); attrs.stream(). filter(attr -> (attr.getSchema().equals(plainSchema.getKey()))). forEachOrdered(attr -> { for (ListIterator<String> itor = attr.getValues().listIterator(); itor.hasNext();) { String value = itor.next(); try { itor.set(fmt.format(Long.valueOf(value))); } catch (NumberFormatException ex) { LOG.error("Invalid format value for {}", value); } } }); }
@JsonIgnore public boolean isEmpty() { return attrTO == null || attrTO.getValues().isEmpty(); }