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

This code example shows how to use the following methods: getAlgorithm, getParams, getW
    } 
     
    public JCEECPublicKey( 
        ECPublicKey     key)
    { 
        this.algorithm = key.getAlgorithm();
        this.ecSpec = key.getParams();
        this.q = EC5Util.convertPoint(this.ecSpec, key.getW(), false);
    } 
 
    JCEECPublicKey( 
        SubjectPublicKeyInfo    info)
    { 
        populateFromPubKeyInfo(info);
    } 
 
    private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
    { 
        // BEGIN android-removed 
        // if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001)) 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, getAlgorithm, getEncoded, getFormat
 
        if (keySpec == null) {
            throw new InvalidKeySpecException("keySpec == null");
        } 
 
        if (!"EC".equals(key.getAlgorithm())) {
            throw new InvalidKeySpecException("Key must be an EC key");
        } 
 
        if (key instanceof ECPublicKey && ECPublicKeySpec.class.isAssignableFrom(keySpec)) {
            ECPublicKey ecKey = (ECPublicKey) key;
            return (T) new ECPublicKeySpec(ecKey.getW(), ecKey.getParams());
        } else if (key instanceof PublicKey && ECPublicKeySpec.class.isAssignableFrom(keySpec)) {
            final byte[] encoded = key.getEncoded();
            if (!"X.509".equals(key.getFormat()) || encoded == null) {
                throw new InvalidKeySpecException("Not a valid X.509 encoding");
            } 
            ECPublicKey ecKey = (ECPublicKey) engineGeneratePublic(new X509EncodedKeySpec(encoded));
            return (T) new ECPublicKeySpec(ecKey.getW(), ecKey.getParams());
        } else if (key instanceof ECPrivateKey

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getEncoded
  public MasterKeyData(int serialNo, SecretKey secretKey) {
    this.masterKeyRecord = Records.newRecord(MasterKey.class);
    this.masterKeyRecord.setKeyId(serialNo);
    this.generatedSecretKey = secretKey;
    this.masterKeyRecord.setBytes(ByteBuffer.wrap(generatedSecretKey
      .getEncoded()));
  } 
 
  public MasterKeyData(MasterKey masterKeyRecord, SecretKey secretKey) {
    this.masterKeyRecord = masterKeyRecord;
    this.generatedSecretKey = secretKey;
 
  } 
 
  public MasterKey getMasterKey() { 
    return this.masterKeyRecord;
  } 
 
  public SecretKey getSecretKey() {
    return this.generatedSecretKey;
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAlgorithm, getEncoded, getFormat
    private void encodeKey( 
        Key                 key,
        DataOutputStream    dOut)
        throws IOException 
    { 
        byte[]      enc = key.getEncoded();
 
        if (key instanceof PrivateKey)
        { 
            dOut.write(KEY_PRIVATE);
        } 
        else if (key instanceof PublicKey)
        { 
            dOut.write(KEY_PUBLIC);
        } 
        else 
        { 
            dOut.write(KEY_SECRET);
        } 
     

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, getAlgorithm, getEncoded, getFormat
 
        if (keySpec == null) {
            throw new InvalidKeySpecException("keySpec == null");
        } 
 
        if (!"RSA".equals(key.getAlgorithm())) {
            throw new InvalidKeySpecException("Key must be a RSA key");
        } 
 
        if (key instanceof RSAPublicKey && RSAPublicKeySpec.class.isAssignableFrom(keySpec)) {
            RSAPublicKey rsaKey = (RSAPublicKey) key;
            return (T) new RSAPublicKeySpec(rsaKey.getModulus(), rsaKey.getPublicExponent());
        } else if (key instanceof PublicKey && RSAPublicKeySpec.class.isAssignableFrom(keySpec)) {
            final byte[] encoded = key.getEncoded();
            if (!"X.509".equals(key.getFormat()) || encoded == null) {
                throw new InvalidKeySpecException("Not a valid X.509 encoding");
            } 
            RSAPublicKey rsaKey =
                    (RSAPublicKey) engineGeneratePublic(new X509EncodedKeySpec(encoded));
            return (T) new RSAPublicKeySpec(rsaKey.getModulus(), rsaKey.getPublicExponent());

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 Key Questions & Answers:

See Code Examples for Java 8 Key Methods: