use of com.sun.identity.entitlement.xacml3.core.AttributeDesignator in project OpenAM by OpenRock.
the class XACMLPrivilegeUtils method realmsAppsResourcesToAnyOf.
public static AnyOf realmsAppsResourcesToAnyOf(Set<String> realms, Map<String, Set<String>> appsResources) throws JSONException {
AnyOf anyOf = new AnyOf();
List<AllOf> allOfList = anyOf.getAllOf();
AllOf allOf = new AllOf();
allOfList.add(allOf);
List<Match> matchList = allOf.getMatch();
Match match = new Match();
matchList.add(match);
//FIXME
match.setMatchId(XACMLConstants.JSON_REALMS_APPS_RESOURCES_MATCH);
AttributeValue attributeValue = new AttributeValue();
//FIXME
String dataType = XACMLConstants.JSON_REALMS_APPS_RESOURCES_DATATYPE;
attributeValue.setDataType(dataType);
JSONObject jo = new JSONObject();
jo.put("realms", realms);
jo.put("appsResources", appsResources);
attributeValue.getContent().add(jo.toString());
AttributeDesignator attributeDesignator = new AttributeDesignator();
String category = XACMLConstants.REALMS_APPS_RESOURCES_CATEGORY;
attributeDesignator.setCategory(category);
String attributeId = XACMLConstants.JSON_REALMS_APPS_RESOURCES_ID;
attributeDesignator.setAttributeId(attributeId);
attributeDesignator.setDataType(dataType);
boolean mustBePresent = false;
attributeDesignator.setMustBePresent(mustBePresent);
match.setAttributeValue(attributeValue);
match.setAttributeDesignator(attributeDesignator);
return anyOf;
}
use of com.sun.identity.entitlement.xacml3.core.AttributeDesignator in project OpenAM by OpenRock.
the class XACMLPrivilegeUtils method applicationNameToMatch.
public static Match applicationNameToMatch(String applicationName) {
if (applicationName == null || applicationName.length() == 0) {
return null;
}
Match match = new Match();
String matchId = XACMLConstants.APPLICATION_MATCH;
match.setMatchId(matchId);
AttributeValue attributeValue = new AttributeValue();
String dataType = XACMLConstants.XS_STRING;
attributeValue.setDataType(dataType);
attributeValue.getContent().add(applicationName);
AttributeDesignator attributeDesignator = new AttributeDesignator();
String category = XACMLConstants.APPLICATION_CATEGORY;
attributeDesignator.setCategory(category);
String attributeId = XACMLConstants.APPLICATION_ID;
attributeDesignator.setAttributeId(attributeId);
String dt = XACMLConstants.XS_STRING;
attributeDesignator.setDataType(dt);
// TODO: not a constant?
String issuer = XACMLConstants.APPLICATION_ISSUER;
// attributeDesignator.setIssuer(issuer); // TODO: verify and fix
boolean mustBePresent = false;
attributeDesignator.setMustBePresent(mustBePresent);
match.setAttributeValue(attributeValue);
match.setAttributeDesignator(attributeDesignator);
return match;
}
use of com.sun.identity.entitlement.xacml3.core.AttributeDesignator in project OpenAM by OpenRock.
the class XACMLPrivilegeUtils method resourceNameToMatch.
public static Match resourceNameToMatch(String resourceName, String applicationName) {
if (resourceName == null || resourceName.length() == 0) {
return null;
}
Match match = new Match();
String matchId = XACMLConstants.ENTITLEMENT_RESOURCE_MATCH + ":" + applicationName;
match.setMatchId(matchId);
AttributeValue attributeValue = new AttributeValue();
String dataType = XACMLConstants.XS_STRING;
attributeValue.setDataType(dataType);
attributeValue.getContent().add(resourceName);
AttributeDesignator attributeDesignator = new AttributeDesignator();
String category = XACMLConstants.XACML_RESOURCE_CATEGORY;
attributeDesignator.setCategory(category);
String attributeId = XACMLConstants.XACML_RESOURCE_ID;
attributeDesignator.setAttributeId(attributeId);
String dt = XACMLConstants.XS_STRING;
attributeDesignator.setDataType(dt);
// TOOD: not a constant?
String issuer = XACMLConstants.RESOURCE_ISSUER;
// attributeDesignator.setIssuer(issuer); TODO: verify and fix
boolean mustBePresent = true;
attributeDesignator.setMustBePresent(mustBePresent);
match.setAttributeValue(attributeValue);
match.setAttributeDesignator(attributeDesignator);
return match;
}
use of com.sun.identity.entitlement.xacml3.core.AttributeDesignator in project OpenAM by OpenRock.
the class XACMLPrivilegeUtils method actionNameToMatch.
public static Match actionNameToMatch(String actionName, String applicationName) {
if (actionName == null || actionName.length() == 0) {
return null;
}
Match match = new Match();
String matchId = XACMLConstants.ENTITLEMENT_ACTION_MATCH + ":" + applicationName;
match.setMatchId(matchId);
AttributeValue attributeValue = new AttributeValue();
String dataType = XACMLConstants.XS_STRING;
attributeValue.setDataType(dataType);
attributeValue.getContent().add(actionName);
AttributeDesignator attributeDesignator = new AttributeDesignator();
String category = XACMLConstants.XACML_ACTION_CATEGORY;
attributeDesignator.setCategory(category);
String attributeId = XACMLConstants.XACML_ACTION_ID;
attributeDesignator.setAttributeId(attributeId);
String dt = XACMLConstants.XS_STRING;
attributeDesignator.setDataType(dt);
// TODO: not a constant?
String issuer = XACMLConstants.ACTION_ISSUER;
// attributeDesignator.setIssuer(issuer); // TODO: verify and fix
boolean mustBePresent = true;
attributeDesignator.setMustBePresent(mustBePresent);
match.setAttributeValue(attributeValue);
match.setAttributeDesignator(attributeDesignator);
return match;
}
use of com.sun.identity.entitlement.xacml3.core.AttributeDesignator in project OpenAM by OpenRock.
the class XACMLPrivilegeUtils method entitlementSubjectToAnyOfList.
// TODO: not used now, use, test, fix and verify
public static List<AnyOf> entitlementSubjectToAnyOfList(EntitlementSubject es) {
if (es == null) {
return null;
}
List<AnyOf> anyOfList = new ArrayList<AnyOf>();
AnyOf anyOf = new AnyOf();
anyOfList.add(anyOf);
List<AllOf> allOfList = anyOf.getAllOf();
AllOf allOf = new AllOf();
allOfList.add(allOf);
List<Match> matchList = allOf.getMatch();
if (es instanceof UserSubject) {
UserSubject us = (UserSubject) es;
String userId = us.getID();
Match match = new Match();
matchList.add(match);
match.setMatchId("user-subject-match");
AttributeValue attributeValue = new AttributeValue();
String dataType = "datatype";
attributeValue.setDataType(dataType);
attributeValue.getContent().add(userId);
AttributeDesignator attributeDesignator = new AttributeDesignator();
String category = "subject-category";
attributeDesignator.setCategory(category);
String attributeId = "user-subject:user-id";
attributeDesignator.setAttributeId(attributeId);
String dt = "xs;string";
attributeDesignator.setDataType(dt);
String issuer = "subject:issuer";
// attributeDesignator.setIssuer(issuer); TODO: verify and fix
boolean mustBePresent = true;
attributeDesignator.setMustBePresent(mustBePresent);
match.setAttributeValue(attributeValue);
match.setAttributeDesignator(attributeDesignator);
}
return anyOfList;
}
Aggregations