JBoss.orgCommunity Documentation
On the API level each IdentityType object (Identity and Group) can have associated Attribute objects. All operations are exposed by AttributesManager interface. Each attribute is described with AttributeDescription that contains its properties such as:
name - attribute name
readonly - if attribute values can be changed
multivalued - if attribute can have many values
required - if attribute can be removed
type - type of attribute values.
Default implementation provides two attribute types:
text - java.lang.String object
binary - byte[] object
Identity user = session.getPersistenceManager(). createIdentity("sampleUser"); // Check that binary attribute 'picture' is mapped AttributeDescription attributeDescription = session.getAttributesManager(). getAttributeDescription(user, "picture"); assertNotNull(attributeDescription); assertEquals("binary", attributeDescription.getType()); // Generate random binary data for binary attribute Random random = new Random(); byte[] picture = new byte[5120]; random.nextBytes(picture); // User attributes Attribute[] userInfo = new Attribute[] { new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, new String[]{"John"}), new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, new String[]{"Doe"}), new SimpleAttribute("picture", new byte[][]{picture}) }; session.getAttributesManager(). addAttributes(user, userInfo); .... AttributesManager attrMgr = session.getAttributesManager(); attrMgr.addAttribute(anneUser, P3PConstants.INFO_USER_NAME_GIVEN, "Anne"); attrMgr.addAttribute(anneUser, P3PConstants.INFO_USER_NAME_FAMILY, "Smith"); attrMgr.addAttribute(anneUser, P3PConstants.INFO_USER_JOB_TITLE, "Senior Software Developer"); attrMgr.addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "anne.smith@acme.com"); attrMgr.addAttribute(anneUser, P3PConstants.INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, "777 777 777 7 77");