Package org.jboss.security.xacml.core.model.policy

Examples of org.jboss.security.xacml.core.model.policy.ObjectFactory


   }
  
   public static XACMLPolicy createPolicy(PolicyType policyFile)
   throws Exception
   {
      JAXBElement<PolicyType> jaxbPolicy = new ObjectFactory().createPolicy(policyFile);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JAXB.marshal(jaxbPolicy, baos);
      ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
      return (XACMLPolicy) getCtr().newInstance(new Object[]
                                                  { bis,
View Full Code Here


      {policyFile, XACMLPolicy.POLICY});
   }

   public static XACMLPolicy createPolicy(PolicyType policyFile) throws Exception
   {
      JAXBElement<PolicyType> jaxbPolicy = new ObjectFactory().createPolicy(policyFile);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JAXB.marshal(jaxbPolicy, baos);
      ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
      return (XACMLPolicy) getCtr().newInstance(new Object[]
      {bis, XACMLPolicy.POLICY});
View Full Code Here

      assertEquals("Access Disallowed?", XACMLConstants.DECISION_DENY, XACMLTestUtil.getDecision(pdp, request));
   }

   private PolicyType constructPolicy() throws Exception
   {
      ObjectFactory objectFactory = new ObjectFactory();

      PolicyType policyType = new PolicyType();
      policyType.setPolicyId("ExamplePolicy");
      policyType.setVersion("2.0");
      policyType.setRuleCombiningAlgId(XACMLConstants.RULE_COMBINING_PERMIT_OVERRIDES);

      //Create a target
      TargetType targetType = new TargetType();

      ResourcesType resourcesType = new ResourcesType();
      ResourceType resourceType = new ResourceType();
      ResourceMatchType rmt = new ResourceMatchType();
      rmt.setMatchId(XACMLConstants.FUNCTION_ANYURI_EQUAL);
      rmt.setResourceAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
            XACMLConstants.ATTRIBUTEID_RESOURCE_ID, XMLSchemaConstants.DATATYPE_ANYURI, null, false));
      rmt.setAttributeValue(PolicyAttributeFactory
            .createAnyURIAttributeType(new URI("http://test/developer-guide.html")));
      resourceType.getResourceMatch().add(rmt);
      resourcesType.getResource().add(resourceType);

      targetType.setResources(resourcesType);

      policyType.setTarget(targetType);

      //Create a Rule
      RuleType permitRule = new RuleType();
      permitRule.setRuleId("ReadRule");
      permitRule.setEffect(EffectType.PERMIT);

      ActionsType permitRuleActionsType = new ActionsType();
      ActionType permitRuleActionType = new ActionType();

      ActionMatchType amct = new ActionMatchType();
      amct.setMatchId("urn:oasis:names:tc:xacml:1.0:function:string-equal");
      amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType("read"));
      amct.setActionAttributeDesignator(PolicyAttributeFactory.createAttributeDesignatorType(
            XACMLConstants.ATTRIBUTEID_ACTION_ID, XMLSchemaConstants.DATATYPE_STRING, null, false));
      permitRuleActionType.getActionMatch().add(amct);
      TargetType permitRuleTargetType = new TargetType();
      permitRuleActionsType.getAction().add(permitRuleActionType);
      permitRuleTargetType.setActions(permitRuleActionsType);
      permitRule.setTarget(permitRuleTargetType);

      ConditionType permitRuleConditionType = new ConditionType();
      FunctionType functionType = new FunctionType();
      functionType.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
      JAXBElement<ExpressionType> jaxbElementFunctionType = objectFactory.createExpression(functionType);
      permitRuleConditionType.setExpression(jaxbElementFunctionType);

      ApplyType permitRuleApplyType = new ApplyType();
      permitRuleApplyType.setFunctionId(XACMLConstants.FUNCTION_STRING_IS_IN);

      SubjectAttributeDesignatorType sadt = PolicyAttributeFactory.createSubjectAttributeDesignatorType(
            XACMLConstants.ATTRIBUTEID_ROLE, XMLSchemaConstants.DATATYPE_STRING, null, false, null);
      JAXBElement<SubjectAttributeDesignatorType> sadtElement = objectFactory.createSubjectAttributeDesignator(sadt);
      AttributeValueType avt = PolicyAttributeFactory.createStringAttributeType("developer");
      JAXBElement<AttributeValueType> jaxbAVT = objectFactory.createAttributeValue(avt);
      permitRuleApplyType.getExpression().add(jaxbAVT);
      permitRuleApplyType.getExpression().add(sadtElement);

      permitRuleConditionType.setExpression(objectFactory.createApply(permitRuleApplyType));

      permitRule.setCondition(permitRuleConditionType);

      policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(permitRule);
      //Create a Deny Rule
View Full Code Here

      {policyFile, XACMLPolicy.POLICY});
   }

   public static XACMLPolicy createPolicy(PolicyType policyFile) throws Exception
   {
      JAXBElement<PolicyType> jaxbPolicy = new ObjectFactory().createPolicy(policyFile);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JAXB.marshal(jaxbPolicy, baos);
      ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
      return (XACMLPolicy) getCtr().newInstance(new Object[]
      {bis, XACMLPolicy.POLICY});
View Full Code Here

   }
  
   public static XACMLPolicy createPolicy(PolicyType policyFile)
   throws Exception
   {
      JAXBElement<PolicyType> jaxbPolicy = new ObjectFactory().createPolicy(policyFile);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JAXB.marshal(jaxbPolicy, baos);
      ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
      return (XACMLPolicy) getCtr().newInstance(new Object[]
                                                  { bis,
View Full Code Here

TOP

Related Classes of org.jboss.security.xacml.core.model.policy.ObjectFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.