public void testErrorHandling() throws Exception {
   ErrorServlet.authError = null;
   Client client = ClientBuilder.newClient();
   // make sure
   Response response = client.target(APP_SERVER_BASE_URL + "/employee-sig/").request().get();
   response.close();
   SAML2ErrorResponseBuilder builder =
       new SAML2ErrorResponseBuilder()
           .destination(APP_SERVER_BASE_URL + "/employee-sig/saml")
           .issuer(AUTH_SERVER_URL + "/realms/demo")
           .status(JBossSAMLURIConstants.STATUS_REQUEST_DENIED.get());
   BaseSAML2BindingBuilder binding = new BaseSAML2BindingBuilder().relayState(null);
   Document document = builder.buildDocument();
   URI uri =
       binding
           .redirectBinding(document)
           .generateURI(APP_SERVER_BASE_URL + "/employee-sig/saml", false);
   response = client.target(uri).request().get();
   String errorPage = response.readEntity(String.class);
   response.close();
   Assert.assertTrue(errorPage.contains("Error Page"));
   client.close();
   Assert.assertNotNull(ErrorServlet.authError);
   SamlAuthenticationError error = (SamlAuthenticationError) ErrorServlet.authError;
   Assert.assertEquals(SamlAuthenticationError.Reason.ERROR_STATUS, error.getReason());
   Assert.assertNotNull(error.getStatus());
   ErrorServlet.authError = null;
 }
 public BaseRedirectBindingBuilder(BaseSAML2BindingBuilder builder, Document document)
     throws ProcessingException {
   this.builder = builder;
   this.document = document;
   if (builder.encrypt) builder.encryptDocument(document);
   if (builder.signAssertions) {
     builder.signAssertion(document);
   }
 }
    public URI generateURI(String redirectUri, boolean asRequest)
        throws ConfigurationException, ProcessingException, IOException {
      String samlParameterName = GeneralConstants.SAML_RESPONSE_KEY;

      if (asRequest) {
        samlParameterName = GeneralConstants.SAML_REQUEST_KEY;
      }

      return builder.generateRedirectUri(samlParameterName, redirectUri, document);
    }
 public URI responseURI(String actionUrl)
     throws ConfigurationException, ProcessingException, IOException {
   return builder.generateRedirectUri(GeneralConstants.SAML_RESPONSE_KEY, actionUrl, document);
 }
 public String getHtmlRequest(String actionUrl)
     throws ProcessingException, ConfigurationException, IOException {
   String str = builder.buildHtmlPostResponse(document, actionUrl, true);
   return str;
 }