java.lang.Object
org.codelibs.jcifs.smb.dcerpc.DcerpcHandle
- All Implemented Interfaces:
AutoCloseable,DcerpcConstants
- Direct Known Subclasses:
DcerpcPipeHandle
Abstract base class for DCE/RPC communication handles.
This class provides the foundation for DCE/RPC client communication.
-
Field Summary
Fields inherited from interface org.codelibs.jcifs.smb.dcerpc.DcerpcConstants
DCERPC_CONC_MPX, DCERPC_DID_NOT_EXECUTE, DCERPC_FIRST_FRAG, DCERPC_LAST_FRAG, DCERPC_MAYBE, DCERPC_OBJECT_UUID, DCERPC_PENDING_CANCEL, DCERPC_RESERVED_1, DCERPC_UUID_SYNTAX_NDR, RPC_C_PF_BROADCAST, RPC_C_PF_BROADCAST_MAYBE, RPC_C_PF_IDEMPOTENT, RPC_C_PF_MAYBE, RPC_C_PF_NO_AUTO_LISTEN, RPC_C_PF_NO_AUTO_RETRY, RPC_C_PF_NO_FRAGMENT, RPC_C_PF_NOT_IDEMPOTENT, RPC_PT_ACK, RPC_PT_ALTER_CONTEXT, RPC_PT_ALTER_CONTEXT_RESPONSE, RPC_PT_BIND, RPC_PT_BIND_ACK, RPC_PT_BIND_NAK, RPC_PT_CANCEL, RPC_PT_CO_CANCEL, RPC_PT_FAULT, RPC_PT_ORPHANED, RPC_PT_PING, RPC_PT_REJECT, RPC_PT_REQUEST, RPC_PT_RESPONSE, RPC_PT_SHUTDOWN -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a DcerpcHandle with the specified CIFS contextDcerpcHandle(CIFSContext tc, DcerpcBinding binding) Constructs a DcerpcHandle with the specified CIFS context and binding -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()Bind the handlevoidclose()protected abstract intdoReceiveFragment(byte[] buf) Receives a DCERPC fragment from the remote endpointprotected abstract voiddoSendFragment(byte[] buf, int off, int length) Sends a DCERPC fragment to the remote endpointprotected abstract intdoSendReceiveFragment(byte[] out, int off, int length, byte[] inB) Sends a DCERPC fragment and receives the response in a single operationprotected NdrBufferencodeMessage(DcerpcMessage msg, byte[] out) Encode a DCE/RPC message for transmissionReturns the DCE/RPC binding for this handlestatic DcerpcHandlegetHandle(String url, CIFSContext tc) Get a handle to a servicestatic DcerpcHandlegetHandle(String url, CIFSContext tc, boolean unshared) Get a handle to a serviceabstract StringGets the server hostname or address currently connected toabstract StringGets the server hostname resolved through DFS (Distributed File System)abstract byte[]Gets the session key from the underlying SMB session for encryptionabstract CIFSContextGets the CIFS context used for transport operationsprotected static DcerpcBindingparseBinding(String str) Parses a DCERPC binding string into a DcerpcBinding objectvoidsendrecv(DcerpcMessage msg) Send and receive a DCE/RPC messagevoidsetDcerpcSecurityProvider(DcerpcSecurityProvider securityProvider) Sets the DCERPC security provider for authentication and message protectiontoString()
-
Constructor Details
-
DcerpcHandle
Constructs a DcerpcHandle with the specified CIFS context- Parameters:
tc- the CIFS context for this handle
-
DcerpcHandle
Constructs a DcerpcHandle with the specified CIFS context and binding- Parameters:
tc- the CIFS context for this handlebinding- the DCE/RPC binding for this connection
-
-
Method Details
-
parseBinding
Parses a DCERPC binding string into a DcerpcBinding object- Parameters:
str- the binding string to parse- Returns:
- the parsed DcerpcBinding object
- Throws:
DcerpcException- if the binding string is malformed
-
getBinding
Returns the DCE/RPC binding for this handle- Returns:
- the binding
-
getHandle
public static DcerpcHandle getHandle(String url, CIFSContext tc) throws MalformedURLException, DcerpcException Get a handle to a service- Parameters:
url- the DCE/RPC service URLtc- context to use- Returns:
- a DCERPC handle for the given url
- Throws:
MalformedURLException- if the URL is malformedDcerpcException- if there is an error establishing the connection
-
getHandle
public static DcerpcHandle getHandle(String url, CIFSContext tc, boolean unshared) throws MalformedURLException, DcerpcException Get a handle to a service- Parameters:
url- the DCE/RPC service URLtc- context to useunshared- whether an exclusive connection should be used- Returns:
- a DCERPC handle for the given url
- Throws:
MalformedURLException- if the URL is malformedDcerpcException- if there is an error establishing the connection
-
bind
Bind the handle- Throws:
DcerpcException- if there is a DCE/RPC protocol errorIOException- if there is an I/O error during binding
-
sendrecv
Send and receive a DCE/RPC message- Parameters:
msg- the message to send- Throws:
DcerpcException- if there is a DCE/RPC protocol errorIOException- if there is an I/O error during communication
-
encodeMessage
protected NdrBuffer encodeMessage(DcerpcMessage msg, byte[] out) throws NdrException, DcerpcException Encode a DCE/RPC message for transmission- Parameters:
msg- the message to encodeout- the output buffer for the encoded message- Returns:
- the NdrBuffer containing the encoded message
- Throws:
NdrException- if there is an error encoding the messageDcerpcException- if there is a DCE/RPC protocol error
-
setDcerpcSecurityProvider
Sets the DCERPC security provider for authentication and message protection- Parameters:
securityProvider- the security provider to use for DCERPC authentication
-
getServer
Gets the server hostname or address currently connected to- Returns:
- the server connected to
-
getServerWithDfs
Gets the server hostname resolved through DFS (Distributed File System)- Returns:
- the server resolved by DFS
-
getTransportContext
Gets the CIFS context used for transport operations- Returns:
- the transport context used
-
getSessionKey
Gets the session key from the underlying SMB session for encryption- Returns:
- session key of the underlying smb session
- Throws:
CIFSException- if unable to retrieve the session key
-
toString
-
doSendFragment
Sends a DCERPC fragment to the remote endpoint- Parameters:
buf- the buffer containing the fragment dataoff- the offset into the bufferlength- the length of data to send- Throws:
IOException- if an I/O error occurs during transmission
-
doReceiveFragment
Receives a DCERPC fragment from the remote endpoint- Parameters:
buf- the buffer to receive the fragment data- Returns:
- the number of bytes received
- Throws:
IOException- if an I/O error occurs during reception
-
doSendReceiveFragment
protected abstract int doSendReceiveFragment(byte[] out, int off, int length, byte[] inB) throws IOException Sends a DCERPC fragment and receives the response in a single operation- Parameters:
out- the outgoing buffer containing the requestoff- the offset into the outgoing bufferlength- the length of data to sendinB- the buffer to receive the response- Returns:
- the number of bytes received
- Throws:
IOException- if an I/O error occurs during the operation
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-