Examples of PKCS8Key


Examples of org.apache.commons.ssl.PKCS8Key

     *
     * @throws KeyException thrown if the key can not be decoded
     */
    public static PrivateKey decodePrivateKey(byte[] key, char[] password) throws KeyException {
        try {
            PKCS8Key deocodedKey = new PKCS8Key(key, password);
            return deocodedKey.getPrivateKey();
        } catch (GeneralSecurityException e) {
            throw new KeyException("Unable to decode private key", e);
        }
    }
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

    f.setExecutable(false);
  }

  public static boolean sameKeyPair(File privateKeyFile, File publicKeyFile) throws IOException {
    try {
      PKCS8Key decodedKey = new PKCS8Key(
          new FileInputStream(privateKeyFile), null);
      PublicKey publicKey = decodedKey.getPublicKey();

      byte[] actual = encodePublicKey((RSAPublicKey) publicKey);
      byte[] expected = IOUtils.toByteArray(new FileReader(publicKeyFile));

      for(int i=0; i<actual.length; i += 1) {
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

    f.setExecutable(false);
  }

  public static boolean sameKeyPair(File privateKeyFile, File publicKeyFile) throws IOException {
    try {
      PKCS8Key decodedKey = new PKCS8Key(
          new FileInputStream(privateKeyFile), null);
      PrivateKey privateKey = decodedKey.getPrivateKey();
      PublicKey publicKey = decodedKey.getPublicKey();

      byte[] actual = encodePublicKey((RSAPublicKey) publicKey);
      byte[] expected = IOUtils.toByteArray(new FileReader(publicKeyFile));

      for(int i=0; i<actual.length; i += 1) {
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

     *
     * @throws KeyException thrown if the key can not be decoded
     */
    public static PrivateKey decodePrivateKey(byte[] key, char[] password) throws KeyException {
        try {
            PKCS8Key deocodedKey = new PKCS8Key(key, password);
            return deocodedKey.getPrivateKey();
        } catch (GeneralSecurityException e) {
            throw new KeyException("Unable to decode private key", e);
        }
    }
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

    f.setExecutable(false);
  }

  public static boolean sameKeyPair(File privateKeyFile, File publicKeyFile) throws IOException {
    try {
      PKCS8Key decodedKey = new PKCS8Key(
          new FileInputStream(privateKeyFile), null);
      PublicKey publicKey = decodedKey.getPublicKey();

      byte[] actual = encodePublicKey((RSAPublicKey) publicKey);
      byte[] expected = IOUtils.toByteArray(new FileReader(publicKeyFile));

      for(int i=0; i<actual.length; i += 1) {
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

        signatureTemplate = getInitParameter("signatureTemplate");
        String privateKeyString = getInitParameter("privateKey");
        String privateKeyPassword = getInitParameter("privateKeyPassword", null);
        forceCRLF = getInitParameter("forceCRLF", true);
        try {
            PKCS8Key pkcs8 = new PKCS8Key(new ByteArrayInputStream(
                    privateKeyString.getBytes()),
                    privateKeyPassword != null ? privateKeyPassword
                            .toCharArray() : null);
            privateKey = pkcs8.getPrivateKey();
            // privateKey = DKIMSigner.getPrivateKey(privateKeyString);
        } catch (NoSuchAlgorithmException e) {
            throw new MessagingException("Unknown private key algorythm: "
                    + e.getMessage(), e);
        } catch (InvalidKeySpecException e) {
View Full Code Here

Examples of org.apache.commons.ssl.PKCS8Key

     *
     * @throws KeyException thrown if the key can not be decoded
     */
    public static PrivateKey decodePrivateKey(byte[] key, char[] password) throws KeyException {
        try {
            PKCS8Key deocodedKey = new PKCS8Key(key, password);
            return deocodedKey.getPrivateKey();
        } catch (GeneralSecurityException e) {
            throw new KeyException("Unable to decode private key", e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.