Package jcifs.internal.smb1
Class ServerMessageBlock
- java.lang.Object
-
- jcifs.internal.smb1.ServerMessageBlock
-
- All Implemented Interfaces:
CommonServerMessageBlock,CommonServerMessageBlockRequest,CommonServerMessageBlockResponse,RequestWithPath,Message,Request,Response
- Direct Known Subclasses:
AndXServerMessageBlock,SmbComBlankResponse,SmbComClose,SmbComCreateDirectory,SmbComDelete,SmbComDeleteDirectory,SmbComFindClose2,SmbComNegotiate,SmbComNegotiateResponse,SmbComNtCancel,SmbComQueryInformation,SmbComQueryInformationResponse,SmbComRename,SmbComSeek,SmbComSeekResponse,SmbComSetInformation,SmbComSetInformationResponse,SmbComTransaction,SmbComTransactionResponse,SmbComTreeDisconnect,SmbComWrite,SmbComWriteResponse
public abstract class ServerMessageBlock extends Object implements CommonServerMessageBlockRequest, CommonServerMessageBlockResponse, RequestWithPath
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedServerMessageBlock(Configuration config)protectedServerMessageBlock(Configuration config, byte command)protectedServerMessageBlock(Configuration config, byte command, String path)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddFlags2(int fl)booleanallowChain(CommonServerMessageBlockRequest next)voidclearReceived()Unset received statusCommonServerMessageBlockRequestcreateCancel()intdecode(byte[] buffer, int bufferIndex)Decode message data from the given byte arrayintencode(byte[] dst, int dstIndex)booleanequals(Object obj)voiderror()Set error statusvoidexception(Exception e)intgetByteCount()intgetCommand()protected ConfigurationgetConfig()intgetCreditCost()SMB1SigningDigestgetDigest()StringgetDomain()intgetErrorCode()ExceptiongetException()LonggetExpiration()bytegetFlags()intgetFlags2()StringgetFullUNCPath()intgetGrantedCredits()intgetLength()longgetMid()ServerMessageBlockgetNext()CommonServerMessageBlockResponsegetNextResponse()IntegergetOverrideTimeout()StringgetPath()intgetPid()byte[]getRawPayload()ServerMessageBlockgetResponse()StringgetServer()intgetSignSeq()intgetTid()intgetUid()inthashCode()CommonServerMessageBlockignoreDisconnect()booleanisAsync()booleanisCancel()booleanisError()booleanisExtendedSecurity()booleanisForceUnicode()booleanisReceived()booleanisResolveInDfs()protected booleanisResponse()booleanisResponseAsync()booleanisRetainPayload()booleanisUseUnicode()booleanisVerifyFailed()voidprepare(CommonServerMessageBlockRequest next)protected abstract intreadBytesWireFormat(byte[] buffer, int bufferIndex)protected intreadHeaderWireFormat(byte[] buffer, int bufferIndex)protected abstract intreadParameterWordsWireFormat(byte[] buffer, int bufferIndex)StringreadString(byte[] src, int srcIndex)StringreadString(byte[] src, int srcIndex, int maxLen, boolean unicode)StringreadString(byte[] src, int srcIndex, int srcEnd, int maxLen, boolean unicode)protected intreadStringLength(byte[] src, int srcIndex, int max)voidreceived()Set received statusvoidremFlags2(int fl)voidreset()voidretainPayload()Indicate that this message should retain it's raw payloadvoidsetCommand(int command)voidsetDigest(SMBSigningDigest digest)voidsetErrorCode(int errorCode)voidsetExpiration(Long exp)voidsetExtendedSecurity(boolean extendedSecurity)voidsetFlags(byte flags)voidsetFlags2(int fl)voidsetFullUNCPath(String domain, String server, String fullPath)voidsetMid(long mid)voidsetOverrideTimeout(Integer overrideTimeout)voidsetPath(String path)voidsetPid(int pid)voidsetRawPayload(byte[] rawPayload)voidsetRequestCredits(int credits)voidsetResolveInDfs(boolean resolve)voidsetResponse(CommonServerMessageBlockResponse response)voidsetSessionId(long sessionId)voidsetSignSeq(int signSeq)voidsetTid(int tid)voidsetUid(int uid)voidsetUseUnicode(boolean useUnicode)intsize()CommonServerMessageBlockRequestsplit()intstringWireLength(String str, int offset)StringtoString()booleanverifySignature(byte[] buffer, int i, int size)protected abstract intwriteBytesWireFormat(byte[] dst, int dstIndex)protected intwriteHeaderWireFormat(byte[] dst, int dstIndex)protected abstract intwriteParameterWordsWireFormat(byte[] dst, int dstIndex)protected intwriteString(String str, byte[] dst, int dstIndex)protected intwriteString(String str, byte[] dst, int dstIndex, boolean unicode)
-
-
-
Field Detail
-
SMB_COM_CREATE_DIRECTORY
public static final byte SMB_COM_CREATE_DIRECTORY
- See Also:
- Constant Field Values
-
SMB_COM_DELETE_DIRECTORY
public static final byte SMB_COM_DELETE_DIRECTORY
- See Also:
- Constant Field Values
-
SMB_COM_CLOSE
public static final byte SMB_COM_CLOSE
- See Also:
- Constant Field Values
-
SMB_COM_DELETE
public static final byte SMB_COM_DELETE
- See Also:
- Constant Field Values
-
SMB_COM_RENAME
public static final byte SMB_COM_RENAME
- See Also:
- Constant Field Values
-
SMB_COM_QUERY_INFORMATION
public static final byte SMB_COM_QUERY_INFORMATION
- See Also:
- Constant Field Values
-
SMB_COM_SET_INFORMATION
public static final byte SMB_COM_SET_INFORMATION
- See Also:
- Constant Field Values
-
SMB_COM_WRITE
public static final byte SMB_COM_WRITE
- See Also:
- Constant Field Values
-
SMB_COM_CHECK_DIRECTORY
public static final byte SMB_COM_CHECK_DIRECTORY
- See Also:
- Constant Field Values
-
SMB_COM_SEEK
public static final byte SMB_COM_SEEK
- See Also:
- Constant Field Values
-
SMB_COM_LOCKING_ANDX
public static final byte SMB_COM_LOCKING_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_TRANSACTION
public static final byte SMB_COM_TRANSACTION
- See Also:
- Constant Field Values
-
SMB_COM_TRANSACTION_SECONDARY
public static final byte SMB_COM_TRANSACTION_SECONDARY
- See Also:
- Constant Field Values
-
SMB_COM_MOVE
public static final byte SMB_COM_MOVE
- See Also:
- Constant Field Values
-
SMB_COM_ECHO
public static final byte SMB_COM_ECHO
- See Also:
- Constant Field Values
-
SMB_COM_OPEN_ANDX
public static final byte SMB_COM_OPEN_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_READ_ANDX
public static final byte SMB_COM_READ_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_WRITE_ANDX
public static final byte SMB_COM_WRITE_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_TRANSACTION2
public static final byte SMB_COM_TRANSACTION2
- See Also:
- Constant Field Values
-
SMB_COM_FIND_CLOSE2
public static final byte SMB_COM_FIND_CLOSE2
- See Also:
- Constant Field Values
-
SMB_COM_TREE_DISCONNECT
public static final byte SMB_COM_TREE_DISCONNECT
- See Also:
- Constant Field Values
-
SMB_COM_NEGOTIATE
public static final byte SMB_COM_NEGOTIATE
- See Also:
- Constant Field Values
-
SMB_COM_SESSION_SETUP_ANDX
public static final byte SMB_COM_SESSION_SETUP_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_LOGOFF_ANDX
public static final byte SMB_COM_LOGOFF_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_TREE_CONNECT_ANDX
public static final byte SMB_COM_TREE_CONNECT_ANDX
- See Also:
- Constant Field Values
-
SMB_COM_NT_TRANSACT
public static final byte SMB_COM_NT_TRANSACT
- See Also:
- Constant Field Values
-
SMB_COM_NT_CANCEL
public static final byte SMB_COM_NT_CANCEL
- See Also:
- Constant Field Values
-
SMB_COM_NT_TRANSACT_SECONDARY
public static final byte SMB_COM_NT_TRANSACT_SECONDARY
- See Also:
- Constant Field Values
-
SMB_COM_NT_CREATE_ANDX
public static final byte SMB_COM_NT_CREATE_ANDX
- See Also:
- Constant Field Values
-
headerStart
protected int headerStart
-
length
protected int length
-
batchLevel
protected int batchLevel
-
errorCode
protected int errorCode
-
flags2
protected int flags2
-
pid
protected int pid
-
uid
protected int uid
-
mid
protected int mid
-
wordCount
protected int wordCount
-
byteCount
protected int byteCount
-
tid
protected int tid
-
path
protected String path
-
digest
protected SMB1SigningDigest digest
-
-
Constructor Detail
-
ServerMessageBlock
protected ServerMessageBlock(Configuration config)
-
ServerMessageBlock
protected ServerMessageBlock(Configuration config, byte command)
-
ServerMessageBlock
protected ServerMessageBlock(Configuration config, byte command, String path)
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCommonServerMessageBlockRequest- Returns:
- the size of this message
- See Also:
CommonServerMessageBlockRequest.size()
-
isAsync
public boolean isAsync()
- Specified by:
isAsyncin interfaceCommonServerMessageBlockResponse- Returns:
- is an async response
- See Also:
CommonServerMessageBlockResponse.isAsync()
-
isResponseAsync
public boolean isResponseAsync()
- Specified by:
isResponseAsyncin interfaceCommonServerMessageBlockRequest- Returns:
- request was handled asynchronously
- See Also:
CommonServerMessageBlockRequest.isResponseAsync()
-
getOverrideTimeout
public final Integer getOverrideTimeout()
- Specified by:
getOverrideTimeoutin interfaceCommonServerMessageBlockRequest- Returns:
- custom response timeout for this request
- See Also:
CommonServerMessageBlockRequest.getOverrideTimeout()
-
setOverrideTimeout
public final void setOverrideTimeout(Integer overrideTimeout)
- Parameters:
overrideTimeout- the overrideTimeout to set
-
getNext
public ServerMessageBlock getNext()
- Specified by:
getNextin interfaceCommonServerMessageBlockRequest- Specified by:
getNextin interfaceRequest- Returns:
- next chained message
- See Also:
CommonServerMessageBlockRequest.getNext()
-
allowChain
public boolean allowChain(CommonServerMessageBlockRequest next)
- Specified by:
allowChainin interfaceCommonServerMessageBlockRequest- Returns:
- whether to allow chaining
- See Also:
CommonServerMessageBlockRequest.allowChain(jcifs.internal.CommonServerMessageBlockRequest)
-
split
public CommonServerMessageBlockRequest split()
- Specified by:
splitin interfaceCommonServerMessageBlockRequest- Returns:
- the following message
- See Also:
CommonServerMessageBlockRequest.split()
-
createCancel
public CommonServerMessageBlockRequest createCancel()
- Specified by:
createCancelin interfaceCommonServerMessageBlockRequest- Returns:
- create cancel request
- See Also:
CommonServerMessageBlockRequest.createCancel()
-
getNextResponse
public CommonServerMessageBlockResponse getNextResponse()
- Specified by:
getNextResponsein interfaceCommonServerMessageBlockResponse- Specified by:
getNextResponsein interfaceResponse- Returns:
- the next response
- See Also:
CommonServerMessageBlockResponse.getNextResponse()
-
prepare
public void prepare(CommonServerMessageBlockRequest next)
- Specified by:
preparein interfaceCommonServerMessageBlockResponse- See Also:
CommonServerMessageBlockResponse.prepare(jcifs.internal.CommonServerMessageBlockRequest)
-
getCreditCost
public int getCreditCost()
- Specified by:
getCreditCostin interfaceRequest- Returns:
- number of credits this request requires
- See Also:
Request.getCreditCost()
-
getGrantedCredits
public int getGrantedCredits()
- Specified by:
getGrantedCreditsin interfaceResponse- Returns:
- number of credits granted by the server
- See Also:
Response.getGrantedCredits()
-
setRequestCredits
public void setRequestCredits(int credits)
- Specified by:
setRequestCreditsin interfaceRequest- See Also:
Request.setRequestCredits(int)
-
getCommand
public final int getCommand()
- Specified by:
getCommandin interfaceCommonServerMessageBlock- Returns:
- the command
-
setCommand
public final void setCommand(int command)
- Specified by:
setCommandin interfaceCommonServerMessageBlock- Parameters:
command- the command to set
-
getByteCount
public final int getByteCount()
- Returns:
- the byteCount
-
getLength
public final int getLength()
- Returns:
- the length
-
isForceUnicode
public boolean isForceUnicode()
- Returns:
- the forceUnicode
-
getFlags
public final byte getFlags()
- Returns:
- the flags
-
setFlags
public final void setFlags(byte flags)
- Parameters:
flags- the flags to set
-
getFlags2
public final int getFlags2()
- Returns:
- the flags2
-
setFlags2
public final void setFlags2(int fl)
- Parameters:
fl- the flags2 to set
-
addFlags2
public final void addFlags2(int fl)
- Parameters:
fl-
-
remFlags2
public final void remFlags2(int fl)
- Parameters:
fl-
-
setResolveInDfs
public void setResolveInDfs(boolean resolve)
- Specified by:
setResolveInDfsin interfaceRequestWithPath- See Also:
RequestWithPath.setResolveInDfs(boolean)
-
isResolveInDfs
public boolean isResolveInDfs()
- Specified by:
isResolveInDfsin interfaceRequestWithPath- Returns:
- whether to resolve the request path in DFS
- See Also:
RequestWithPath.isResolveInDfs()
-
getErrorCode
public final int getErrorCode()
- Specified by:
getErrorCodein interfaceResponse- Returns:
- the errorCode
-
setErrorCode
public final void setErrorCode(int errorCode)
- Parameters:
errorCode- the errorCode to set
-
getPath
public final String getPath()
- Specified by:
getPathin interfaceRequestWithPath- Returns:
- the path
-
getFullUNCPath
public String getFullUNCPath()
- Specified by:
getFullUNCPathin interfaceRequestWithPath- Returns:
- the full UNC path
- See Also:
RequestWithPath.getFullUNCPath()
-
getDomain
public String getDomain()
- Specified by:
getDomainin interfaceRequestWithPath- Returns:
- the domain name
- See Also:
RequestWithPath.getDomain()
-
getServer
public String getServer()
- Specified by:
getServerin interfaceRequestWithPath- Returns:
- the server name
- See Also:
RequestWithPath.getServer()
-
setFullUNCPath
public void setFullUNCPath(String domain, String server, String fullPath)
- Specified by:
setFullUNCPathin interfaceRequestWithPath- See Also:
RequestWithPath.setFullUNCPath(java.lang.String, java.lang.String, java.lang.String)
-
setPath
public final void setPath(String path)
- Specified by:
setPathin interfaceRequestWithPath- Parameters:
path- the path to set
-
getDigest
public final SMB1SigningDigest getDigest()
- Specified by:
getDigestin interfaceCommonServerMessageBlock- Returns:
- the digest
-
setDigest
public final void setDigest(SMBSigningDigest digest)
- Specified by:
setDigestin interfaceCommonServerMessageBlock- Parameters:
digest- the digest to set
-
isExtendedSecurity
public boolean isExtendedSecurity()
- Returns:
- the extendedSecurity
-
setSessionId
public final void setSessionId(long sessionId)
- Specified by:
setSessionIdin interfaceCommonServerMessageBlock
-
setExtendedSecurity
public void setExtendedSecurity(boolean extendedSecurity)
- Specified by:
setExtendedSecurityin interfaceCommonServerMessageBlock- Parameters:
extendedSecurity- the extendedSecurity to set
-
isUseUnicode
public final boolean isUseUnicode()
- Returns:
- the useUnicode
-
setUseUnicode
public final void setUseUnicode(boolean useUnicode)
- Parameters:
useUnicode- the useUnicode to set
-
isReceived
public final boolean isReceived()
- Specified by:
isReceivedin interfaceResponse- Returns:
- the received
-
clearReceived
public final void clearReceived()
Description copied from interface:ResponseUnset received status- Specified by:
clearReceivedin interfaceResponse
-
received
public void received()
Set received status- Specified by:
receivedin interfaceResponse- See Also:
Response.received()
-
exception
public void exception(Exception e)
- Specified by:
exceptionin interfaceResponse- See Also:
Response.exception(java.lang.Exception)
-
error
public void error()
Set error status- Specified by:
errorin interfaceResponse- See Also:
Response.error()
-
getResponse
public ServerMessageBlock getResponse()
- Specified by:
getResponsein interfaceCommonServerMessageBlock- Specified by:
getResponsein interfaceRequest- Returns:
- the response
-
ignoreDisconnect
public CommonServerMessageBlock ignoreDisconnect()
- Returns:
- null
-
setResponse
public final void setResponse(CommonServerMessageBlockResponse response)
- Specified by:
setResponsein interfaceCommonServerMessageBlock- Parameters:
response- the response to set
-
isCancel
public boolean isCancel()
- Specified by:
isCancelin interfaceRequest- Returns:
- whether this is a cancel request
- See Also:
Request.isCancel()
-
getMid
public final long getMid()
- Specified by:
getMidin interfaceCommonServerMessageBlock- Specified by:
getMidin interfaceResponse- Returns:
- the mid
-
setMid
public final void setMid(long mid)
- Specified by:
setMidin interfaceCommonServerMessageBlock- Specified by:
setMidin interfaceResponse- Parameters:
mid- the mid to set
-
getTid
public final int getTid()
- Returns:
- the tid
-
setTid
public final void setTid(int tid)
- Specified by:
setTidin interfaceCommonServerMessageBlockRequest- Parameters:
tid- the tid to set
-
getPid
public final int getPid()
- Returns:
- the pid
-
setPid
public final void setPid(int pid)
- Parameters:
pid- the pid to set
-
getUid
public final int getUid()
- Returns:
- the uid
-
setUid
public final void setUid(int uid)
- Specified by:
setUidin interfaceCommonServerMessageBlock- Parameters:
uid- the uid to set
-
getSignSeq
public int getSignSeq()
- Returns:
- the signSeq
-
setSignSeq
public final void setSignSeq(int signSeq)
- Parameters:
signSeq- the signSeq to set
-
isVerifyFailed
public boolean isVerifyFailed()
- Specified by:
isVerifyFailedin interfaceResponse- Returns:
- the verifyFailed
-
getException
public Exception getException()
- Specified by:
getExceptionin interfaceResponse- Returns:
- an exception linked to an error
- See Also:
Response.getException()
-
isError
public boolean isError()
- Specified by:
isErrorin interfaceResponse- Returns:
- whether the response is an error
- See Also:
Response.isError()
-
getRawPayload
public byte[] getRawPayload()
- Specified by:
getRawPayloadin interfaceMessage- Returns:
- the raw response message
- See Also:
Message.getRawPayload()
-
setRawPayload
public void setRawPayload(byte[] rawPayload)
- Specified by:
setRawPayloadin interfaceMessage- See Also:
Message.setRawPayload(byte[])
-
isRetainPayload
public boolean isRetainPayload()
- Specified by:
isRetainPayloadin interfaceMessage- Returns:
- whether to retain the message payload
- See Also:
Message.isRetainPayload()
-
retainPayload
public void retainPayload()
Indicate that this message should retain it's raw payload- Specified by:
retainPayloadin interfaceMessage- See Also:
Message.retainPayload()
-
getExpiration
public Long getExpiration()
- Specified by:
getExpirationin interfaceResponse- Returns:
- the message timeout
- See Also:
Response.getExpiration()
-
setExpiration
public void setExpiration(Long exp)
- Specified by:
setExpirationin interfaceResponse- Parameters:
exp- message timeout- See Also:
Response.setExpiration(java.lang.Long)
-
getConfig
protected final Configuration getConfig()
- Returns:
- the config
-
reset
public void reset()
- Specified by:
resetin interfaceCommonServerMessageBlock- Specified by:
resetin interfaceResponse
-
verifySignature
public boolean verifySignature(byte[] buffer, int i, int size)- Specified by:
verifySignaturein interfaceResponse- Returns:
- whether signature verification is successful
- See Also:
Response.verifySignature(byte[], int, int)
-
writeString
protected int writeString(String str, byte[] dst, int dstIndex)
-
writeString
protected int writeString(String str, byte[] dst, int dstIndex, boolean unicode)
-
readString
public String readString(byte[] src, int srcIndex)
- Parameters:
src-srcIndex-- Returns:
- read string
-
readString
public String readString(byte[] src, int srcIndex, int maxLen, boolean unicode)
- Parameters:
src-srcIndex-maxLen-unicode-- Returns:
- read string
-
readString
public String readString(byte[] src, int srcIndex, int srcEnd, int maxLen, boolean unicode)
- Parameters:
src-srcIndex-srcEnd-maxLen-unicode-- Returns:
- read string
-
stringWireLength
public int stringWireLength(String str, int offset)
- Parameters:
str-offset-- Returns:
- string length
-
readStringLength
protected int readStringLength(byte[] src, int srcIndex, int max)
-
encode
public int encode(byte[] dst, int dstIndex)- Specified by:
encodein interfaceCommonServerMessageBlock- Returns:
- message length
-
decode
public int decode(byte[] buffer, int bufferIndex) throws SMBProtocolDecodingExceptionDescription copied from interface:CommonServerMessageBlockDecode message data from the given byte array- Specified by:
decodein interfaceCommonServerMessageBlock- Returns:
- message length
- Throws:
SMBProtocolDecodingException
-
writeHeaderWireFormat
protected int writeHeaderWireFormat(byte[] dst, int dstIndex)
-
readHeaderWireFormat
protected int readHeaderWireFormat(byte[] buffer, int bufferIndex)
-
isResponse
protected boolean isResponse()
-
writeParameterWordsWireFormat
protected abstract int writeParameterWordsWireFormat(byte[] dst, int dstIndex)
-
writeBytesWireFormat
protected abstract int writeBytesWireFormat(byte[] dst, int dstIndex)
-
readParameterWordsWireFormat
protected abstract int readParameterWordsWireFormat(byte[] buffer, int bufferIndex)
-
readBytesWireFormat
protected abstract int readBytesWireFormat(byte[] buffer, int bufferIndex) throws SMBProtocolDecodingException- Throws:
SMBProtocolDecodingException
-
-