org.picketlink.idm.model.Attribute类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中org.picketlink.idm.model.Attribute类的一些代码示例,展示了Attribute类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute类的具体详情如下:
包路径:org.picketlink.idm.model.Attribute
类名称:Attribute

Attribute介绍

[英]Represents an attribute value, a type of metadata that can be associated with an IdentityType
[中]表示属性值,这是一种可以与IdentityType关联的元数据类型

代码示例

代码示例来源:origin: picketlink/picketlink

private Map<String, Serializable> getAttributes(AttributedType attributedType) {
    HashMap<String, Serializable> attributes = new HashMap<String, Serializable>();

    for (Attribute attribute : attributedType.getAttributes()) {
      attributes.put(attribute.getName(), attribute.getValue());
    }

    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: picketlink/picketlink

attribute = new Attribute<Serializable>(storedName, storedValue);
} else {
    Serializable[] values = null;
    if (attribute.getValue().getClass().isArray()) {
      values = (Serializable[]) attribute.getValue();
    } else {
      values = (Serializable[]) Array.newInstance(attribute.getValue().getClass(), 1);
      values[0] = attribute.getValue();
    attribute.setValue(newValues);
attributes.put(attribute.getName(), attribute);

代码示例来源: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 String getValue(Object instance) {
  if (!(instance instanceof AttributedType)) {
    throw new IllegalStateException("Instance [ " + instance + " ] not an instance of AttributedType");
  }
  AttributedType attributedType = (AttributedType) instance;
  Attribute<String> attr = attributedType.getAttribute(bindingPropertyName);
  return attr!=null ? attr.getValue() : null;
}

代码示例来源:origin: org.picketlink/picketlink-idm-impl

identityType.setAttribute(new Attribute<Serializable>(mappedName, (Serializable) value));
    identityTypeAttribute = new Attribute<Serializable>(attribName, attribValue);
    identityType.setAttribute(identityTypeAttribute);
  } else {
    if (identityTypeAttribute.getValue() != null) {
      String[] values = null;
      if (identityTypeAttribute.getValue().getClass().isArray()) {
        values = (String[]) identityTypeAttribute.getValue();
      } else {
        values = new String[1];
        values[0] = identityTypeAttribute.getValue().toString();
      identityTypeAttribute.setValue(newValues);

代码示例来源: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.picketlink/picketlink-idm-api

public void setAttribute(Attribute<? extends Serializable> attribute) {
  attributes.put(attribute.getName(), attribute);
}

代码示例来源:origin: picketlink/picketlink

attribute = new Attribute(attributeName, "dummy");
if (isPrimitiveNativeType(attributeType)) {
  handlePrimitiveAttributeType(attribute, attributeType, valList);
    serialArray[i++] = attributeValue;
  attribute.setValue(serialArray);
attribute = new Attribute(attributeName, valList.get(0));

代码示例来源:origin: picketlink/picketlink

serialArray[i++] = str.toString();
  attribute.setValue(serialArray);
} else if (Integer.class.getName().equals(attributeType)) {
  Integer[] serialArray = new Integer[valueList.size()];
    serialArray[i++] = (Integer) str;
  attribute.setValue(serialArray);
} else if (Long.class.getName().equals(attributeType)) {
  Long[] serialArray = new Long[valueList.size()];
    serialArray[i++] = (Long) str;
  attribute.setValue(serialArray);
} else if (Double.class.getName().equals(attributeType)) {
  Double[] serialArray = new Double[valueList.size()];
  attribute.setValue(serialArray);
} else if (Float.class.getName().equals(attributeType)) {
  Float[] serialArray = new Float[valueList.size()];
  attribute.setValue(serialArray);
} else if (Short.class.getName().equals(attributeType)) {
  Short[] serialArray = new Short[valueList.size()];
  attribute.setValue(serialArray);

代码示例来源: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 String getValue(Object instance) {
  if (!(instance instanceof AttributedType)) {
    throw new IllegalStateException("Instance [ " + instance + " ] not an instance of AttributedType");
  }
  AttributedType attributedType = (AttributedType) instance;
  Attribute<String> attr = attributedType.getAttribute(bindingPropertyName);
  return attr!=null ? attr.getValue() : null;
}

代码示例来源: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: 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

public void setAttribute(Attribute<? extends Serializable> attribute) {
  attributes.put(attribute.getName(), attribute);
}

代码示例来源:origin: picketlink/picketlink

attribute = new Attribute(attributeName, "dummy");
if (isPrimitiveNativeType(attributeType)) {
  handlePrimitiveAttributeType(attribute, attributeType, valList);
    serialArray[i++] = attributeValue;
  attribute.setValue(serialArray);
attribute = new Attribute(attributeName, valList.get(0));

代码示例来源:origin: picketlink/picketlink

serialArray[i++] = str.toString();
  attribute.setValue(serialArray);
} else if (Integer.class.getName().equals(attributeType)) {
  Integer[] serialArray = new Integer[valueList.size()];
    serialArray[i++] = (Integer) str;
  attribute.setValue(serialArray);
} else if (Long.class.getName().equals(attributeType)) {
  Long[] serialArray = new Long[valueList.size()];
    serialArray[i++] = (Long) str;
  attribute.setValue(serialArray);
} else if (Double.class.getName().equals(attributeType)) {
  Double[] serialArray = new Double[valueList.size()];
  attribute.setValue(serialArray);
} else if (Float.class.getName().equals(attributeType)) {
  Float[] serialArray = new Float[valueList.size()];
  attribute.setValue(serialArray);
} else if (Short.class.getName().equals(attributeType)) {
  Short[] serialArray = new Short[valueList.size()];
  attribute.setValue(serialArray);

代码示例来源:origin: picketlink/picketlink

private Map<String, Serializable> getAttributes(AttributedType attributedType) {
    HashMap<String, Serializable> attributes = new HashMap<String, Serializable>();

    for (Attribute attribute : attributedType.getAttributes()) {
      attributes.put(attribute.getName(), attribute.getValue());
    }

    return attributes;
  }
}

代码示例来源: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: 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));
}

相关文章

微信公众号

最新文章

更多