com.monica.javacom.ssh
Class MJCSSHHMAC

java.lang.Object
  |
  +--com.monica.javacom.ssh.MJCSSHHMAC
All Implemented Interfaces:
MJCSSHMACAlgorithm

public class MJCSSHHMAC
extends java.lang.Object
implements MJCSSHMACAlgorithm

This class provides HMAC Message Authentication as defined in RFC-2104.


Constructor Summary
MJCSSHHMAC(MJCSSHHashAlgorithm h)
          Default constructor.
 
Method Summary
 boolean authenticate(java.lang.String data, java.lang.String MAC, java.lang.String K)
          Authenticates a message String (data) with a specified MAC String (MAC) accoring to the specified shared secret String (secret).
 java.lang.String createMAC(java.lang.String data, java.lang.String K)
          Creates the Message Authentication Code for the provided String (data) according to the provided shared secret String (secret).
 java.lang.String getMACAlgorithmName()
          Returns the MJC name of the MJCSSHMACAlgorithm.
 java.lang.String getMACAlgorithmVersion()
          Returns the MJC version of the MJCSSHMACAlgorithm.
 int getMACLength()
          Return the length of the MAC in bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCSSHHMAC

public MJCSSHHMAC(MJCSSHHashAlgorithm h)
Default constructor. For HMAC to be functional, a hash algorithm is required. This has to be provided as parameter.
Parameters:
MJCSSHHashAlgorithm - h: the hash algorithm that is required by HMAC
Method Detail

getMACAlgorithmName

public java.lang.String getMACAlgorithmName()
Description copied from interface: MJCSSHMACAlgorithm
Returns the MJC name of the MJCSSHMACAlgorithm.
Specified by:
getMACAlgorithmName in interface MJCSSHMACAlgorithm
Following copied from interface: com.monica.javacom.interfaces.MJCSSHMACAlgorithm
Returns:
String: the MJC name of the MJCSSHMACAlgorithm

getMACAlgorithmVersion

public java.lang.String getMACAlgorithmVersion()
Description copied from interface: MJCSSHMACAlgorithm
Returns the MJC version of the MJCSSHMACAlgorithm.
Specified by:
getMACAlgorithmVersion in interface MJCSSHMACAlgorithm
Following copied from interface: com.monica.javacom.interfaces.MJCSSHMACAlgorithm
Returns:
String: the MJC version of the MJCSSHMACAlgorithm

createMAC

public java.lang.String createMAC(java.lang.String data,
                                  java.lang.String K)
Description copied from interface: MJCSSHMACAlgorithm
Creates the Message Authentication Code for the provided String (data) according to the provided shared secret String (secret).
Specified by:
createMAC in interface MJCSSHMACAlgorithm
Following copied from interface: com.monica.javacom.interfaces.MJCSSHMACAlgorithm
Parameters:
String - data: the data for which the MAC has to be created
String - secret: the shared secret for the MAC creation
Returns:
String: the resulting MAC

authenticate

public boolean authenticate(java.lang.String data,
                            java.lang.String MAC,
                            java.lang.String K)
Description copied from interface: MJCSSHMACAlgorithm
Authenticates a message String (data) with a specified MAC String (MAC) accoring to the specified shared secret String (secret). Returns true if Message Authentication was successful.
Specified by:
authenticate in interface MJCSSHMACAlgorithm
Following copied from interface: com.monica.javacom.interfaces.MJCSSHMACAlgorithm
Parameters:
String - data: the message body
String - MAC: the Message Authentication Code for the message body
String - secret: the shared secret for authenticating
Returns:
boolean: wether the authentication was successful or not

getMACLength

public int getMACLength()
Description copied from interface: MJCSSHMACAlgorithm
Return the length of the MAC in bytes.
Specified by:
getMACLength in interface MJCSSHMACAlgorithm
Following copied from interface: com.monica.javacom.interfaces.MJCSSHMACAlgorithm
Returns:
int: the length of the MAC in bytes