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

This code example shows how to use the following methods:getParams, getX
    { 
        if (key instanceof DSAPrivateKey)
        { 
            DSAPrivateKey    k = (DSAPrivateKey)key;
 
            return new DSAPrivateKeyParameters(k.getX(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        } 
                         
        throw new InvalidKeyException("can't identify DSA private key.");
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getParams, getX
        } 
        else if (spec.isAssignableFrom(DSAPrivateKeySpec.class) && key instanceof java.security.interfaces.DSAPrivateKey)
        { 
            java.security.interfaces.DSAPrivateKey k = (java.security.interfaces.DSAPrivateKey)key;
 
            return new DSAPrivateKeySpec(k.getX(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG());
        } 
 
        return super.engineGetKeySpec(key, spec);
    } 
 
    protected Key engineTranslateKey(
        Key key)
        throws InvalidKeyException 
    { 
        if (key instanceof DSAPublicKey)
        { 
            return new BCDSAPublicKey((DSAPublicKey)key);
        } 
        else if (key instanceof DSAPrivateKey)
6
CodeRank
This code example shows how to use the following methods:getParams, getX
    } 
 
    BCDSAPrivateKey( 
        DSAPrivateKey key)
    { 
        this.x = key.getX();
        this.dsaSpec = key.getParams();
    } 
 
    BCDSAPrivateKey( 
        DSAPrivateKeySpec spec)
    { 
        this.x = spec.getX();
        this.dsaSpec = new DSAParameterSpec(spec.getP(), spec.getQ(), spec.getG());
    } 
 
    public BCDSAPrivateKey( 
        PrivateKeyInfo info)
        throws IOException 
    { 
6
CodeRank
This code example shows how to use the following methods:getParams, getX
    { 
        if (key instanceof DSAPrivateKey)
        { 
            DSAPrivateKey    k = (DSAPrivateKey)key;
 
            return new DSAPrivateKeyParameters(k.getX(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        } 
                         
        throw new InvalidKeyException("can't identify DSA private key.");
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getParams, getX
 
        if (key != null) {
            if (key instanceof DSAPrivateKey) {
 
                DSAPrivateKey privateKey = (DSAPrivateKey) key;
                DSAParams params = privateKey.getParams();
 
                try { 
                    return engineGeneratePrivate(new DSAPrivateKeySpec(
                            privateKey.getX(), params.getP(), params.getQ(),
                            params.getG()));
                } catch (InvalidKeySpecException e) {
                    // Actually this exception shouldn't be thrown 
                    throw new InvalidKeyException("ATTENTION: InvalidKeySpecException: " + e);
                } 
            } 
 
            if (key instanceof DSAPublicKey) {
 
                DSAPublicKey publicKey = (DSAPublicKey) key;
5
CodeRank
This code example shows how to use the following methods:getParams, getX
    } 
 
    JDKDSAPrivateKey( 
        DSAPrivateKey    key)
    { 
        this.x = key.getX();
        this.dsaSpec = key.getParams();
    } 
 
    JDKDSAPrivateKey( 
        DSAPrivateKeySpec    spec)
    { 
        this.x = spec.getX();
        this.dsaSpec = new DSAParameterSpec(spec.getP(), spec.getQ(), spec.getG());
    } 
 
    JDKDSAPrivateKey( 
        PrivateKeyInfo  info)
        throws IOException 
    { 
6
CodeRank
This code example shows how to use the following methods:getParams, getX
        } 
        else if (spec.isAssignableFrom(DSAPrivateKeySpec.class) && key instanceof java.security.interfaces.DSAPrivateKey)
        { 
            java.security.interfaces.DSAPrivateKey k = (java.security.interfaces.DSAPrivateKey)key;
 
            return new DSAPrivateKeySpec(k.getX(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG());
        } 
 
        return super.engineGetKeySpec(key, spec);
    } 
 
    protected Key engineTranslateKey(
        Key key)
        throws InvalidKeyException 
    { 
        if (key instanceof DSAPublicKey)
        { 
            return new BCDSAPublicKey((DSAPublicKey)key);
        } 
        else if (key instanceof DSAPrivateKey)
6
CodeRank
This code example shows how to use the following methods:getX
        } 
        else if (privateKey instanceof DSAPrivateKey)
        { 
            DSAPrivateKey dsK = (DSAPrivateKey)privateKey;
 
            privateKeyDataPacket = new DSASecretBCPGKey(dsK.getX());
        } 
        else if (privateKey instanceof  ElGamalPrivateKey)
        { 
            ElGamalPrivateKey esK = (ElGamalPrivateKey)privateKey;
 
            privateKeyDataPacket = new ElGamalSecretBCPGKey(esK.getX());
        } 
        else 
        { 
            throw new IllegalArgumentException("unknown key class");
        } 
 
    } 
 
5
CodeRank
This code example shows how to use the following methods:getParams, getX
    } 
 
    BCDSAPrivateKey( 
        DSAPrivateKey key)
    { 
        this.x = key.getX();
        this.dsaSpec = key.getParams();
    } 
 
    BCDSAPrivateKey( 
        DSAPrivateKeySpec spec)
    { 
        this.x = spec.getX();
        this.dsaSpec = new DSAParameterSpec(spec.getP(), spec.getQ(), spec.getG());
    } 
 
    public BCDSAPrivateKey( 
        PrivateKeyInfo info)
        throws IOException 
    { 
5
CodeRank
This code example shows how to use the following methods:getParams, getX
    { 
        if (key instanceof DSAPrivateKey)
        { 
            DSAPrivateKey    k = (DSAPrivateKey)key;
 
            return new DSAPrivateKeyParameters(k.getX(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        } 
                         
        throw new InvalidKeyException("can't identify DSA private key.");
    } 
} 
5
CodeRank
See Code Examples for Java 8 DSAPrivateKey Methods: