Code example for KeyFactory

Methods: generatePublicgetKeySpec

                  public String getAlgorithm() { return "DSA"; }
                  public byte[] getEncoded()   { return enc2; }
                  public String getFormat()    { return "X.509"; }
        ks = kf.getKeySpec(pubKey, X509EncodedKeySpec.class);
        try { 
            pubKey = (DSAPublicKey) kf.generatePublic((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 "generatePublic" method returns DSA public key 
     * whose algorithm is neither null nor "DSA". 
Stop searching for code, let great code find you!  Add Codota to your java IDE