Skip to content

Default Java XACML type mappings

Cyril Dangerville edited this page Jan 29, 2018 · 1 revision

AuthzForce API allows to create AttributeValues (and AttributeBags) from standard Java types using default Java-to-XACML type mappings detailed below:

Standard Java type XACML datatype
java.lang.String http://www.w3.org/2001/XMLSchema#string
java.lang.Boolean http://www.w3.org/2001/XMLSchema#boolean
java.lang.Short http://www.w3.org/2001/XMLSchema#integer
java.lang.Integer http://www.w3.org/2001/XMLSchema#integer
java.lang.Long http://www.w3.org/2001/XMLSchema#integer
java.math.BigInteger http://www.w3.org/2001/XMLSchema#integer
java.lang.Float http://www.w3.org/2001/XMLSchema#double
java.lang.Double http://www.w3.org/2001/XMLSchema#double
java.time.LocalTime http://www.w3.org/2001/XMLSchema#time
java.time.OffsetTime http://www.w3.org/2001/XMLSchema#time
java.time.LocalDate http://www.w3.org/2001/XMLSchema#date
java.time.LocalDateTime http://www.w3.org/2001/XMLSchema#dateTime
java.time.OffsetDateTime http://www.w3.org/2001/XMLSchema#dateTime
java.time.ZonedDateTime http://www.w3.org/2001/XMLSchema#dateTime
java.time.Instant http://www.w3.org/2001/XMLSchema#dateTime
java.net.URI http://www.w3.org/2001/XMLSchema#anyURI
byte[] http://www.w3.org/2001/XMLSchema#hexBinary
javax.security.auth.x500.X500Principal urn:oasis:names:tc:xacml:1.0:data-type:x500Name

Legacy date/time classes

java.util.Date, java.util.Calendar and subclasses such as java.util.GregorianCalendar are not supported here because considered unsafe legacy code since Java 8. More info: https://docs.oracle.com/javase/tutorial/datetime/iso/legacy.html

Code sample

private static final AttributeValueFactoryRegistry ATT_VALUE_FACTORIES = StandardAttributeValueFactories.getRegistry(false, Optional.empty());

...
// Single value
final AttributeValue attVal = ATT_VALUE_FACTORIES.newAttributeValue(myRawValue);
// Collection
final AttributeBag<?> attBag = ATT_VALUE_FACTORIES.newAttributeBag(myRawValues);
...