org.opensaml.saml1.core.Assertion.setVersion()方法的使用及代码示例

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

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

Assertion.setVersion介绍

[英]Sets the SAML version of this assertion.
[中]设置此断言的SAML版本。

代码示例

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

/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
  Assertion assertion = (Assertion) samlObject;
  if (Assertion.ID_ATTRIB_NAME.equals(attribute.getLocalName())) {
    assertion.setID(attribute.getValue());
  } else if (Assertion.ISSUER_ATTRIB_NAME.equals(attribute.getLocalName())) {
    assertion.setIssuer(attribute.getValue());
  } else if (Assertion.ISSUEINSTANT_ATTRIB_NAME.equals(attribute.getLocalName())
      && !DatatypeHelper.isEmpty(attribute.getValue())) {
    assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
  } else if (Assertion.MINORVERSION_ATTRIB_NAME.equals(attribute.getLocalName())) {
    if (attribute.getValue().equals("0")) {
      assertion.setVersion(SAMLVersion.VERSION_10);
    } else {
      assertion.setVersion(SAMLVersion.VERSION_11);
    }
  } else {
    super.processAttribute(samlObject, attribute);
  }
}

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

/**
 * Create a new SAML 1.1 assertion
 *
 * @param issuer of type String
 * @return A SAML 1.1 assertion
 */
@SuppressWarnings("unchecked")
public static Assertion createSamlv1Assertion(String issuer) {
  if (assertionV1Builder == null) {
    assertionV1Builder = (SAMLObjectBuilder<Assertion>) 
      builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
    if (assertionV1Builder == null) {
      throw new IllegalStateException(
        "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml "
        + "engine prior using it"
      );
    }
  }
  Assertion assertion = 
    assertionV1Builder.buildObject(
      Assertion.DEFAULT_ELEMENT_NAME, 
      Assertion.TYPE_NAME
    );
  assertion.setVersion(SAMLVersion.VERSION_11);
  assertion.setIssuer(issuer);
  assertion.setIssueInstant(new DateTime()); // now
  assertion.setID("_" + UUIDGenerator.getUUID());
  return assertion;
}

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

/**
 * Create a new SAML 1.1 assertion
 *
 * @param issuer of type String
 * @return A SAML 1.1 assertion
 */
@SuppressWarnings("unchecked")
public static Assertion createSamlv1Assertion(String issuer) {
  if (assertionV1Builder == null) {
    assertionV1Builder = (SAMLObjectBuilder<Assertion>) 
      builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
    if (assertionV1Builder == null) {
      throw new IllegalStateException(
        "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml "
        + "engine prior using it"
      );
    }
  }
  Assertion assertion = 
    assertionV1Builder.buildObject(
      Assertion.DEFAULT_ELEMENT_NAME, 
      Assertion.TYPE_NAME
    );
  assertion.setVersion(SAMLVersion.VERSION_11);
  assertion.setIssuer(issuer);
  assertion.setIssueInstant(new DateTime()); // now
  assertion.setID("_" + UUIDGenerator.getUUID());
  return assertion;
}

相关文章