Code example for KeyFactory

Methods: generatePrivategetKeySpec

                  public String getAlgorithm() { return "DSA"; }
                  public byte[] getEncoded()   { return enc2; }
                  public String getFormat()    { return "PKCS8"; }
        ks = kf.getKeySpec(prKey, PKCS8EncodedKeySpec.class);
        try { 
            prKey = (DSAPrivateKey) kf.generatePrivate((KeySpec)ks);
            fail("no InvalidKeySpecException");
        } catch (InvalidKeySpecException e) {
     * A compatibility with RI test. 
     * It checks out that if key encoding in KeySpec has correct ASN1 structure 
     * but AlgorithmIdentifier contains value that connot be translated to "DSA"   
     * the "generatePrivate" method returns DSA private key 
     * whose algorithm is neither null nor "DSA". 
Connect your IDE to all the code out there  Get Codota for Java