[jboss-cvs] JBossAS SVN: r70333 - projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 3 14:10:39 EST 2008


Author: mmoyses
Date: 2008-03-03 14:10:39 -0500 (Mon, 03 Mar 2008)
New Revision: 70333

Modified:
   projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyAttributeFactory.java
Log:
New data types

Modified: projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyAttributeFactory.java
===================================================================
--- projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyAttributeFactory.java	2008-03-03 19:10:11 UTC (rev 70332)
+++ projects/security/security-xacml/trunk/jboss-xacml/src/main/org/jboss/security/xacml/factories/PolicyAttributeFactory.java	2008-03-03 19:10:39 UTC (rev 70333)
@@ -29,6 +29,7 @@
 import javax.security.auth.x500.X500Principal;
 import javax.xml.datatype.DatatypeConfigurationException;
 import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.jboss.security.xacml.core.model.policy.AttributeDesignatorType;
@@ -50,89 +51,99 @@
 
    public static AttributeValueType createAnyURIAttributeType(URI value)
    {
-      return getBareAttributeValueType(""+value, XMLSchemaConstants.DATATYPE_ANYURI);
+      return getBareAttributeValueType("" + value, XMLSchemaConstants.DATATYPE_ANYURI);
    }
-   
+
    public static AttributeValueType createBase64BinaryAttributeType(byte[] value)
    {
       return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_BASE64BINARY);
    }
-   
-   public static AttributeValueType createBooleanAttributeType( boolean value)
+
+   public static AttributeValueType createBooleanAttributeType(boolean value)
    {
       return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_BOOLEAN);
    }
-   
+
    public static AttributeValueType createDateAttributeType()
    {
       return getBareAttributeValueType(getXMLDate(), XMLSchemaConstants.DATATYPE_DATE);
    }
-   
+
    public static AttributeValueType createDateAttributeType(XMLGregorianCalendar value)
    {
       return getBareAttributeValueType(value.toXMLFormat(), XMLSchemaConstants.DATATYPE_DATE);
    }
-   
+
    public static AttributeValueType createDateTimeAttributeType()
    {
       return getBareAttributeValueType(getXMLDate(), XMLSchemaConstants.DATATYPE_DATE_TIME);
    }
-   
+
    public static AttributeValueType createDateTimeAttributeType(XMLGregorianCalendar value)
    {
       return getBareAttributeValueType(value.toXMLFormat(), XMLSchemaConstants.DATATYPE_DATE_TIME);
    }
-   
+
    public static AttributeValueType createDNSNameAttributeType(String hostname)
    {
-      return getBareAttributeValueType(hostname, "urn:oasis:names:tc:xacml:2.0:data-type:dnsName");
+      return getBareAttributeValueType(hostname, XMLSchemaConstants.DATATYPE_DNSNAME);
    }
-   
+
    public static AttributeValueType createDoubleAttributeType(double value)
    {
       return getBareAttributeValueType("" + value, XMLSchemaConstants.DATATYPE_DOUBLE);
    }
-   
+
    public static AttributeValueType createEmailAttributeType(String value)
    {
-      return getBareAttributeValueType(value, "urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name");
+      return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_RFC822NAME);
    }
-   
+
    public static AttributeValueType createHexBinaryAttributeType(byte[] value)
    {
       return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_HEXBINARY);
    }
-   
+
    public static AttributeValueType createIntegerAttributeType(int value)
    {
-      return getBareAttributeValueType("" + value, XMLSchemaConstants.DATATYPE_INTEGER); 
+      return getBareAttributeValueType("" + value, XMLSchemaConstants.DATATYPE_INTEGER);
    }
-   
+
    public static AttributeValueType createIPAddressAttributeType(InetAddress address)
    {
-      return getBareAttributeValueType(address, "urn:oasis:names:tc:xacml:2.0:data-type:ipAddress"); 
+      return getBareAttributeValueType(address, XMLSchemaConstants.DATATYPE_IPADDRESS);
    }
-   
+
    public static AttributeValueType createStringAttributeType(String value)
    {
-      return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_STRING); 
+      return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_STRING);
    }
-   
+
    public static AttributeValueType createTimeAttributeType()
    {
-      return getBareAttributeValueType(getXMLDate(), XMLSchemaConstants.DATATYPE_TIME); 
+      return getBareAttributeValueType(getXMLDate(), XMLSchemaConstants.DATATYPE_TIME);
    }
-   
+
    public static AttributeValueType createTimeAttributeType(XMLGregorianCalendar value)
    {
-      return getBareAttributeValueType(value.toXMLFormat(), XMLSchemaConstants.DATATYPE_TIME); 
+      return getBareAttributeValueType(value.toXMLFormat(), XMLSchemaConstants.DATATYPE_TIME);
    }
-   
+
    public static AttributeValueType createX509NameAttributeType(X500Principal value)
    {
-      return getBareAttributeValueType(value, "urn:oasis:names:tc:xacml:1.0:data-type:x500Name"); 
+      return getBareAttributeValueType(value, XMLSchemaConstants.DATATYPE_X500NAME);
    }
-   
+
+   public static AttributeValueType createDayTimeDurationAttributeType(Duration value)
+   {
+      return getBareAttributeValueType(value.toString(), XMLSchemaConstants.DATATYPE_DAYTIMEDURATION);
+   }
+
+   public static AttributeValueType createYearMonthDurationAttributeType(Duration value)
+   {
+      return getBareAttributeValueType(value.toString(), XMLSchemaConstants.DATATYPE_YEARMONTHDURATION);
+   }
+
    public static AttributeDesignatorType createAttributeDesignatorType(String id, String dataType)
    {
       AttributeDesignatorType adt = new AttributeDesignatorType();
@@ -140,7 +151,7 @@
       adt.setDataType(dataType);
       return adt;
    }
-   
+
    public static SubjectAttributeDesignatorType createSubjectAttributeDesignatorType(String id, String dataType)
    {
       SubjectAttributeDesignatorType adt = new SubjectAttributeDesignatorType();
@@ -148,14 +159,14 @@
       adt.setDataType(dataType);
       return adt;
    }
-   
+
    private static AttributeValueType getBareAttributeValueType(Object value, String dataType)
-   { 
+   {
       AttributeValueType avt = new AttributeValueType();
       avt.setDataType(dataType);
-      avt.getContent().add(value); 
-      return avt; 
-   } 
+      avt.getContent().add(value);
+      return avt;
+   }
 
    private static String getXMLDate()
    {
@@ -167,7 +178,7 @@
       catch (DatatypeConfigurationException e)
       {
          throw new RuntimeException(e);
-      } 
+      }
       XMLGregorianCalendar value = dtf.newXMLGregorianCalendar((GregorianCalendar) Calendar.getInstance());
       return value.toXMLFormat();
    }




More information about the jboss-cvs-commits mailing list