Code example for PrivateKey

Methods: getAlgorithm

0
        sign(alias, password, keyStoreLocation, algo, null, false);
    } 
 
    private String getAlgorithmFromPrivateKey(PrivateKey key)
        throws SignException { 
        String keyAlgo = key.getAlgorithm().toLowerCase();
        if (keyAlgo.equals("dsa")) {
            return "dsa-sha1"; 
        } else if (keyAlgo.equals("rsa")) {
            return "rsa-sha1"; 
        } else { 
            throw new SignException("Unknown key algorithm : " + keyAlgo); 
        } 
    } 
     
    private boolean isAlgorithmMatchedWithKey(PrivateKey key, String algo) {
        String keyAlgo = key.getAlgorithm().toLowerCase();
        return algo.startsWith(keyAlgo);
    }