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

This code example shows how to use the following methods: getParams, getY
	public void testRecoverKeyPair_Dsa() throws Exception { 
		KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
 
		DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
 
		assertEquals(DSA_KEY_pub, pubKey.getY());
 
		DSAParams params = pubKey.getParams();
		assertEquals(params.getG(), DSA_KEY_G);
		assertEquals(params.getP(), DSA_KEY_P);
		assertEquals(params.getQ(), DSA_KEY_Q);
	} 
 
	public void testRecoverKeyPair_Rsa() throws Exception { 
		KeyPair kp = PubkeyUtils.recoverKeyPair(RSA_KEY_PKCS8);
 
		RSAPublicKey pubKey = (RSAPublicKey) kp.getPublic();
 
		assertEquals(RSA_KEY_N, pubKey.getModulus());
		assertEquals(RSA_KEY_E, pubKey.getPublicExponent());
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: getParams, getY
    { 
        if (key instanceof DSAPublicKey)
        { 
            DSAPublicKey    k = (DSAPublicKey)key;
 
            return new DSAPublicKeyParameters(k.getY(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        } 
 
        throw new InvalidKeyException("can't identify DSA public key: " + key.getClass().getName());
    } 
 
    static public AsymmetricKeyParameter generatePrivateKeyParameter( 
        PrivateKey    key)
        throws InvalidKeyException 
    { 
        if (key instanceof DSAPrivateKey)
        { 
            DSAPrivateKey    k = (DSAPrivateKey)key;
 
Full Snippet Info
6
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: getParams, getY
    { 
        if (spec.isAssignableFrom(DSAPublicKeySpec.class) && key instanceof DSAPublicKey)
        { 
            DSAPublicKey k = (DSAPublicKey)key;
 
            return new DSAPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG());
        } 
        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 
Full Snippet Info
6
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: getParams, getY
	public void testRecoverKeyPair_Dsa() throws Exception { 
		KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
 
		DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
 
		assertEquals(DSA_KEY_pub, pubKey.getY());
 
		DSAParams params = pubKey.getParams();
		assertEquals(params.getG(), DSA_KEY_G);
		assertEquals(params.getP(), DSA_KEY_P);
		assertEquals(params.getQ(), DSA_KEY_Q);
	} 
 
	public void testRecoverKeyPair_Rsa() throws Exception { 
		KeyPair kp = PubkeyUtils.recoverKeyPair(RSA_KEY_PKCS8);
 
		RSAPublicKey pubKey = (RSAPublicKey) kp.getPublic();
 
		assertEquals(RSA_KEY_N, pubKey.getModulus());
		assertEquals(RSA_KEY_E, pubKey.getPublicExponent());
Full Snippet Info
6
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: getParams, getY
    } 
 
    BCDSAPublicKey( 
        DSAPublicKey key)
    { 
        this.y = key.getY();
        this.dsaSpec = key.getParams();
    } 
 
    BCDSAPublicKey( 
        DSAPublicKeyParameters params)
    { 
        this.y = params.getY();
        this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
    } 
 
    BCDSAPublicKey( 
        BigInteger y,
        DSAParameterSpec dsaSpec)
    { 
Full Snippet Info
6
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: getParams, getY
            throw new NullPointerException("key cannot be null");
        } 
        this.publicKey = key;
        if (key instanceof DSAPublicKey) {
            DSAPublicKey dkey = (DSAPublicKey) key;
            DSAParams params = dkey.getParams();
            p = new DOMCryptoBinary(params.getP());
            q = new DOMCryptoBinary(params.getQ());
            g = new DOMCryptoBinary(params.getG());
            y = new DOMCryptoBinary(dkey.getY());
        } else if (key instanceof RSAPublicKey) {
            RSAPublicKey rkey = (RSAPublicKey) key;
            exponent = new DOMCryptoBinary(rkey.getPublicExponent());
            modulus = new DOMCryptoBinary(rkey.getModulus());
        } else { 
            throw new KeyException("unsupported key algorithm: " +
                key.getAlgorithm());
        } 
    } 
 
Full Snippet Info
6
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: getParams, getY
    } 
 
    JDKDSAPublicKey( 
        DSAPublicKey    key)
    { 
        this.y = key.getY();
        this.dsaSpec = key.getParams();
    } 
 
    JDKDSAPublicKey( 
        DSAPublicKeyParameters  params)
    { 
        this.y = params.getY();
        this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
    } 
 
    JDKDSAPublicKey( 
        BigInteger        y,
        DSAParameterSpec  dsaSpec)
    { 
Full Snippet Info
6
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: getParams, getY
    { 
        if (key instanceof DSAPublicKey)
        { 
            DSAPublicKey    k = (DSAPublicKey)key;
 
            return new DSAPublicKeyParameters(k.getY(),
                new DSAParameters(k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()));
        } 
 
        throw new InvalidKeyException("can't identify DSA public key: " + key.getClass().getName());
    } 
 
    static public AsymmetricKeyParameter generatePrivateKeyParameter( 
        PrivateKey    key)
        throws InvalidKeyException
    { 
        if (key instanceof DSAPrivateKey)
        { 
            DSAPrivateKey    k = (DSAPrivateKey)key;
 
Full Snippet Info
6
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: getParams, getY
	public void testRecoverKeyPair_Dsa() throws Exception {
		KeyPair kp = PubkeyUtils.recoverKeyPair(DSA_KEY_PKCS8);
 
		DSAPublicKey pubKey = (DSAPublicKey) kp.getPublic();
 
		assertEquals(DSA_KEY_pub, pubKey.getY());
 
		DSAParams params = pubKey.getParams();
		assertEquals(params.getG(), DSA_KEY_G);
		assertEquals(params.getP(), DSA_KEY_P);
		assertEquals(params.getQ(), DSA_KEY_Q);
	} 
 
	public void testRecoverKeyPair_Rsa() throws Exception {
		KeyPair kp = PubkeyUtils.recoverKeyPair(RSA_KEY_PKCS8);
 
		RSAPublicKey pubKey = (RSAPublicKey) kp.getPublic();
 
		assertEquals(RSA_KEY_N, pubKey.getModulus());
		assertEquals(RSA_KEY_E, pubKey.getPublicExponent());
Full Snippet Info
6
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: getParams, getY
    private void dsaTest() 
        throws IOException, ClassNotFoundException 
    { 
        DSAPublicKey pub = (DSAPublicKey)readObject(dsaPub);
 
        if (!dsaY.equals(pub.getY()))
        { 
            fail("dsa public key y mismatch"); 
        } 
        if (!dsaG.equals(pub.getParams().getG()))
        { 
            fail("dsa public key g mismatch"); 
        } 
        if (!dsaP.equals(pub.getParams().getP()))
        { 
            fail("dsa public key p mismatch"); 
        } 
 
        DSAPrivateKey priv = (DSAPrivateKey)readObject(dsaPriv);
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 DSAPublicKey Methods: