@Override public void storeCredential(Agent agent, CredentialStorage storage) { List<Property<Object>> annotatedTypes = PropertyQueries.createQuery(storage.getClass()) .addCriteria(new AnnotatedPropertyCriteria(Stored.class)).getResultList(); if (annotatedTypes.isEmpty()) { throw new IdentityManagementException("Could not find any @Stored annotated method for CredentialStorage type [" + storage.getClass().getName() + "]."); } else { Property<Object> storedProperty = annotatedTypes.get(0); Object credential = storedProperty.getValue(storage); if (Serializable.class.isInstance(credential)) { org.picketlink.idm.model.Attribute<Serializable> credentialAttribute = new org.picketlink.idm.model.Attribute<Serializable>( storage.getClass().getName(), (Serializable) credential); agent.setAttribute(credentialAttribute); update(agent); } else { throw new IdentityManagementException( "Credential storage property [" + storedProperty.getName() + "] in class [" + storage.getClass().getName() + "] must implement Serializable"); } } }
oauthApp.setAttribute( new Attribute<String>("appURL", appURL) ); oauthApp.setAttribute( new Attribute<String>("appDesc", appDesc) );
user.setAttribute(new Attribute<String>("someAttribute", "someAttributeValue"));
Agent someAgent = loadOrCreateAgent("someAgent", true); someAgent.setAttribute(new Attribute<String>("someAttribute", "someAttributeValue")); assertTrue(contains(result, someAgent.getId())); someAgent.setAttribute(new Attribute<String>("someAttribute", "someAttributeValueChanged")); someAgent.setAttribute(new Attribute<String>("someAttribute2", "someAttributeValue2"));
/** * <p> * Updates the stored agent information. * </p> * * @throws Exception */ @Test public void testUpdate() throws Exception { Agent storedAgent = getIdentityType(true); assertNotNull(storedAgent); assertEquals("someAgent", storedAgent.getId()); IdentityManager identityManager = getIdentityManager(); storedAgent.setAttribute(new Attribute<String>("someAttribute", "1")); identityManager.update(storedAgent); // let's load again the user from the store and check for the updated information Agent updatedUser = identityManager.getAgent(storedAgent.getId()); assertNotNull(updatedUser.getAttribute("someAttribute")); assertEquals("1", updatedUser.getAttribute("someAttribute").getValue()); }
Agent someAgent = loadOrCreateAgent("someAgent", true); someAgent.setAttribute(new Attribute<String[]>("someAttribute", new String[] { "someAttributeValue1", "someAttributeValue2" })); someAgent.setAttribute(new Attribute<String[]>("someAttribute", new String[] { "someAttributeValue1", "someAttributeValueChanged" })); someAgent.setAttribute(new Attribute<String[]>("someAttribute2", new String[] { "someAttribute2Value1", "someAttribute2Value2" }));