/** * Generic routine for resource, attribute and environment attributes * to build the lookup map for each. The Form is a Map that is indexed * by the String form of the attribute ids, and that contains Sets at * each entry with all attributes that have that id */ private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) { Iterator<Attribute> it = input.iterator(); while (it.hasNext()) { Attribute attr = it.next(); String id = attr.getId().toString(); if (output.containsKey(id)) { List<Attribute> list = output.get(id); list.add(attr); } else { List list = new ArrayList<Attribute>(); list.add(attr); output.put(id, list); } } }
/** * Generic routine for resource, attribute and environment attributes * to build the lookup map for each. The Form is a Map that is indexed * by the String form of the attribute ids, and that contains Sets at * each entry with all attributes that have that id */ private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) { Iterator<Attribute> it = input.iterator(); while (it.hasNext()) { Attribute attr = it.next(); String id = attr.getId().toString(); if (output.containsKey(id)) { List<Attribute> list = output.get(id); list.add(attr); } else { List list = new ArrayList<Attribute>(); list.add(attr); output.put(id, list); } } }
private String getXacmlResourceId(RequestCtx req) { List<Attribute> attributes = req.getResourceAsList(); for (Attribute attr : attributes) { if (logger.isDebugEnabled()) { logger.debug("Attribute: " + attr.getId().toString()); } if (attr.getId().toString().equals(Constants.XACML1_RESOURCE.ID.uri)) { return attr.getValue().encode(); } } return null; } }
/** * Changes the value of the resource-id attribute in this context. This * is useful when you have multiple resources (ie, a scope other than * IMMEDIATE), and you need to keep changing only the resource-id to * evaluate the different effective requests. * * @param resourceId the new resource-id value */ public void setResourceId(AttributeValue resourceId) { this.resourceId = resourceId; // there will always be exactly one value for this attribute Collection attrSet = (Collection)(resourceMap.get(RESOURCE_ID)); Attribute attr = (Attribute)(attrSet.iterator().next()); // remove the old value... attrSet.remove(attr); // ...and insert the new value attrSet.add(new SingletonAttribute(attr.getId(), attr.getIssuer(), attr.getIssueInstant(), resourceId)); }
/** * Changes the value of the resource-id attribute in this context. This * is useful when you have multiple resources (ie, a scope other than * IMMEDIATE), and you need to keep changing only the resource-id to * evaluate the different effective requests. * * @param resourceId the new resource-id value */ public void setResourceId(AttributeValue resourceId) { this.resourceId = resourceId; // there will always be exactly one value for this attribute Collection attrSet = (Collection)(resourceMap.get(RESOURCE_ID)); Attribute attr = (Attribute)(attrSet.iterator().next()); // remove the old value... attrSet.remove(attr); // ...and insert the new value attrSet.add(new SingletonAttribute(attr.getId(), attr.getIssuer(), attr.getIssueInstant(), resourceId)); }
String id = attr.getId().toString();
String id = attr.getId().toString();
/** * Utility function to add an attribute to the hash digest. * * @param a * the attribute to hash */ private static void hashAttribute(Attribute a, MessageDigest dig) { dig.update(a.getId().toString().getBytes()); dig.update(a.getType().toString().getBytes()); dig.update(a.getValue().encode().getBytes()); if (a.getIssuer() != null) { dig.update(a.getIssuer().getBytes()); } if (a.getIssueInstant() != null) { dig.update(a.getIssueInstant().encode().getBytes()); } }
protected List<Subject> wrapSubjects(String subjectLoginId) { logger.debug("wrapSubjectIdAsSubjects(): {}", subjectLoginId); StringAttribute stringAttribute = EMPTY_ATTRIBUTE; Attribute subjectAttribute = SUBJECT_ATTRIBUTE; logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); List<Attribute> subjectAttributes; if (subjectLoginId != null && !subjectLoginId.isEmpty()) { subjectAttributes = new ArrayList<Attribute>(2); subjectAttributes.add(subjectAttribute); stringAttribute = new StringAttribute(subjectLoginId); subjectAttribute = new SingletonAttribute(SUBJECT_ID_URI, null, null, stringAttribute); logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); subjectAttributes.add(subjectAttribute); } else { subjectAttributes = new ArrayList<Attribute>(1); subjectAttributes.add(subjectAttribute); } Subject singleSubject = new Subject(subjectAttributes); return Collections.singletonList(singleSubject); }
protected List<Subject> wrapSubjects(String subjectLoginId) { logger.debug("wrapSubjectIdAsSubjects(): {}", subjectLoginId); StringAttribute stringAttribute = EMPTY_ATTRIBUTE; Attribute subjectAttribute = SUBJECT_ATTRIBUTE; logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); List<Attribute> subjectAttributes; if (subjectLoginId != null && !subjectLoginId.isEmpty()) { subjectAttributes = new ArrayList<Attribute>(2); subjectAttributes.add(subjectAttribute); stringAttribute = new StringAttribute(subjectLoginId); subjectAttribute = new SingletonAttribute(SUBJECT_ID_URI, null, null, stringAttribute); logger.debug("wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}", subjectAttribute.getId(), subjectAttribute.getType(), subjectAttribute.getValue()); subjectAttributes.add(subjectAttribute); } else { subjectAttributes = new ArrayList<Attribute>(1); subjectAttributes.add(subjectAttribute); } Subject singleSubject = new Subject(subjectAttributes); return Collections.singletonList(singleSubject); }
if (debug) { for (Attribute tempobj: actions) { logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue());
while (tempit.hasNext()) { Attribute tempobj = tempit.next(); logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue().toString());
if (debug) { for (Attribute tempobj: actions) { logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue());
if (debug) { for (Attribute tempobj: actions) { logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue());
if (debug) { for (Attribute tempobj: actions) { logger.debug("request action has {}={}", tempobj.getId(), tempobj.getValue());