org.opensaml.saml1.core.Attribute类的使用及代码示例

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

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

Attribute介绍

[英]This interface defines how the object representing a SAML 1 Attribute element behaves.
[中]此接口定义表示SAML 1Attribute元素的对象的行为方式。

代码示例

代码示例来源:origin: edu.internet2.middleware/shibboleth-common

/** {@inheritDoc} */
public Attribute encode(BaseAttribute attribute) throws AttributeEncodingException {
  Attribute samlAttribute = attributeBuilder.buildObject();
  samlAttribute.setAttributeName(getAttributeName());
  samlAttribute.setAttributeNamespace(getNamespace());
  samlAttribute.getAttributeValues()
      .addAll(encodeAttributeValues(AttributeValue.DEFAULT_ELEMENT_NAME, attribute));
  List<XMLObject> attributeValues = samlAttribute.getAttributeValues();
  if (attributeValues == null || attributeValues.isEmpty()) {
    log.debug("Unable to encode {} attribute.  It does not contain any values", attribute.getId());
    return null;
  }
  return samlAttribute;
}

代码示例来源:origin: edu.internet2.middleware/shibboleth-common

/**
   * Populates the attribute with attribute name and namespace.
   * 
   * @param attribute to populate
   */
  protected void populateAttribute(Attribute attribute) {
    attribute.setAttributeName(getAttributeName());
    attribute.setAttributeNamespace(getNamespace());
  }
}

代码示例来源:origin: org.opensaml/opensaml

/**
   * Validates that the attribute has at least one attribute value.
   * 
   * @param attribute attribute to validate
   * 
   * @throws ValidationException thrown if the attribute does not have any values
   */
  protected void validateAttributeValue(Attribute attribute) throws ValidationException {
    if (attribute.getAttributeValues().size() == 0) {
      throw new ValidationException("No AttributeValue elements present");
    }
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.relyingparty

String name = attr.getAttributeNamespace() + "/" + attr.getAttributeName();
List attributeValues = attr.getAttributeValues();
Iterator values = attributeValues.iterator();
StringBuilder buffer = new StringBuilder();

代码示例来源:origin: org.opensaml/opensaml

/** {@inheritDoc} */
  protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
      throws UnmarshallingException {

    Attribute attribute = (Attribute) parentSAMLObject;

    QName childQName = childSAMLObject.getElementQName();
    if (childQName.getLocalPart().equals("AttributeValue")
        && childQName.getNamespaceURI().equals(SAMLConstants.SAML1_NS)) {
      attribute.getAttributeValues().add(childSAMLObject);
    } else {
      super.processChildElement(parentSAMLObject, childSAMLObject);
    }
  }
}

代码示例来源:origin: net.unicon.cas/cas-addons

attribute.setAttributeName(e.getKey());
attribute.setAttributeNamespace(NAMESPACE);
    attribute.getAttributeValues().add(newAttributeValue(value, attrStatement));
  attribute.getAttributeValues().add(newAttributeValue(e.getValue(), attrStatement));
attribute.setAttributeName(this.rememberMeAttributeName);
attribute.setAttributeNamespace(NAMESPACE);
attribute.getAttributeValues().add(newAttributeValue(REMEMBER_ME_ATTRIBUTE_VALUE, attrStatement));
attrStatement.getAttributes().add(attribute);

代码示例来源:origin: edu.internet2.middleware/shibboleth-common

/** {@inheritDoc} */
public Attribute encode(BaseAttribute attribute) throws AttributeEncodingException {
  Attribute samlAttribute = attributeBuilder.buildObject();
  populateAttribute(samlAttribute);
  XSAny samlAttributeValue;
  for (Object o : attribute.getValues()) {
    if (o == null || !(o instanceof XMLObject)) {
      continue;
    }
    samlAttributeValue = attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);
    samlAttributeValue.getUnknownXMLObjects().add((XMLObject) o);
    samlAttribute.getAttributeValues().add(samlAttributeValue);
  }
  List<XMLObject> attributeValues = samlAttribute.getAttributeValues();
  if (attributeValues == null || attributeValues.isEmpty()) {
    log.debug("Unable to encode {} attribute.  It does not contain any values", attribute.getId());
    return null;
  }
  return samlAttribute;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

attribute.setAttributeName(attributeName);
attribute.setAttributeNamespace(attributeUrn);
      stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    attribute1.setValue((String)value);
    attribute.getAttributeValues().add(attribute1);
  } else if (value instanceof XMLObject) {
    attribute.getAttributeValues().add((XMLObject)value);

代码示例来源:origin: edu.internet2.middleware/shibboleth-common

/** {@inheritDoc} */
public Attribute encode(BaseAttribute attribute) {
  Attribute samlAttribute = attributeBuilder.buildObject();
  populateAttribute(samlAttribute);
  byte[] attributeValue;
  XSString samlAttributeValue;
  for (Object o : attribute.getValues()) {
    if (o == null || !(o instanceof byte[])) {
      log.debug("Skipping attribute value because it is either null or not a byte[]");
      continue;
    }
    
    attributeValue = (byte[]) o;
    samlAttributeValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    samlAttributeValue.setValue(Base64.encodeBytes(attributeValue));
    samlAttribute.getAttributeValues().add(samlAttributeValue);
  }
  List<XMLObject> attributeValues = samlAttribute.getAttributeValues();
  if (attributeValues == null || attributeValues.isEmpty()) {
    log.debug("Unable to encode {} attribute.  It does not contain any values", attribute.getId());
    return null;
  }
  return samlAttribute;
}

代码示例来源:origin: org.apache.ws.security/wss4j

attribute.setAttributeName(attributeName);
attribute.setAttributeNamespace(attributeUrn);
      stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    attribute1.setValue((String)value);
    attribute.getAttributeValues().add(attribute1);
  } else if (value instanceof XMLObject) {
    attribute.getAttributeValues().add((XMLObject)value);

代码示例来源:origin: edu.internet2.middleware/shibboleth-common

/** {@inheritDoc} */
public Attribute encode(BaseAttribute attribute) {
  Attribute samlAttribute = attributeBuilder.buildObject();
  populateAttribute(samlAttribute);
  String attributeValue;
  XSString samlAttributeValue;
  for (Object o : attribute.getValues()) {
    if (o == null) {
      continue;
    }
    attributeValue = o.toString();
    if (!DatatypeHelper.isEmpty(attributeValue)) {
      samlAttributeValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
      samlAttributeValue.setValue(attributeValue);
      samlAttribute.getAttributeValues().add(samlAttributeValue);
    }
  }
  List<XMLObject> attributeValues = samlAttribute.getAttributeValues();
  if (attributeValues == null || attributeValues.isEmpty()) {
    log.debug("Unable to encode {} attribute.  It does not contain any values", attribute.getId());
    return null;
  }
  return samlAttribute;
}

代码示例来源:origin: org.apache.rampart/rampart-trust

/**
 * Creates a SAML attribute similar to following,
 * <pre>   &lt;saml:Attribute
 *       AttributeName="MemberLevel"
 *       AttributeNamespace="http://www.oasis.open.org/Catalyst2002/attributes"&gt;
 *       &lt;saml:AttributeValue&gt;gold&lt;/saml:AttributeValue&gt;
 *   &lt;/saml:Attribute&gt;</pre>
 * @param name attribute name
 * @param namespace attribute namespace.
 * @param value attribute value.
 * @return OpenSAML representation of the attribute.
 * @throws org.apache.rahas.TrustException If unable to find the appropriate builder.
 */
public static Attribute createAttribute(String name, String namespace, String value) throws TrustException {
  Attribute attribute = (Attribute)CommonUtil.buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
  attribute.setAttributeName(name);
  attribute.setAttributeNamespace(namespace);
  XSStringBuilder attributeValueBuilder = (XSStringBuilder)Configuration.getBuilderFactory().
      getBuilder(XSString.TYPE_NAME);
  XSString stringValue
      = attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
  stringValue.setValue(value);
  attribute.getAttributeValues().add(stringValue);
  return attribute;
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider

attribute.setAttributeName(attrName);
attribute.setAttributeNamespace(attrNamespace);
    attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
stringValue.setValue(claim.getValue());
attribute.getAttributeValues().add(stringValue);

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider

attribute.setAttributeName(attrName);
attribute.setAttributeNamespace(attrNamespace);
    attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
stringValue.setValue(claim.getValue());
attribute.getAttributeValues().add(stringValue);

相关文章

微信公众号

最新文章

更多