コード例 #1
0
  @SuppressWarnings("unchecked")
  // CHECKSTYLE:OFF
  public static AuthnRequest createAuthnRequest(
      String serviceURL,
      boolean forceAuthn,
      boolean isPassive,
      String protocolBinding,
      SAMLVersion version,
      Issuer issuer,
      NameIDPolicy nameIDPolicy,
      RequestedAuthnContext requestedAuthnCtx) {
    // CHECKSTYLE:ON
    if (authnRequestBuilder == null) {
      authnRequestBuilder =
          (SAMLObjectBuilder<AuthnRequest>)
              builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
    }
    AuthnRequest authnRequest = authnRequestBuilder.buildObject();
    authnRequest.setAssertionConsumerServiceURL(serviceURL);
    authnRequest.setForceAuthn(forceAuthn);
    authnRequest.setID("_" + UUID.randomUUID());
    authnRequest.setIsPassive(isPassive);
    authnRequest.setIssueInstant(new DateTime());
    authnRequest.setProtocolBinding(protocolBinding);
    authnRequest.setVersion(version);

    authnRequest.setIssuer(issuer);
    authnRequest.setNameIDPolicy(nameIDPolicy);
    authnRequest.setRequestedAuthnContext(requestedAuthnCtx);

    return authnRequest;
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Test
  public void testSingleElementOptionalAttributesMarshall() {
    QName qname =
        new QName(
            SAMLConstants.SAML20P_NS,
            AuthnRequest.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20P_PREFIX);
    AuthnRequest req = (AuthnRequest) buildXMLObject(qname);

    super.populateRequiredAttributes(req);
    super.populateOptionalAttributes(req);

    req.setForceAuthn(expectedForceAuthn);
    req.setIsPassive(expectedIsPassive);
    req.setProtocolBinding(expectedProtocolBinding);
    req.setAssertionConsumerServiceIndex(expectedAssertionConsumerServiceIndex);
    req.setAssertionConsumerServiceURL(expectedAssertionConsumerServiceURL);
    req.setAttributeConsumingServiceIndex(expectedAttributeConsumingServiceIndex);
    req.setProviderName(expectedProviderName);

    assertXMLEquals(expectedOptionalAttributesDOM, req);
  }