Пример #1
0
  /**
   * Create a SAML2 auth request
   *
   * @param serviceURL URL of the service
   * @param identityURL URL of the identity provider
   * @return
   * @throws org.picketlink.common.exceptions.ConfigurationException
   */
  private AuthnRequestType createSAMLRequest(String serviceURL, String identityURL)
      throws ConfigurationException {
    if (serviceURL == null)
      throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "serviceURL");
    if (identityURL == null)
      throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "identityURL");

    SAML2Request saml2Request = new SAML2Request();
    String id = IDGenerator.create("ID_");
    return saml2Request.createAuthnRequestType(id, serviceURL, identityURL, serviceURL);
  }
Пример #2
0
  /**
   * Sign an RequestType at the root
   *
   * @param request
   * @param keypair Key Pair
   * @param digestMethod (Example: DigestMethod.SHA1)
   * @param signatureMethod (Example: SignatureMethod.DSA_SHA1)
   * @return
   * @throws ParserConfigurationException
   * @throws IOException
   * @throws SAXException
   * @throws XMLSignatureException
   * @throws MarshalException
   * @throws GeneralSecurityException
   */
  public Document sign(RequestAbstractType request, KeyPair keypair)
      throws SAXException, IOException, ParserConfigurationException, GeneralSecurityException,
          MarshalException, XMLSignatureException {
    SAML2Request saml2Request = new SAML2Request();
    Document doc = saml2Request.convert(request);
    doc.normalize();

    Node theSibling = getNextSiblingOfIssuer(doc);
    if (theSibling != null) {
      this.sibling = theSibling;
    }

    return sign(doc, request.getID(), keypair);
  }
Пример #3
0
 public RequestAbstractType getSAMLRequest(String samlMessage)
     throws ParsingException, ConfigurationException, ProcessingException {
   InputStream is = null;
   SAML2Request saml2Request = new SAML2Request();
   if (redirectProfile) {
     try {
       is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
     } catch (Exception e) {
       logger.samlParsingError(e);
       throw logger.parserError(e);
     }
   } else {
     byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
     logger.trace("SAML Request Document: " + new String(samlBytes));
     is = new ByteArrayInputStream(samlBytes);
   }
   return saml2Request.getRequestType(is);
 }
Пример #4
0
  public SAMLDocumentHolder getSAMLDocumentHolder(String samlMessage)
      throws ParsingException, ConfigurationException, ProcessingException {
    InputStream is = null;
    SAML2Request saml2Request = new SAML2Request();

    try {
      if (redirectProfile) {
        is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
      } else {
        byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
        logger.trace("SAML Request Document: " + new String(samlBytes));
        is = new ByteArrayInputStream(samlBytes);
      }
    } catch (Exception rte) {
      logger.samlBase64DecodingError(rte);
      throw logger.parserError(rte);
    }

    saml2Request.getSAML2ObjectFromStream(is);

    return saml2Request.getSamlDocumentHolder();
  }