public String base64Encoded(Document document)
      throws ConfigurationException, ProcessingException, IOException {
    String documentAsString = DocumentUtil.getDocumentAsString(document);
    logger.debugv("saml document: {0}", documentAsString);
    byte[] responseBytes = documentAsString.getBytes("UTF-8");

    return RedirectBindingUtil.deflateBase64URLEncode(responseBytes);
  }
 public String encoded() throws ProcessingException, ConfigurationException, IOException {
   byte[] responseBytes = DocumentUtil.getDocumentAsString(document).getBytes("UTF-8");
   return PostBindingUtil.base64Encode(new String(responseBytes));
 }