List of usage examples for org.springframework.expression PropertyAccessor PropertyAccessor
PropertyAccessor
From source file:it.geosolutions.geostore.core.security.MapExpressionUserMapper.java
public MapExpressionUserMapper(Map<String, String> attributeMappings) { super(attributeMappings); // property accessor for JSONObject attributes (read only) evaluationContext.addPropertyAccessor(new PropertyAccessor() { @Override/* w w w . j a v a 2s . co m*/ public void write(EvaluationContext ctx, Object target, String name, Object value) throws AccessException { } @Override public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException { if (target instanceof Map) { Map map = (Map) target; return new TypedValue(map.get(name)); } return null; } @Override public Class[] getSpecificTargetClasses() { return new Class[] { Map.class }; } @Override public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException { return false; } @Override public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException { return target instanceof Map; } }); }
From source file:it.geosolutions.geostore.core.security.JSONExpressionUserMapper.java
public JSONExpressionUserMapper(Map<String, String> attributeMappings) { super(attributeMappings); // property accessor for JSONObject attributes (read only) evaluationContext.addPropertyAccessor(new PropertyAccessor() { @Override//from w w w . j ava2s . c o m public void write(EvaluationContext ctx, Object target, String name, Object value) throws AccessException { } @Override public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException { if (target instanceof JSONObject) { JSONObject details = (JSONObject) target; return new TypedValue(details.get(name)); } return null; } @Override public Class[] getSpecificTargetClasses() { return new Class[] { JSONObject.class }; } @Override public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException { return false; } @Override public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException { return target instanceof JSONObject; } }); }
From source file:it.geosolutions.geostore.core.security.UserDetailsExpressionUserMapper.java
public UserDetailsExpressionUserMapper(Map<String, String> attributeMappings) { super(attributeMappings); // property accessor for UserDetailsWithAttributes attributes (read only) evaluationContext.addPropertyAccessor(new PropertyAccessor() { @Override//from www. j a v a 2s.c o m public void write(EvaluationContext ctx, Object target, String name, Object value) throws AccessException { } @Override public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException { if (target instanceof UserDetailsWithAttributes) { UserDetailsWithAttributes details = (UserDetailsWithAttributes) target; return new TypedValue(details.getAttribute(name)); } return null; } @Override public Class[] getSpecificTargetClasses() { return new Class[] { UserDetailsWithAttributes.class }; } @Override public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException { return false; } @Override public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException { return target instanceof UserDetailsWithAttributes; } }); }