private EnvironmentType getEnvironmentType() { EnvironmentType environmentType = new EnvironmentType(); environmentType.getAttribute().add( RequestAttributeFactory.createDateTimeAttributeType( XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null)); return environmentType; }
private ActionType getActionType(String action) { String actionID_NS = XACMLConstants.ATTRIBUTEID_ACTION_ID; AttributeType actionAttribute = RequestAttributeFactory.createStringAttributeType( actionID_NS , "jboss.org", action ); ActionType actionType = new ActionType(); actionType.getAttribute().add( actionAttribute ); return actionType; }
/** * @see PolicyRegistration#registerPolicy(String, String, InputStream) */ public void registerPolicy(String contextID, String type, InputStream stream) { if (PolicyRegistration.XACML.equalsIgnoreCase(type)) { try { XACMLPolicy policy = PolicyFactory.createPolicy(stream); Set<XACMLPolicy> policySet = this.contextIdToXACMLPolicy.get(contextID); if (policySet == null) { policySet = new HashSet<XACMLPolicy>(); } policySet.add(policy); this.contextIdToXACMLPolicy.put(contextID, policySet); } catch (Exception e) { PicketBoxLogger.LOGGER.debugIgnoredException(e); } } }
RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx(); RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_SUBJECT_ID, "jboss.org", AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ROLE, "jboss.org", roleName); subject.getAttribute().add(attSubjectID); RequestAttributeFactory.createAnyURIAttributeType( XACMLConstants.ATTRIBUTEID_RESOURCE_ID, null, RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ACTION_ID, "jboss.org", URI actionUri = new URI(actionURIBase + paramName); actionType.getAttribute().add( RequestAttributeFactory.createStringAttributeType( actionUri.toASCIIString(), "jboss.org", environmentType.getAttribute().add( RequestAttributeFactory.createDateTimeAttributeType( XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null));
RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx(); RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_SUBJECT_ID, "jboss.org", principal.getName())); AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ROLE, "jboss.org", roleName); subject.getAttribute().add(attSubjectID); RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_RESOURCE_ID, null, RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ACTION_ID, "jboss.org", RequestAttributeFactory.createDateTimeAttributeType( XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null));
private RequestContext getRequestContext( String ejbName, ActionType actionType, Principal principal, RoleGroup callerRoles ) throws IOException { if(principal == null) throw PicketBoxMessages.MESSAGES.invalidNullArgument("principal"); RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx(); //Create a subject type SubjectType subject = this.getSubjectType( principal, callerRoles ); //Create a resource type ResourceType resourceType = getResourceType( ejbName ); //Create an Environment Type (Optional) EnvironmentType environmentType = getEnvironmentType(); //Create a Request Type RequestType requestType = getRequestType( subject, resourceType, actionType, environmentType ); requestCtx.setRequest( requestType ); return requestCtx; }
RequestContext requestCtx = RequestResponseContextFactory.createRequestCtx(); RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_SUBJECT_ID, "jboss.org", AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ROLE, "jboss.org", roleName); subject.getAttribute().add(attSubjectID); RequestAttributeFactory.createAnyURIAttributeType( XACMLConstants.ATTRIBUTEID_RESOURCE_ID, null, RequestAttributeFactory.createStringAttributeType( XACMLConstants.ATTRIBUTEID_ACTION_ID, "jboss.org", URI actionUri = new URI(actionURIBase + paramName); actionType.getAttribute().add( RequestAttributeFactory.createStringAttributeType( actionUri.toASCIIString(), "jboss.org", environmentType.getAttribute().add( RequestAttributeFactory.createDateTimeAttributeType( XACMLConstants.ATTRIBUTEID_CURRENT_TIME, null));
private ResourceType getResourceType(String ejbName) { String resourceID_NS = XACMLConstants.ATTRIBUTEID_RESOURCE_ID; ResourceType resourceType = new ResourceType(); AttributeType resourceAttribute = RequestAttributeFactory.createStringAttributeType( resourceID_NS, null, ejbName ); resourceType.getAttribute().add( resourceAttribute ); return resourceType; }
XACMLPolicy policy = PolicyFactory.createPolicy(stream);
private SubjectType getSubjectType( Principal principal, RoleGroup callerRoles ) { String subjectID_NS = XACMLConstants.ATTRIBUTEID_SUBJECT_ID; String roleID_NS = XACMLConstants.ATTRIBUTEID_ROLE; String principalName = principal.getName(); //Create a subject type SubjectType subject = new SubjectType(); AttributeType attribute = RequestAttributeFactory.createStringAttributeType( subjectID_NS, "jboss.org", principalName ); subject.getAttribute().add( attribute ); Collection<Role> rolesList = callerRoles.getRoles(); if(rolesList != null) { for(Role role:rolesList) { String roleName = role.getRoleName(); AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( roleID_NS , "jboss.org", roleName ); subject.getAttribute().add(attSubjectID); } } return subject; } private void safeClose(OutputStream os)