public abstract class AbstractMessage
extends java.lang.Object
implements java.lang.Cloneable
Constructor and Description |
---|
AbstractMessage() |
AbstractMessage(int opCode) |
Modifier and Type | Method and Description |
---|---|
void |
clearBuffers()
Removed all cached copies of the encoded message.
|
protected AbstractMessage |
clone() |
byte[] |
getEncodedMessage()
Get the encoded value of this message.
|
byte[] |
getEncodedMessageBody()
Encode (if necessary) and retrieve the header and body portion of this
message.
|
static java.lang.String |
getResponseCodeMessage(int responseCode) |
boolean |
hasEqualOrGreaterVersion(int majorVersion,
int minorVersion)
Return true if the major and minor version of this message is equal to or
greater than the given major/minor versions.
|
static boolean |
hasEqualOrGreaterVersion(int majorProtocolVersion,
int minorProtocolVersion,
int majorVersion,
int minorVersion) |
void |
setSupportedProtocolVersion() |
void |
setSupportedProtocolVersion(AbstractMessage message) |
void |
setSupportedProtocolVersion(SiteInfo site) |
boolean |
shouldEncrypt() |
boolean |
signatureIsMac() |
void |
signMessage(byte[] secretKey)
Generate a MAC code with a given secretKey.
|
void |
signMessage(java.security.Signature signer)
Generate a signature for this message using the given Signature object.
|
void |
takeValuesFrom(AbstractMessage msg)
Takes the request parameters (certify, cacheCertify, authoritative, and
encrypt) from the given request object.
|
java.lang.String |
toString() |
boolean |
verifyMessage(byte[] secretKey)
Validate the signature for this message.
|
boolean |
verifyMessage(java.security.PublicKey pubKey)
Validate the signature for this message.
|
public static final int OC_RESERVED
public static final int OC_RESOLUTION
public static final int OC_GET_SITE_INFO
public static final int OC_CREATE_HANDLE
public static final int OC_DELETE_HANDLE
public static final int OC_ADD_VALUE
public static final int OC_REMOVE_VALUE
public static final int OC_MODIFY_VALUE
public static final int OC_LIST_HANDLES
public static final int OC_RESPONSE_TO_CHALLENGE
public static final int OC_VERIFY_CHALLENGE
public static final int OC_HOME_NA
public static final int OC_UNHOME_NA
public static final int OC_LIST_HOMED_NAS
public static final int OC_SESSION_SETUP
public static final int OC_SESSION_TERMINATE
public static final int OC_SESSION_EXCHANGEKEY
public static final int OC_GET_NEXT_TXN_ID
public static final int OC_RETRIEVE_TXN_LOG
public static final int OC_DUMP_HANDLES
public static final int OC_BACKUP_SERVER
public static final int RC_RESERVED
public static final int RC_SUCCESS
public static final int RC_ERROR
public static final int RC_SERVER_TOO_BUSY
public static final int RC_PROTOCOL_ERROR
public static final int RC_OPERATION_NOT_SUPPORTED
public static final int RC_RECURSION_COUNT_TOO_HIGH
public static final int RC_SERVER_BACKUP
public static final int RC_HANDLE_NOT_FOUND
public static final int RC_HANDLE_ALREADY_EXISTS
public static final int RC_INVALID_HANDLE
public static final int RC_VALUES_NOT_FOUND
public static final int RC_VALUE_ALREADY_EXISTS
public static final int RC_INVALID_VALUE
public static final int RC_OUT_OF_DATE_SITE_INFO
public static final int RC_SERVER_NOT_RESP
public static final int RC_SERVICE_REFERRAL
public static final int RC_PREFIX_REFERRAL
public static final int RC_INVALID_ADMIN
public static final int RC_INSUFFICIENT_PERMISSIONS
public static final int RC_AUTHENTICATION_NEEDED
public static final int RC_AUTHENTICATION_FAILED
public static final int RC_INVALID_CREDENTIAL
public static final int RC_AUTHEN_TIMEOUT
public static final int RC_AUTHEN_ERROR
public static final int RC_SESSION_TIMEOUT
public static final int RC_SESSION_FAILED
public static final int RC_INVALID_SESSION_KEY
public static final int RC_NEED_RSAKEY_FOR_SESSIONEXCHANGE
public static final int RC_INVALID_SESSIONSETUP_REQUEST
public static final int RC_SESSION_MESSAGE_REJECTED
public int requestId
public int sessionId
public byte majorProtocolVersion
public byte minorProtocolVersion
public byte suggestMajorProtocolVersion
public byte suggestMinorProtocolVersion
public int opCode
public int responseCode
public int siteInfoSerial
public int expiration
public short recursionCount
public boolean certify
public boolean cacheCertify
public boolean authoritative
public boolean encrypt
public boolean ignoreRestrictedValues
public boolean returnRequestDigest
public boolean recursive
public boolean continuous
public boolean keepAlive
public boolean overwriteWhenExists
public boolean mintNewSuffix
public boolean doNotRefer
public byte[] signerHdl
public int signerHdlIdx
public byte[] messageBody
public byte[] signature
public byte[] encodedMessage
public byte[] requestDigest
public byte rdHashType
public int sessionCounter
public AbstractMessage()
public AbstractMessage(int opCode)
protected AbstractMessage clone()
clone
in class java.lang.Object
public void setSupportedProtocolVersion(AbstractMessage message)
public void setSupportedProtocolVersion(SiteInfo site)
public void setSupportedProtocolVersion()
public boolean hasEqualOrGreaterVersion(int majorVersion, int minorVersion)
public static boolean hasEqualOrGreaterVersion(int majorProtocolVersion, int minorProtocolVersion, int majorVersion, int minorVersion)
public void takeValuesFrom(AbstractMessage msg)
public final void signMessage(byte[] secretKey) throws HandleException
Credential section (including signature) within each message: Version octet (always be 0) Reserved octet (set to 0) Flags int2 Signer Handle 0 length UTF8 string index was sesion id (speicified in message envelop) ... replaced by session counter SignatureType UTF8String (the handle type of the signature - HS_MAC) SignatureLength int4 (length of signature section) SignatureSection (the bytes of the signature, dependent on SignatureType) SignatureSection for MAC signatures: DigestAlg UTF8String (e.g. SHA-1) ContentInfo int4, signedData (version <= 2.4: Hash onCall verifyMessage(byte[] secretKey) to verify. Also see method signMessage(Signature signer), signMessage(PrivateKey key).; version >= 2.5, int4 sessionCounter follower by Hash on session key + protocolMajorVersion + protocolMinorVersion + session id + request id + session counter + message header + message body + session key)
HandleException
public final void signMessage(java.security.Signature signer) throws HandleException, java.security.SignatureException
Credential section (including signature) within each message: Version octet (always be 0) Reserved octet (set to 0) Flags int2 Signer HdlValueRef (place holder in hdl authentication) (note: HdlValueRef: UTF8String:int4) SignatureType UTF8String (the handle type of the signature - HS_SIGNED, etc) SignatureLength int4 (length of signature section) SignatureSection (the bytes of the signature, dependent on SignatureType) SignatureSection for HS_SIGNED signatures: DigestAlg UTF8String (e.g. SHA-1) ContentInfo int4, signedData
HandleException
java.security.SignatureException
public boolean signatureIsMac() throws HandleException
HandleException
public final boolean verifyMessage(byte[] secretKey) throws java.lang.Exception
java.lang.Exception
public final boolean verifyMessage(java.security.PublicKey pubKey) throws java.lang.Exception
java.lang.Exception
public boolean shouldEncrypt()
public void clearBuffers()
public final byte[] getEncodedMessageBody() throws HandleException
HandleException
public final byte[] getEncodedMessage() throws HandleException
HandleException
public java.lang.String toString()
toString
in class java.lang.Object
public static final java.lang.String getResponseCodeMessage(int responseCode)