Java 8 XMLSignature - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 XMLSignature class.

This code example shows how to use the following methods:sign
        Element w3cElement = document.getDocumentElement();
        Node xmlSigInsertionPoint = getXmlSignatureInsertionLocation(w3cElement);
        DOMSignContext dsc = new DOMSignContext(privateKey, w3cElement, xmlSigInsertionPoint);
         
        XMLSignature signature = signatureFactory.newXMLSignature(signedInfo, keyInfo);
        signature.sign(dsc);
        return w3cElement;
    } 
     
    /** 
     * Non-static method to return private key entry from the keystore. 
     *  
     * @return PrivateKeyEntry Entry containing public-private key combination. 
     */ 
    private PrivateKeyEntry getPrivateKeyEntryFromKeystore() {
        String keyStorePass = null;
        String keyAlias = null;
        FileInputStream propStream = null;
        try { 
            propStream = new FileInputStream(new File(propertiesFile));
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:sign
            dsc.setNextSibling(xmlSigInsertionPoint);
 
            // Marshal, generate (and sign) the enveloped signature 
            final XMLSignature signature = sigFactory.newXMLSignature(signedInfo,
                    keyInfo);
            signature.sign(dsc);
 
            return toJdom(w3cElement);
 
        } catch (final Exception e) {
            throw new RuntimeException("Error signing SAML element: "
                    + e.getMessage(), e);
        } 
    } 
 
    /** 
     * Gets the xml signature insert location. 
     * 
     * @param elem the elem 
     * @return the xml signature insert location 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:validate
     * 
     * @return true if the signature is valid, false otherwise. 
     */ 
    public boolean isSmpSignatureValid() { 
        try { 
            return signature.validate(domValidateContext);
        } catch (XMLSignatureException e) {
            throw new IllegalStateException("Unable to validateUsingCache signature: " + e, e);
        } 
    } 
 
 
    /** 
     * Retrieves the certificate of the SMP, which signed the response. 
     * 
     * @return the certificate used to sign the request or null if not found. 
     */ 
    public X509Certificate getCertificate() {
 
        // This is horrible, read the JavaDoc to understand :-) 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:sign
 
    // Finally, generate the signature 
    DOMSignContext domSignContext = new DOMSignContext(
        keyPair.getPrivate(), document.getDocumentElement());
    try { 
      signature.sign(domSignContext);
    } catch (MarshalException e) {
      throw new RuntimeException(e);
    } catch (XMLSignatureException e) {
      throw new RuntimeException(e);
    } 
 
    XmlUtil.writeDocument(document, writer, null);
  } 
 
  /* VisibleForTesting */ PublicKey getPublicKey() {
    return keyPair.getPublic();
  } 
} 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 XMLSignature Methods: