use of edu.uiuc.ncsa.security.util.functor.JFunctor in project OA4MP by ncsa.
the class jSet method execute.
@Override
public Object execute() {
String claim = String.valueOf(getArgs().get(0));
if (!claims.containsKey(claim)) {
return null;
}
Object obj = getArgs().get(1);
String newValue = null;
if (obj instanceof JFunctor) {
JFunctor ff = (JFunctor) obj;
ff.execute();
newValue = String.valueOf(ff.getResult());
} else {
newValue = String.valueOf(obj);
}
claims.put(claim, newValue);
return newValue;
}
use of edu.uiuc.ncsa.security.util.functor.JFunctor in project OA4MP by ncsa.
the class FunctorTests method testAccessToken.
@Test
public void testAccessToken() throws Exception {
Map<String, Object> claims = createClaims();
CAFunctorFactory ff = new CAFunctorFactory(claims);
String rawJson = "{\"$access_token\":[\"$true\"]}";
JFunctor jf = ff.fromJSON(JSONObject.fromObject(rawJson));
assert jf instanceof jAccessToken;
jf.execute();
assert ((jAccessToken) jf).getBooleanResult();
}
use of edu.uiuc.ncsa.security.util.functor.JFunctor in project OA4MP by ncsa.
the class jExclude method execute.
@Override
public Object execute() {
HashSet<String> newClaims = new HashSet<>();
for (int i = 0; i < getArgs().size(); i++) {
Object obj = getArgs().get(i);
String newClaim = null;
if (obj instanceof JFunctor) {
JFunctor ff = (JFunctor) obj;
ff.execute();
newClaim = String.valueOf(ff.getResult());
} else {
newClaim = String.valueOf(obj);
}
if (newClaim != null) {
newClaims.add(newClaim);
}
}
for (String claim : newClaims) {
claims.remove(claim);
}
result = null;
return result;
}
use of edu.uiuc.ncsa.security.util.functor.JFunctor in project OA4MP by ncsa.
the class jInclude method execute.
@Override
public Object execute() {
HashSet<String> newClaims = new HashSet<>();
for (int i = 0; i < getArgs().size(); i++) {
Object obj = getArgs().get(i);
String newClaim = null;
if (obj instanceof JFunctor) {
JFunctor ff = (JFunctor) obj;
ff.execute();
newClaim = String.valueOf(ff.getResult());
} else {
newClaim = String.valueOf(obj);
}
if (newClaim != null) {
newClaims.add(newClaim);
}
}
Set<String> currentClaims = new HashSet<>();
// when you try to remove values.
for (String x : claims.keySet()) {
currentClaims.add(x);
}
for (String claim : currentClaims) {
if (!newClaims.contains(claim)) {
claims.remove(claim);
}
}
result = null;
return result;
}
Aggregations