Code example for PrivateKey

Methods: getAlgorithm

0
 
  /** 
   * Returns the signature algorithm to be used for the provided private key. 
   */ 
  private static SignatureAlgorithm getSigAlg(PrivateKey key) {
    String algorithm = key.getAlgorithm();
    if ("dsa".equalsIgnoreCase(algorithm)) {
      return SignatureAlgorithm.DSA_SHA1;
    } else if ("rsa".equalsIgnoreCase(algorithm)) {
      return SignatureAlgorithm.RSA_SHA1;
    } else { 
      throw new IllegalArgumentException("Unknown algorithm in private key.");
    } 
  } 
 
 
  /** 
   * Returns the URL to use to exchange the one-time-use token for 
   * a session token. 
   *