Constructors Summary |
---|
public Type1Message()Creates a Type-1 message using default values from the current
environment.
DEFAULT_FLAGS = NTLMSSP_NEGOTIATE_NTLM |
(Config.getBoolean("jcifs.smb.client.useUnicode", true) ?
NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM);
DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", null);
String defaultWorkstation = null;
try {
defaultWorkstation = NbtAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) { }
DEFAULT_WORKSTATION = defaultWorkstation;
this(getDefaultFlags(), getDefaultDomain(), getDefaultWorkstation());
|
public Type1Message(int flags, String suppliedDomain, String suppliedWorkstation)Creates a Type-1 message with the specified parameters.
setFlags(getDefaultFlags() | flags);
setSuppliedDomain(suppliedDomain);
if (suppliedWorkstation == null)
suppliedWorkstation = getDefaultWorkstation();
setSuppliedWorkstation(suppliedWorkstation);
|
public Type1Message(byte[] material)Creates a Type-1 message using the given raw Type-1 material.
parse(material);
|
Methods Summary |
---|
public static java.lang.String | getDefaultDomain()Returns the default domain from the current environment.
return DEFAULT_DOMAIN;
|
public static int | getDefaultFlags()Returns the default flags for a generic Type-1 message in the
current environment.
return DEFAULT_FLAGS;
|
public static java.lang.String | getDefaultWorkstation()Returns the default workstation from the current environment.
return DEFAULT_WORKSTATION;
|
public java.lang.String | getSuppliedDomain()Returns the supplied authentication domain.
return suppliedDomain;
|
public java.lang.String | getSuppliedWorkstation()Returns the supplied workstation name.
return suppliedWorkstation;
|
private void | parse(byte[] material)
for (int i = 0; i < 8; i++) {
if (material[i] != NTLMSSP_SIGNATURE[i]) {
throw new IOException("Not an NTLMSSP message.");
}
}
if (readULong(material, 8) != 1) {
throw new IOException("Not a Type 1 message.");
}
int flags = readULong(material, 12);
String suppliedDomain = null;
if ((flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED) != 0) {
byte[] domain = readSecurityBuffer(material, 16);
suppliedDomain = new String(domain, getOEMEncoding());
}
String suppliedWorkstation = null;
if ((flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED) != 0) {
byte[] workstation = readSecurityBuffer(material, 24);
suppliedWorkstation = new String(workstation, getOEMEncoding());
}
setFlags(flags);
setSuppliedDomain(suppliedDomain);
setSuppliedWorkstation(suppliedWorkstation);
|
public void | setSuppliedDomain(java.lang.String suppliedDomain)Sets the supplied authentication domain for this message.
this.suppliedDomain = suppliedDomain;
|
public void | setSuppliedWorkstation(java.lang.String suppliedWorkstation)Sets the supplied workstation name for this message.
this.suppliedWorkstation = suppliedWorkstation;
|
public byte[] | toByteArray()
try {
String suppliedDomain = getSuppliedDomain();
String suppliedWorkstation = getSuppliedWorkstation();
int flags = getFlags();
boolean hostInfo = false;
byte[] domain = new byte[0];
if (suppliedDomain != null && suppliedDomain.length() != 0) {
hostInfo = true;
flags |= NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED;
domain = suppliedDomain.toUpperCase().getBytes(
getOEMEncoding());
} else {
flags &= (NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED ^ 0xffffffff);
}
byte[] workstation = new byte[0];
if (suppliedWorkstation != null &&
suppliedWorkstation.length() != 0) {
hostInfo = true;
flags |= NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED;
workstation =
suppliedWorkstation.toUpperCase().getBytes(
getOEMEncoding());
} else {
flags &= (NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED ^
0xffffffff);
}
byte[] type1 = new byte[hostInfo ?
(32 + domain.length + workstation.length) : 16];
System.arraycopy(NTLMSSP_SIGNATURE, 0, type1, 0, 8);
writeULong(type1, 8, 1);
writeULong(type1, 12, flags);
if (hostInfo) {
writeSecurityBuffer(type1, 16, 32, domain);
writeSecurityBuffer(type1, 24, 32 + domain.length, workstation);
}
return type1;
} catch (IOException ex) {
throw new IllegalStateException(ex.getMessage());
}
|
public java.lang.String | toString()
String suppliedDomain = getSuppliedDomain();
String suppliedWorkstation = getSuppliedWorkstation();
return "Type1Message[suppliedDomain=" + (suppliedDomain == null ? "null" : suppliedDomain) +
",suppliedWorkstation=" + (suppliedWorkstation == null ? "null" : suppliedWorkstation) +
",flags=0x" + jcifs.util.Hexdump.toHexString(getFlags(), 8) + "]";
|