Module jcifs

Class DcerpcHandle

java.lang.Object
org.codelibs.jcifs.smb.dcerpc.DcerpcHandle
All Implemented Interfaces:
AutoCloseable, DcerpcConstants
Direct Known Subclasses:
DcerpcPipeHandle

public abstract class DcerpcHandle extends Object implements DcerpcConstants, AutoCloseable
Abstract base class for DCE/RPC communication handles. This class provides the foundation for DCE/RPC client communication.
  • Constructor Details

    • DcerpcHandle

      public DcerpcHandle(CIFSContext tc)
      Constructs a DcerpcHandle with the specified CIFS context
      Parameters:
      tc - the CIFS context for this handle
    • DcerpcHandle

      public DcerpcHandle(CIFSContext tc, DcerpcBinding binding)
      Constructs a DcerpcHandle with the specified CIFS context and binding
      Parameters:
      tc - the CIFS context for this handle
      binding - the DCE/RPC binding for this connection
  • Method Details

    • parseBinding

      protected static DcerpcBinding parseBinding(String str) throws DcerpcException
      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

      public DcerpcBinding 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 URL
      tc - context to use
      Returns:
      a DCERPC handle for the given url
      Throws:
      MalformedURLException - if the URL is malformed
      DcerpcException - 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 URL
      tc - context to use
      unshared - whether an exclusive connection should be used
      Returns:
      a DCERPC handle for the given url
      Throws:
      MalformedURLException - if the URL is malformed
      DcerpcException - if there is an error establishing the connection
    • bind

      public void bind() throws DcerpcException, IOException
      Bind the handle
      Throws:
      DcerpcException - if there is a DCE/RPC protocol error
      IOException - if there is an I/O error during binding
    • sendrecv

      public void sendrecv(DcerpcMessage msg) throws DcerpcException, IOException
      Send and receive a DCE/RPC message
      Parameters:
      msg - the message to send
      Throws:
      DcerpcException - if there is a DCE/RPC protocol error
      IOException - 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 encode
      out - the output buffer for the encoded message
      Returns:
      the NdrBuffer containing the encoded message
      Throws:
      NdrException - if there is an error encoding the message
      DcerpcException - if there is a DCE/RPC protocol error
    • setDcerpcSecurityProvider

      public void setDcerpcSecurityProvider(DcerpcSecurityProvider securityProvider)
      Sets the DCERPC security provider for authentication and message protection
      Parameters:
      securityProvider - the security provider to use for DCERPC authentication
    • getServer

      public abstract String getServer()
      Gets the server hostname or address currently connected to
      Returns:
      the server connected to
    • getServerWithDfs

      public abstract String getServerWithDfs()
      Gets the server hostname resolved through DFS (Distributed File System)
      Returns:
      the server resolved by DFS
    • getTransportContext

      public abstract CIFSContext getTransportContext()
      Gets the CIFS context used for transport operations
      Returns:
      the transport context used
    • getSessionKey

      public abstract byte[] getSessionKey() throws CIFSException
      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

      public String toString()
      Overrides:
      toString in class Object
    • doSendFragment

      protected abstract void doSendFragment(byte[] buf, int off, int length) throws IOException
      Sends a DCERPC fragment to the remote endpoint
      Parameters:
      buf - the buffer containing the fragment data
      off - the offset into the buffer
      length - the length of data to send
      Throws:
      IOException - if an I/O error occurs during transmission
    • doReceiveFragment

      protected abstract int doReceiveFragment(byte[] buf) throws IOException
      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 request
      off - the offset into the outgoing buffer
      length - the length of data to send
      inB - the buffer to receive the response
      Returns:
      the number of bytes received
      Throws:
      IOException - if an I/O error occurs during the operation
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException