attr.get().getValues().clear(); } else { attr = Optional.of(new AttrTO.Builder().schema(intAttrName.getSchemaName()).build()); userTO.getPlainAttrs().add(attr.get());
protected void fillTO( final AnyTO anyTO, final String realmFullPath, final Collection<? extends AnyTypeClass> auxClasses, final Collection<? extends PlainAttr<?>> plainAttrs, final Map<DerSchema, String> derAttrs, final Map<VirSchema, List<String>> virAttrs, final Collection<? extends ExternalResource> resources, final boolean details) { anyTO.setRealm(realmFullPath); anyTO.getAuxClasses().addAll(auxClasses.stream().map(Entity::getKey).collect(Collectors.toList())); plainAttrs.forEach(plainAttr -> { anyTO.getPlainAttrs().add(new AttrTO.Builder(). schema(plainAttr.getSchema().getKey()). values(plainAttr.getValuesAsStrings()).build()); }); derAttrs.forEach((schema, value) -> { anyTO.getDerAttrs().add(new AttrTO.Builder().schema(schema.getKey()).value(value).build()); }); virAttrs.forEach((schema, values) -> { anyTO.getVirAttrs().add(new AttrTO.Builder().schema(schema.getKey()).values(values).build()); }); anyTO.getResources().addAll(resources.stream().map(Entity::getKey).collect(Collectors.toSet())); }
attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getDerAttrs())); attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getVirAttrs())); attrs.put("username", new AttrTO.Builder().schema("username").value(userTO.getUsername()).build());
result.getPlainAttrs().add(new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(schema).build()). build()); }); result.getPlainAttrs().add(new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(attrTO.getSchema()).build()). build());
attr.get().getValues().clear(); } else { attr = Optional.of(new AttrTO.Builder().schema(intAttrName.getSchemaName()).build()); userTO.getPlainAttrs().add(attr.get());
protected MembershipTO getMembershipTO( final Collection<? extends PlainAttr<?>> plainAttrs, final Map<DerSchema, String> derAttrs, final Map<VirSchema, List<String>> virAttrs, final Membership<? extends Any<?>> membership) { MembershipTO membershipTO = new MembershipTO.Builder(). group(membership.getRightEnd().getKey(), membership.getRightEnd().getName()). build(); plainAttrs.forEach(plainAttr -> { membershipTO.getPlainAttrs().add(new AttrTO.Builder(). schema(plainAttr.getSchema().getKey()). values(plainAttr.getValuesAsStrings()). build()); }); derAttrs.forEach((schema, value) -> { membershipTO.getDerAttrs().add(new AttrTO.Builder(). schema(schema.getKey()). value(value). build()); }); virAttrs.forEach((schema, values) -> { membershipTO.getVirAttrs().add(new AttrTO.Builder(). schema(schema.getKey()). values(values). build()); }); return membershipTO; }
@PreAuthorize("hasRole('" + SCIMEntitlement.SCIM_CONF_SET + "')") public void set(final SCIMConf conf) { try { schemaLogic.read(SchemaType.PLAIN, SCIMConf.KEY); } catch (NotFoundException e) { PlainSchemaTO scimConf = new PlainSchemaTO(); scimConf.setKey(SCIMConf.KEY); scimConf.setType(AttrSchemaType.Binary); scimConf.setMimeType(MediaType.APPLICATION_JSON); schemaLogic.create(SchemaType.PLAIN, scimConf); } conf.setGeneralConf(new SCIMGeneralConf()); conf.getGeneralConf().setLastChangeDate(new Date()); configurationLogic.set(new AttrTO.Builder(). schema(SCIMConf.KEY). value(Base64.getEncoder().encodeToString(POJOHelper.serialize(conf).getBytes())). build()); } }
private <E extends Enum<?>> void fill( final Set<AttrTO> attrs, final List<SCIMComplexConf<E>> confs, final List<SCIMComplexValue> values) { values.forEach(value -> { if (value.getType() != null) { confs.stream(). filter(object -> value.getType().equals(object.getType().name())).findFirst(). ifPresent(conf -> attrs.add( new AttrTO.Builder().schema(conf.getValue()).value(value.getValue()).build())); } }); }
private ConnObjectTO getOnSyncope(final Any<?> any, final Provision provision, final String resourceKey) { Pair<String, Set<Attribute>> attrs = mappingManager.prepareAttrs(any, null, false, true, provision); MappingItem connObjectKey = provision.getMapping().getConnObjectKeyItem().orElseThrow(() -> new NotFoundException("No RemoteKey set for " + resourceKey)); ConnObjectTO connObjectTO = ConnObjectUtils.getConnObjectTO(attrs.getRight()); if (attrs.getLeft() != null) { connObjectTO.getAttrs().add(new AttrTO.Builder(). schema(connObjectKey.getExtAttrName()).value(attrs.getLeft()).build()); connObjectTO.getAttrs().add(new AttrTO.Builder(). schema(Uid.NAME).value(attrs.getLeft()).build()); } return connObjectTO; }
/** * Add PLAIN attribute DELETE patch for those attributes of the input AnyTO without values or containing null value * * @param anyTO User, Group or Any Object to look for attributes with no value * @param patch patch to enrich with DELETE statements */ public static void cleanEmptyAttrs(final AnyTO anyTO, final AnyPatch patch) { patch.getPlainAttrs().addAll(anyTO.getPlainAttrs().stream(). filter(plainAttrTO -> isEmpty(plainAttrTO)). map(plainAttrTO -> new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(plainAttrTO.getSchema()).build()). build()).collect(Collectors.toSet())); }
@Override public AttrTO getAttrTO(final CPlainAttr attr) { return new AttrTO.Builder(). schema(attr.getSchema().getKey()). values(attr.getValuesAsStrings()). build(); }
private void setAttribute(final UserTO userTO, final String schema, final String value) { switch (schema) { case "username": userTO.setUsername(value); break; default: userTO.getPlainAttrs().add(new AttrTO.Builder().schema(schema).value(value).build()); } }
@Override public void delete(final String key, final SchemaType schemaType, final String schema) { addUpdateOrReplaceAttr( getActualKey(getAnyDAO(), key), schemaType, new AttrTO.Builder().schema(schema).build(), PatchOperation.DELETE); }