本文整理了Java中org.picketlink.idm.model.Attribute.<init>()
方法的一些代码示例,展示了Attribute.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.<init>()
方法的具体详情如下:
包路径:org.picketlink.idm.model.Attribute
类名称:Attribute
方法名:<init>
暂无
代码示例来源:origin: picketlink/picketlink
@Override
protected Collection<Attribute<? extends Serializable>> doPopulateEntry(Map<String, Serializable> properties) throws Exception {
List<Attribute<? extends Serializable>> attributes = new ArrayList<Attribute<?extends Serializable>>();
for (String name: properties.keySet()) {
attributes.add(new Attribute(name, properties.get(name)));
}
return attributes;
}
代码示例来源:origin: picketlink/picketlink
@Override
protected Collection<Attribute<? extends Serializable>> doPopulateEntry(Map<String, Serializable> properties) throws Exception {
List<Attribute<? extends Serializable>> attributes = new ArrayList<Attribute<?extends Serializable>>();
for (String name: properties.keySet()) {
attributes.add(new Attribute(name, properties.get(name)));
}
return attributes;
}
代码示例来源:origin: picketlink/picketlink
@Override
public void setValue(Object instance, String value) {
if (!(instance instanceof AttributedType)) {
throw new IllegalStateException("Instance [ " + instance + " ] not an instance of AttributedType");
}
AttributedType attributedType = (AttributedType) instance;
attributedType.setAttribute(new Attribute(bindingPropertyName, value));
}
代码示例来源:origin: picketlink/picketlink
@Override
public void setValue(Object instance, String value) {
if (!(instance instanceof AttributedType)) {
throw new IllegalStateException("Instance [ " + instance + " ] not an instance of AttributedType");
}
AttributedType attributedType = (AttributedType) instance;
attributedType.setAttribute(new Attribute(bindingPropertyName, value));
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
@Override
public void setEmail(String email) {
setAttribute(new org.picketlink.idm.model.Attribute<String>(LDAPConstants.EMAIL, email));
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
@SuppressWarnings("unchecked")
@Override
public <T extends Serializable> org.picketlink.idm.model.Attribute<T> getAttribute(String name) {
try {
Attribute theAttribute = attributes.get(name);
Object value = null;
if (theAttribute != null) {
value = theAttribute.get();
} else if (this.customAttributes.getAttributes().containsKey(name)) {
value = this.customAttributes.getAttribute(name);
} else {
return null;
}
return new org.picketlink.idm.model.Attribute<T>(name, (T) value);
} catch (NamingException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
@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");
}
}
}
代码示例来源:origin: picketlink/picketlink
private Map<String, Attribute> getAttributes(IdentityContext identityContext, AttributedType identityType) {
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
for (Attribute attribute : identityType.getAttributes()) {
attributes.put(attribute.getName(), attribute);
}
List<Property<Object>> properties = PropertyQueries.createQuery(identityType.getClass())
.addCriteria(new AnnotatedPropertyCriteria(AttributeProperty.class))
.getResultList();
for (Property property : properties) {
AttributeProperty attributeProperty = property.getAnnotatedElement().getAnnotation(AttributeProperty.class);
if (attributeProperty.managed()) {
String attributeName = property.getName();
Object attributeValue = property.getValue(identityType);
if (attributeValue != null) {
attributes.put(attributeName, new Attribute(attributeName, (Serializable) attributeValue));
} else {
attributes.remove(attributeName);
}
}
}
return attributes;
}
代码示例来源:origin: picketlink/picketlink
private Map<String, Attribute> getAttributes(IdentityContext identityContext, AttributedType identityType) {
Map<String, Attribute> attributes = new HashMap<String, Attribute>();
for (Attribute attribute : identityType.getAttributes()) {
attributes.put(attribute.getName(), attribute);
}
List<Property<Object>> properties = PropertyQueries.createQuery(identityType.getClass())
.addCriteria(new AnnotatedPropertyCriteria(AttributeProperty.class))
.getResultList();
for (Property property : properties) {
AttributeProperty attributeProperty = property.getAnnotatedElement().getAnnotation(AttributeProperty.class);
if (attributeProperty.managed()) {
String attributeName = property.getName();
Object attributeValue = property.getValue(identityType);
if (attributeValue != null) {
attributes.put(attributeName, new Attribute(attributeName, (Serializable) attributeValue));
} else {
attributes.remove(attributeName);
}
}
}
return attributes;
}
代码示例来源:origin: org.jboss.aerogear/aerogear-security-picketlink
/**
* Represents the generated TOTP secret for the current User logged in.
*/
@Produces
@Secret
public String getSecret() {
User user = (User) identity.getAccount();
Attribute<String> secret = user.getAttribute(IDM_SECRET_ATTRIBUTE);
if (secret == null) {
secret = new Attribute<String>(IDM_SECRET_ATTRIBUTE, Base32.random());
user.setAttribute(secret);
this.identityManager.update(user);
}
return secret.getValue();
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Sets multiple attributes and check if they are properly stored.
* </p>
*
* @throws Exception
*/
@Test
public void testSetMultipleAttributes() throws Exception {
T storedIdentityTypeInstance = getIdentityType(true);
storedIdentityTypeInstance.setAttribute(new Attribute<String>("QuestionTotal", "2"));
storedIdentityTypeInstance.setAttribute(new Attribute<String>("Question1", "What is favorite toy?"));
storedIdentityTypeInstance.setAttribute(new Attribute<String>("Question1Answer", "Gum"));
storedIdentityTypeInstance.setAttribute(new Attribute<String>("Question2", "What is favorite word?"));
storedIdentityTypeInstance.setAttribute(new Attribute<String>("Question2Answer", "Hi"));
updateIdentityType(storedIdentityTypeInstance);
T updatedIdentityTypeInstance = getIdentityType(false);
assertEquals("2", updatedIdentityTypeInstance.<String> getAttribute("QuestionTotal").getValue());
assertEquals("What is favorite toy?", updatedIdentityTypeInstance.<String> getAttribute("Question1").getValue());
assertEquals("Gum", updatedIdentityTypeInstance.<String> getAttribute("Question1Answer").getValue());
assertEquals("What is favorite word?", updatedIdentityTypeInstance.<String[]> getAttribute("Question2").getValue());
assertEquals("Hi", updatedIdentityTypeInstance.<String> getAttribute("Question2Answer").getValue());
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
oauthApp.setAttribute( new Attribute<String>("appURL", appURL) );
oauthApp.setAttribute( new Attribute<String>("appDesc", appDesc) );
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Sets an one-valued attribute.
* </p>
*
* @throws Exception
*/
@Test
public void testSetOneValuedAttribute() throws Exception {
T storedIdentityTypeInstance = getIdentityType(true);
storedIdentityTypeInstance.setAttribute(new Attribute<String>("one-valued", "1"));
updateIdentityType(storedIdentityTypeInstance);
T updatedIdentityTypeInstance = getIdentityType(false);
Attribute<String> oneValuedAttribute = updatedIdentityTypeInstance.getAttribute("one-valued");
assertNotNull(oneValuedAttribute);
assertEquals("1", oneValuedAttribute.getValue());
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Finds roles using the IDM specific attributes and role defined attributes.
* </p>
*
* @throws Exception
*/
@Test
public void testFindUsingMultipleParameters() throws Exception {
Role role = loadOrCreateRole("admin", true);
IdentityManager identityManager = getIdentityManager();
identityManager.update(role);
role.setAttribute(new Attribute<String>("someAttribute", "someAttributeValue"));
identityManager.update(role);
IdentityQuery<Role> query = identityManager.<Role> createQuery(Role.class);
query.setParameter(Role.NAME, "admin");
query.setParameter(IdentityType.ATTRIBUTE.byName("someAttribute"), "someAttributeValue");
List<Role> result = query.getResultList();
assertFalse(result.isEmpty());
assertTrue(contains(result, role.getName()));
assertEquals(1, result.size());
query = identityManager.<Role> createQuery(Role.class);
query.setParameter(Role.NAME, "admin");
query.setParameter(IdentityType.ATTRIBUTE.byName("someAttribute"), "someAttributeValue2");
result = query.getResultList();
assertTrue(result.isEmpty());
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Finds groups using the IDM specific attributes and group defined attributes.
* </p>
*
* @throws Exception
*/
@Test
public void testFindUsingMultipleParameters() throws Exception {
Group group = loadOrCreateGroup("admin", null, true);
IdentityManager identityManager = getIdentityManager();
identityManager.update(group);
group.setAttribute(new Attribute<String>("someAttribute", "someAttributeValue"));
identityManager.update(group);
IdentityQuery<Group> query = identityManager.<Group> createQuery(Group.class);
query.setParameter(Group.NAME, "admin");
query.setParameter(IdentityType.ATTRIBUTE.byName("someAttribute"), "someAttributeValue");
List<Group> result = query.getResultList();
assertFalse(result.isEmpty());
assertTrue(contains(result, group.getName()));
assertEquals(1, result.size());
query = identityManager.<Group> createQuery(Group.class);
query.setParameter(Group.NAME, "admin");
query.setParameter(IdentityType.ATTRIBUTE.byName("someAttribute"), "someAttributeValue2");
result = query.getResultList();
assertTrue(result.isEmpty());
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Updates an attribute.
* </p>
*
* @throws Exception
*/
@Test
public void testUpdateAttribute() throws Exception {
T storedIdentityTypeInstance = getIdentityType(true);
storedIdentityTypeInstance.setAttribute(new Attribute<String[]>("multi-valued", new String[] { "1", "2", "3" }));
updateIdentityType(storedIdentityTypeInstance);
T updatedIdentityTypeInstance = getIdentityType(false);
Attribute<String[]> multiValuedAttribute = updatedIdentityTypeInstance.getAttribute("multi-valued");
assertNotNull(multiValuedAttribute);
multiValuedAttribute.setValue(new String[] { "3", "4", "5" });
updatedIdentityTypeInstance.setAttribute(multiValuedAttribute);
updateIdentityType(updatedIdentityTypeInstance);
updatedIdentityTypeInstance = getIdentityType(false);
multiValuedAttribute = updatedIdentityTypeInstance.getAttribute("multi-valued");
assertNotNull(multiValuedAttribute);
assertEquals(3, multiValuedAttribute.getValue().length);
String[] values = multiValuedAttribute.getValue();
Arrays.sort(values);
assertTrue(Arrays.equals(values, new String[] { "3", "4", "5" }));
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <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());
}
代码示例来源:origin: picketlink/picketlink
@Override
public String createUser(SCIMUser user) {
verifyIdentityManager();
User simpleUser = new User();
simpleUser.setLoginName(user.getDisplayName());
UserName userName = user.getName();
if(userName != null){
simpleUser.setFirstName(userName.getGivenName());
simpleUser.setLastName(userName.getFamilyName());
simpleUser.setAttribute(new Attribute<Serializable>("FullName", userName.getFormatted()));
}
identityManager.add(simpleUser);
User storedUser = BasicModel.getUser(identityManager, user.getDisplayName());
String id = storedUser.getId();
return id;
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Sets a multi-valued attribute.
* </p>
*
* @throws Exception
*/
@Test
public void testSetMultiValuedAttribute() throws Exception {
T storedIdentityTypeInstance = getIdentityType(true);
storedIdentityTypeInstance.setAttribute(new Attribute<String[]>("multi-valued", new String[] { "1", "2", "3" }));
updateIdentityType(storedIdentityTypeInstance);
T updatedIdentityTypeInstance = getIdentityType(false);
Attribute<String[]> multiValuedAttribute = updatedIdentityTypeInstance.getAttribute("multi-valued");
assertNotNull(multiValuedAttribute);
assertNotNull(multiValuedAttribute.getValue());
assertEquals(3, multiValuedAttribute.getValue().length);
}
代码示例来源:origin: org.picketlink/picketlink-idm-impl
/**
* <p>
* Removes an attribute.
* </p>
*
* @throws Exception
*/
@Test
public void testRemoveAttribute() throws Exception {
T storedIdentityTypeInstance = getIdentityType(true);
storedIdentityTypeInstance.setAttribute(new Attribute<String[]>("multi-valued", new String[] { "1", "2", "3" }));
updateIdentityType(storedIdentityTypeInstance);
T updatedIdentityTypeInstance = getIdentityType(false);
Attribute<String[]> multiValuedAttribute = updatedIdentityTypeInstance.getAttribute("multi-valued");
assertNotNull(multiValuedAttribute);
updatedIdentityTypeInstance.removeAttribute("multi-valued");
updateIdentityType(updatedIdentityTypeInstance);
updatedIdentityTypeInstance = getIdentityType(false);
multiValuedAttribute = updatedIdentityTypeInstance.getAttribute("multi-valued");
assertNull(multiValuedAttribute);
}
内容来源于网络,如有侵权,请联系作者删除!