Java 8 PublicKey - 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 PublicKey class.

This code example shows how to use the following methods:getEncoded
        } 
        else 
        { 
            try 
            { 
                byte[]  bytes = publicKey.getEncoded();
 
                publicKey = JDKKeyFactory.createPublicKeyFromDERStream(bytes);
 
                if (publicKey instanceof DSAKey)
                { 
                    param = DSAUtil.generatePublicKeyParameter(publicKey);
                } 
                else 
                { 
                    throw new InvalidKeyException("can't recognise key type in DSA based signer");
                } 
            } 
            catch (Exception e)
            { 
7
CodeRank
This code example shows how to use the following methods:toString, getAlgorithm, getEncoded, getFormat
This code example shows how to use the following methods:getEncoded
        } 
        else 
        { 
            try 
            { 
                byte[] bytes = publicKey.getEncoded();
 
                publicKey = JDKKeyFactory.createPublicKeyFromDERStream(bytes);
 
                if (publicKey instanceof ECPublicKey)
                { 
                    param = ECUtil.generatePublicKeyParameter(publicKey);
                } 
                else 
                { 
                    throw new InvalidKeyException("can't recognise key type in ECDSA based signer");
                } 
            } 
            catch (Exception e)
            { 
7
CodeRank
This code example shows how to use the following methods:getEncoded
This code example shows how to use the following methods:getEncoded
 
        return bl;
    } 
 
    public boolean isPublicKeyBlackListed(PublicKey publicKey) {
        byte[] encoded = publicKey.getEncoded();
        Digest digest = new OpenSSLDigest.SHA1();
        digest.update(encoded, 0, encoded.length);
        byte[] out = new byte[digest.getDigestSize()];
        digest.doFinal(out, 0);
        return pubkeyBlacklist.contains(out);
    } 
 
    public boolean isSerialNumberBlackListed(BigInteger serial) {
        return serialBlacklist.contains(serial);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getAlgorithm, getEncoded, getFormat
    result = 31 * result + (encoded != null ? Arrays.hashCode(encoded) : 0);
    return result;
  } 
 
  public String getAlgorithm() {
    return key.getAlgorithm();
  } 
 
  public String getFormat() {
    return key.getFormat();
  } 
 
  public byte[] getEncoded() { 
    return key.getEncoded();
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getAlgorithm
 
        if (issPub instanceof RSAPublicKey)
        { 
            signerBuilder = new JcaContentSignerBuilder("SHA1WithRSA");
        } 
        else if (issPub.getAlgorithm().equals("DSA"))
        { 
            signerBuilder = new JcaContentSignerBuilder("SHA1withDSA");
        } 
        else if (issPub.getAlgorithm().equals("ECDSA"))
        { 
            signerBuilder = new JcaContentSignerBuilder("SHA1withECDSA");
        } 
        else if (issPub.getAlgorithm().equals("ECGOST3410"))
        { 
            signerBuilder = new JcaContentSignerBuilder("GOST3411withECGOST3410");
        } 
        else 
        { 
            signerBuilder = new JcaContentSignerBuilder("GOST3411WithGOST3410");

6
CodeRank
This code example shows how to use the following methods:hashCode, getEncoded
This code example shows how to use the following methods:getEncoded
   /** 
    * encodes the {@link PublicKey} to PEM format. 
    */ 
   public static String pem(PublicKey key) {
      String marker = key instanceof RSAPublicKey ? PUBLIC_PKCS1_MARKER : PUBLIC_X509_MARKER;
      return pem(key.getEncoded(), marker);
   } 
 
   /** 
    * encodes the {@link PrivateKey} to PEM format. 
    */ 
   public static String pem(PrivateKey key) {
      String marker = key instanceof RSAPrivateCrtKey ? PRIVATE_PKCS1_MARKER : PRIVATE_PKCS8_MARKER;
      return pem(key instanceof RSAPrivateCrtKey ? encode(RSAPrivateCrtKey.class.cast(key)) : key.getEncoded(), marker);
   } 
 
   private static String pem(byte[] encoded, String marker) {
      String ls = System.getProperty("line.separator");
      StringBuilder builder = new StringBuilder();
      builder.append(marker).append(ls);
6
CodeRank
This code example shows how to use the following methods:getAlgorithm
        in.read(b);
        return b;
    } 
 
    public byte[] readSignature(PublicKey pubKey) throws IOException {
        if (!pubKey.getAlgorithm().equals("DSA"))
            throw new UnsupportedOperationException();
 
        DSAPublicKey dsaPubKey = (DSAPublicKey) pubKey;
        DSAParams dsaParams = dsaPubKey.getParams();
        byte[] sig = new byte[dsaParams.getQ().bitLength() / 4];
        read(sig);
        return sig;
    } 
 
    public SignatureX readMysteriousX() throws IOException {
        PublicKey pubKey = readPublicKey();
        int dhKeyID = readInt();
        byte[] sig = readSignature(pubKey);
        return new SignatureX(pubKey, dhKeyID, sig);
6
CodeRank

Related Java 8 PublicKey Questions & Answers:

See Code Examples for Java 8 PublicKey Methods: