public class

SecurityUtils

extends Object
java.lang.Object
   ↳ net.schmizz.sshj.common.SecurityUtils

Class Overview

Static utility method relating to security facilities.

Summary

Constants
String BOUNCY_CASTLE Identifier for the BouncyCastle JCE provider
Fields
private static final Logger LOG
private static Boolean registerBouncyCastle
private static boolean registrationDone
private static String securityProvider
Public Constructors
SecurityUtils()
Public Methods
synchronized static Cipher getCipher(String transformation)
static String getFingerprint(PublicKey key)
Computes the fingerprint for a public key, in the standard SSH format, e.g.
synchronized static KeyAgreement getKeyAgreement(String algorithm)
Creates a new instance of KeyAgreement with the given algorithm.
synchronized static KeyFactory getKeyFactory(String algorithm)
Creates a new instance of KeyFactory with the given algorithm.
synchronized static KeyPairGenerator getKeyPairGenerator(String algorithm)
Creates a new instance of KeyPairGenerator with the given algorithm.
synchronized static Mac getMAC(String algorithm)
Create a new instance of Mac with the given algorithm.
synchronized static MessageDigest getMessageDigest(String algorithm)
Create a new instance of MessageDigest with the given algorithm.
synchronized static String getSecurityProvider()
Get the identifier for the registered security provider.
synchronized static Signature getSignature(String algorithm)
synchronized static boolean isBouncyCastleRegistered()
Attempts registering BouncyCastle as security provider if it has not been previously attempted and returns whether the registration succeeded.
synchronized static void setRegisterBouncyCastle(boolean registerBouncyCastle)
synchronized static void setSecurityProvider(String securityProvider)
Specifies the JCE security provider that should be used.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String BOUNCY_CASTLE

Identifier for the BouncyCastle JCE provider

Constant Value: "BC"

Fields

private static final Logger LOG

private static Boolean registerBouncyCastle

private static boolean registrationDone

private static String securityProvider

Public Constructors

public SecurityUtils ()

Public Methods

public static synchronized Cipher getCipher (String transformation)

Parameters
transformation
Throws
NoSuchAlgorithmException
NoSuchPaddingException
NoSuchProviderException

public static String getFingerprint (PublicKey key)

Computes the fingerprint for a public key, in the standard SSH format, e.g. "4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21"

Parameters
key The public key
Returns
  • the fingerprint
See Also

public static synchronized KeyAgreement getKeyAgreement (String algorithm)

Creates a new instance of KeyAgreement with the given algorithm.

Parameters
algorithm Key agreement algorithm
Returns
  • new instance
Throws
NoSuchProviderException
NoSuchAlgorithmException

public static synchronized KeyFactory getKeyFactory (String algorithm)

Creates a new instance of KeyFactory with the given algorithm.

Parameters
algorithm Key factory algorithm e.g. RSA, DSA
Returns
  • new instance
Throws
NoSuchProviderException
NoSuchAlgorithmException

public static synchronized KeyPairGenerator getKeyPairGenerator (String algorithm)

Creates a new instance of KeyPairGenerator with the given algorithm.

Parameters
algorithm Key pair generator algorithm
Returns
  • new instance
Throws
NoSuchProviderException
NoSuchAlgorithmException

public static synchronized Mac getMAC (String algorithm)

Create a new instance of Mac with the given algorithm.

Parameters
algorithm MAC algorithm
Returns
  • new instance
Throws
NoSuchProviderException
NoSuchAlgorithmException

public static synchronized MessageDigest getMessageDigest (String algorithm)

Create a new instance of MessageDigest with the given algorithm.

Parameters
algorithm MessageDigest algorithm name
Returns
  • new instance
Throws
NoSuchProviderException
NoSuchAlgorithmException

public static synchronized String getSecurityProvider ()

Get the identifier for the registered security provider.

Returns
  • JCE provider identifier

public static synchronized Signature getSignature (String algorithm)

Parameters
algorithm
Throws
NoSuchAlgorithmException
NoSuchProviderException

public static synchronized boolean isBouncyCastleRegistered ()

Attempts registering BouncyCastle as security provider if it has not been previously attempted and returns whether the registration succeeded.

Returns
  • whether BC registered

public static synchronized void setRegisterBouncyCastle (boolean registerBouncyCastle)

Parameters
registerBouncyCastle

public static synchronized void setSecurityProvider (String securityProvider)

Specifies the JCE security provider that should be used.

Parameters
securityProvider Identifier for the security provider