Module jcifs

Class Smb2CreateRequest

All Implemented Interfaces:
CommonServerMessageBlock, CommonServerMessageBlockRequest, Request<Smb2CreateResponse>, RequestWithPath, Message, Request

public class Smb2CreateRequest extends ServerMessageBlock2Request<Smb2CreateResponse> implements RequestWithPath
SMB2 Create request message. This command is used to create or open a file or directory on the server with specified access rights and sharing options.
Author:
mbechler
  • Field Details

    • SMB2_OPLOCK_LEVEL_NONE

      public static final byte SMB2_OPLOCK_LEVEL_NONE
      No oplock
      See Also:
    • SMB2_OPLOCK_LEVEL_II

      public static final byte SMB2_OPLOCK_LEVEL_II
      Level II oplock
      See Also:
    • SMB2_OPLOCK_LEVEL_EXCLUSIVE

      public static final byte SMB2_OPLOCK_LEVEL_EXCLUSIVE
      Exclusive oplock
      See Also:
    • SMB2_OPLOCK_LEVEL_BATCH

      public static final byte SMB2_OPLOCK_LEVEL_BATCH
      Batch oplock
      See Also:
    • SMB2_OPLOCK_LEVEL_LEASE

      public static final byte SMB2_OPLOCK_LEVEL_LEASE
      Lease-based oplock
      See Also:
    • SMB2_IMPERSONATION_LEVEL_ANONYMOUS

      public static final int SMB2_IMPERSONATION_LEVEL_ANONYMOUS
      Anonymous impersonation level - client cannot obtain identification information about itself
      See Also:
    • SMB2_IMPERSONATION_LEVEL_IDENTIFICATION

      public static final int SMB2_IMPERSONATION_LEVEL_IDENTIFICATION
      Identification impersonation level - server can obtain the client's identity but cannot impersonate
      See Also:
    • SMB2_IMPERSONATION_LEVEL_IMPERSONATION

      public static final int SMB2_IMPERSONATION_LEVEL_IMPERSONATION
      Impersonation level - server can impersonate the client's security context on the local system
      See Also:
    • SMB2_IMPERSONATION_LEVEL_DELEGATE

      public static final int SMB2_IMPERSONATION_LEVEL_DELEGATE
      Delegate impersonation level - server can impersonate the client's security context on remote systems
      See Also:
    • FILE_SHARE_READ

      public static final int FILE_SHARE_READ
      Enable other opens for read access
      See Also:
    • FILE_SHARE_WRITE

      public static final int FILE_SHARE_WRITE
      Enable other opens for write access
      See Also:
    • FILE_SHARE_DELETE

      public static final int FILE_SHARE_DELETE
      Enable other opens for delete access
      See Also:
    • FILE_SUPERSEDE

      public static final int FILE_SUPERSEDE
      If file exists, supersede it. Otherwise create the file
      See Also:
    • FILE_OPEN

      public static final int FILE_OPEN
      If file exists, open it. Otherwise fail
      See Also:
    • FILE_CREATE

      public static final int FILE_CREATE
      If file exists, fail. Otherwise create the file
      See Also:
    • FILE_OPEN_IF

      public static final int FILE_OPEN_IF
      If file exists, open it. Otherwise create the file
      See Also:
    • FILE_OVERWRITE

      public static final int FILE_OVERWRITE
      If file exists, overwrite it. Otherwise fail
      See Also:
    • FILE_OVERWRITE_IF

      public static final int FILE_OVERWRITE_IF
      If file exists, overwrite it. Otherwise create the file
      See Also:
    • FILE_DIRECTORY_FILE

      public static final int FILE_DIRECTORY_FILE
      File being created or opened must be a directory
      See Also:
    • FILE_WRITE_THROUGH

      public static final int FILE_WRITE_THROUGH
      Write operations go directly to persistent storage
      See Also:
    • FILE_SEQUENTIAL_ONLY

      public static final int FILE_SEQUENTIAL_ONLY
      Access to the file is sequential only
      See Also:
    • FILE_NO_IMTERMEDIATE_BUFFERING

      public static final int FILE_NO_IMTERMEDIATE_BUFFERING
      File cannot be cached or buffered at intermediate levels
      See Also:
    • FILE_SYNCHRONOUS_IO_ALERT

      public static final int FILE_SYNCHRONOUS_IO_ALERT
      All operations on the file are performed synchronously with alerts
      See Also:
    • FILE_SYNCHRONOUS_IO_NONALERT

      public static final int FILE_SYNCHRONOUS_IO_NONALERT
      All operations on the file are performed synchronously without alerts
      See Also:
    • FILE_NON_DIRECTORY_FILE

      public static final int FILE_NON_DIRECTORY_FILE
      File being created or opened must not be a directory
      See Also:
    • FILE_COMPLETE_IF_OPLOCKED

      public static final int FILE_COMPLETE_IF_OPLOCKED
      Complete this operation immediately with an oplock break if it would break an oplock
      See Also:
    • FILE_NO_EA_KNOWLEDGE

      public static final int FILE_NO_EA_KNOWLEDGE
      The client does not understand extended attributes
      See Also:
    • FILE_OPEN_REMOTE_INSTANCE

      public static final int FILE_OPEN_REMOTE_INSTANCE
      Open a remote instance of the file
      See Also:
    • FILE_RANDOM_ACCESS

      public static final int FILE_RANDOM_ACCESS
      Access to the file is random
      See Also:
    • FILE_DELETE_ON_CLOSE

      public static final int FILE_DELETE_ON_CLOSE
      Delete the file when the last handle to it is closed
      See Also:
    • FILE_OPEN_BY_FILE_ID

      public static final int FILE_OPEN_BY_FILE_ID
      Open file by its file ID
      See Also:
    • FILE_OPEN_FOR_BACKUP_INTENT

      public static final int FILE_OPEN_FOR_BACKUP_INTENT
      The file is being opened for backup intent
      See Also:
    • FILE_NO_COMPRESSION

      public static final int FILE_NO_COMPRESSION
      Disable compression on the file
      See Also:
    • FILE_OPEN_REQUIRING_OPLOCK

      public static final int FILE_OPEN_REQUIRING_OPLOCK
      The file is being opened and an oplock is being requested as an atomic operation
      See Also:
    • FILE_DISALLOW_EXCLUSIVE

      public static final int FILE_DISALLOW_EXCLUSIVE
      Any open of this file cannot be exclusive
      See Also:
    • FILE_RESERVE_OPFILTER

      public static final int FILE_RESERVE_OPFILTER
      Reserve an opportunistic lock filter on the open
      See Also:
    • FILE_OPEN_REPARSE_POINT

      public static final int FILE_OPEN_REPARSE_POINT
      Open a reparse point and bypass normal reparse point processing
      See Also:
    • FILE_NOP_RECALL

      public static final int FILE_NOP_RECALL
      Open does not cause an opportunistic lock break for the file
      See Also:
    • FILE_OPEN_FOR_FREE_SPACE_QUERY

      public static final int FILE_OPEN_FOR_FREE_SPACE_QUERY
      The file is being opened solely to query its free space
      See Also:
  • Constructor Details

    • Smb2CreateRequest

      public Smb2CreateRequest(Configuration config, String name)
      Constructs an SMB2 create request
      Parameters:
      config - the client configuration
      name - uncPath to open, strips a leading \
  • Method Details

    • createResponse

      Description copied from class: ServerMessageBlock2Request
      Create the response object for this request
      Specified by:
      createResponse in class ServerMessageBlock2Request<Smb2CreateResponse>
      Parameters:
      tc - the CIFS context
      req - the request object
      Returns:
      the response object
    • getPath

      public String getPath()
      Gets the path to the resource.
      Specified by:
      getPath in interface RequestWithPath
      Returns:
      the path to the resource (below share)
      See Also:
    • getFullUNCPath

      public String getFullUNCPath()
      Gets the full UNC path.
      Specified by:
      getFullUNCPath in interface RequestWithPath
      Returns:
      the full UNC path
      See Also:
    • getServer

      public String getServer()
      Gets the server name.
      Specified by:
      getServer in interface RequestWithPath
      Returns:
      the server name
      See Also:
    • getDomain

      public String getDomain()
      Gets the domain name.
      Specified by:
      getDomain in interface RequestWithPath
      Returns:
      the domain name
      See Also:
    • setFullUNCPath

      public void setFullUNCPath(String domain, String server, String fullName)
      Description copied from interface: RequestWithPath
      Sets the full UNC path components.
      Specified by:
      setFullUNCPath in interface RequestWithPath
      Parameters:
      fullName - the fullName to set
      domain - the domain name
      server - the server name
    • setPath

      public void setPath(String path)
      Sets the path to the resource. Strips a leading \
      Specified by:
      setPath in interface RequestWithPath
      Parameters:
      path - the path to set
      See Also:
    • setResolveInDfs

      public void setResolveInDfs(boolean resolve)
      Sets whether to resolve this request path in DFS.
      Specified by:
      setResolveInDfs in interface RequestWithPath
      Parameters:
      resolve - true to enable DFS resolution
      See Also:
    • isResolveInDfs

      public boolean isResolveInDfs()
      Checks if this request should be resolved in DFS.
      Specified by:
      isResolveInDfs in interface RequestWithPath
      Returns:
      whether to resolve the request path in DFS
      See Also:
    • setSecurityFlags

      public void setSecurityFlags(byte securityFlags)
      Set the security flags for the create request
      Parameters:
      securityFlags - the securityFlags to set
    • setRequestedOplockLevel

      public void setRequestedOplockLevel(byte requestedOplockLevel)
      Set the requested oplock level for the file
      Parameters:
      requestedOplockLevel - the requestedOplockLevel to set
    • setImpersonationLevel

      public void setImpersonationLevel(int impersonationLevel)
      Set the impersonation level for the create request
      Parameters:
      impersonationLevel - the impersonationLevel to set
    • setSmbCreateFlags

      public void setSmbCreateFlags(long smbCreateFlags)
      Set the SMB create flags
      Parameters:
      smbCreateFlags - the smbCreateFlags to set
    • setDesiredAccess

      public void setDesiredAccess(int desiredAccess)
      Set the desired access mask for the file
      Parameters:
      desiredAccess - the desiredAccess to set
    • setFileAttributes

      public void setFileAttributes(int fileAttributes)
      Set the file attributes for the created file
      Parameters:
      fileAttributes - the fileAttributes to set
    • setShareAccess

      public void setShareAccess(int shareAccess)
      Set the share access mode for the file
      Parameters:
      shareAccess - the shareAccess to set
    • setCreateDisposition

      public void setCreateDisposition(int createDisposition)
      Set the create disposition specifying what action to take if file exists or doesn't exist
      Parameters:
      createDisposition - the createDisposition to set
    • setCreateOptions

      public void setCreateOptions(int createOptions)
      Set the create options that control file creation behavior
      Parameters:
      createOptions - the createOptions to set
    • size

      public int size()
      Gets the size of this message.
      Specified by:
      size in interface CommonServerMessageBlockRequest
      Returns:
      the size of this message
      See Also:
    • writeBytesWireFormat

      protected int writeBytesWireFormat(byte[] dst, int dstIndex)
      Writes the message body to the wire format.
      Specified by:
      writeBytesWireFormat in class ServerMessageBlock2
      Parameters:
      dst - the destination buffer
      dstIndex - the starting position in the buffer
      Returns:
      number of bytes written
      See Also:
    • readBytesWireFormat

      protected int readBytesWireFormat(byte[] buffer, int bufferIndex)
      Reads the message body from the wire format.
      Specified by:
      readBytesWireFormat in class ServerMessageBlock2
      Parameters:
      buffer - the buffer to read from
      bufferIndex - the starting position in the buffer
      Returns:
      number of bytes read
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class ServerMessageBlock2