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

x33g5p2x  于2022-01-16 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(127)

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

Assertion.setID介绍

[英]Get the ID.
[中]拿到身份证。

代码示例

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

assertion.setID(attribute.getValue());
} else if (Assertion.ISSUER_ATTRIB_NAME.equals(attribute.getLocalName())) {
  assertion.setIssuer(attribute.getValue());

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

/**
 * Method getId returns the id of this SamlAssertionWrapper object.
 *
 * @return the id (type String) of this SamlAssertionWrapper object.
 */
public String getId() {
  String id = null;
  if (samlVersion == SAMLVersion.VERSION_20) {
    id = ((org.opensaml.saml.saml2.core.Assertion)samlObject).getID();
    if (id == null || id.length() == 0) {
      LOG.error("SamlAssertionWrapper: ID was null, seeting a new ID value");
      id = IDGenerator.generateID("_");
      ((org.opensaml.saml.saml2.core.Assertion)samlObject).setID(id);
    }
  } else if (samlVersion == SAMLVersion.VERSION_11) {
    id = ((org.opensaml.saml.saml1.core.Assertion)samlObject).getID();
    if (id == null || id.length() == 0) {
      LOG.error("SamlAssertionWrapper: ID was null, seeting a new ID value");
      id = IDGenerator.generateID("_");
      ((org.opensaml.saml.saml1.core.Assertion)samlObject).setID(id);
    }
  } else {
    LOG.error("SamlAssertionWrapper: unable to return ID - no saml assertion object");
  }
  return id;
}

代码示例来源:origin: org.jasig.cas/cas-server-support-saml

/**
 * Create a new SAML1 response object.
 *
 * @param authnStatement the authn statement
 * @param issuer the issuer
 * @param issuedAt the issued at
 * @param id the id
 * @return the assertion
 */
public Assertion newAssertion(final AuthenticationStatement authnStatement, final String issuer,
                  final DateTime issuedAt, final String id) {
  final Assertion assertion = newSamlObject(Assertion.class);
  assertion.setID(id);
  assertion.setIssueInstant(issuedAt);
  assertion.setIssuer(issuer);
  assertion.getAuthenticationStatements().add(authnStatement);
  return assertion;
}

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

/**
 * Constructs an {@link Assertion} using the parameters supplied, with its issue instant set to the
 * current time.
 * 
 * @param action the current action
 * @param idGenerator source of assertion ID
 * @param issuer value for assertion
 * 
 * @return the assertion
 */
@Nonnull public static Assertion buildAssertion(@Nonnull final AbstractProfileAction action,
    @Nonnull final IdentifierGenerationStrategy idGenerator, @Nonnull @NotEmpty final String issuer) {
  
  final SAMLObjectBuilder<Assertion> assertionBuilder = (SAMLObjectBuilder<Assertion>)
      XMLObjectProviderRegistrySupport.getBuilderFactory().<Assertion>getBuilderOrThrow(
          Assertion.DEFAULT_ELEMENT_NAME);
  final Assertion assertion = assertionBuilder.buildObject();
  assertion.setID(idGenerator.generateIdentifier());
  assertion.setIssueInstant(new DateTime());
  assertion.setIssuer(issuer);
  assertion.setVersion(SAMLVersion.VERSION_11);
  
  getLogger().debug("Profile Action {}: Created Assertion {}", action.getClass().getSimpleName(),
      assertion.getID());
  return assertion;
}

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

/**
 * 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(IDGenerator.generateID("_"));
  return assertion;
}

代码示例来源:origin: apache/cxf

private String createNewId(SamlAssertionWrapper assertion) {
  if (assertion.getSaml1() != null) {
    org.opensaml.saml.saml1.core.Assertion saml1Assertion = assertion.getSaml1();
    String oldId = saml1Assertion.getID();
    saml1Assertion.setID(IDGenerator.generateID("_"));
    return oldId;
  }
  org.opensaml.saml.saml2.core.Assertion saml2Assertion = assertion.getSaml2();
  String oldId = saml2Assertion.getID();
  saml2Assertion.setID(IDGenerator.generateID("_"));
  return oldId;
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

private String createNewId(SamlAssertionWrapper assertion) {
  if (assertion.getSaml1() != null) {
    org.opensaml.saml.saml1.core.Assertion saml1Assertion = assertion.getSaml1();
    String oldId = saml1Assertion.getID();
    saml1Assertion.setID(IDGenerator.generateID("_"));
    return oldId;
  }
  org.opensaml.saml.saml2.core.Assertion saml2Assertion = assertion.getSaml2();
  String oldId = saml2Assertion.getID();
  saml2Assertion.setID(IDGenerator.generateID("_"));
  return oldId;
}

代码示例来源:origin: net.shibboleth.idp/idp-cas-impl

assertion.setID(identifierGenerationStrategy.generateIdentifier());
assertion.setIssueInstant(now);
assertion.setVersion(SAMLVersion.VERSION_11);

相关文章