Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jcifs-ng latest release #2

Open
wants to merge 3 commits into
base: 1.10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="jars/jcifs-1.3.17_patch.jar"/>
<classpathentry kind="lib" path="jars/jcifs-ng-2.1.0-mod-08.jar"/>
<classpathentry kind="lib" path="jars/WrapperForSlf4j-1.0.2.jar"/>
<classpathentry kind="lib" path="jars/WrapperForSlf4j-1.7.36.jar"/>
<classpathentry kind="lib" path="jars/jcifs-ng-2.1.1-20190202-03.jar"/>
<classpathentry kind="lib" path="jars/jcifs-ng-2.1.2-20190324-01.jar"/>
<classpathentry kind="lib" path="jars/jcifs-ng-2.1.4-20200413-01.jar"/>
<classpathentry kind="lib" path="jars/jcifsngLatest.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/bin/
.classpath
.project
Binary file removed jars/WrapperForSlf4j-1.0.2.jar
Binary file not shown.
Binary file added jars/WrapperForSlf4j-1.7.36.jar
Binary file not shown.
Binary file modified jars/jcifs-1.3.17_patch.jar
Binary file not shown.
Binary file added jars/jcifsngLatest.jar
Binary file not shown.
93 changes: 90 additions & 3 deletions src/com/sentaroh/jcifs/JcifsAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public class JcifsAuth {
final static public int JCIFS_FILE_SMB211 = 3;
final static public int JCIFS_FILE_SMB212 = 4;
final static public int JCIFS_FILE_SMB214 = 5;
private jcifs.smb.NtlmPasswordAuthentication mSmb1Auth = null;
final static public int JCIFS_FILE_SMB_LATEST = 6;
private jcifs13.smb.NtlmPasswordAuthentication mSmb1Auth = null;
private jcifsng.CIFSContext mSmb201Auth = null;
private jcifsng211.CIFSContext mSmb211Auth = null;
private jcifsng212.CIFSContext mSmb212Auth = null;
private jcifsng214.CIFSContext mSmb214Auth = null;
private jcifs.CIFSContext mSmbLatestAuth = null;
private int mSmbLevel = JCIFS_FILE_SMB1;

private String mDomain = null, mUserName = null, mUserPass = null;
Expand All @@ -56,7 +58,7 @@ public JcifsAuth(int smb_level, String domain, String user, String pass) {
mUserName = user;
mUserPass = pass;
if (mSmbLevel==JCIFS_FILE_SMB1) {
mSmb1Auth = new jcifs.smb.NtlmPasswordAuthentication(domain, user, pass);
mSmb1Auth = new jcifs13.smb.NtlmPasswordAuthentication(domain, user, pass);
} else if (mSmbLevel==JCIFS_FILE_SMB201) {
try {
Properties prop = new Properties();
Expand Down Expand Up @@ -101,6 +103,17 @@ public JcifsAuth(int smb_level, String domain, String user, String pass) {
} catch (jcifsng214.CIFSException e) {
e.printStackTrace();
}
} else if (mSmbLevel==JCIFS_FILE_SMB_LATEST) {
try {
Properties prop = new Properties();
prop.setProperty("jcifs.smb.client.minVersion", "SMB202");
prop.setProperty("jcifs.smb.client.maxVersion", "SMB311");
jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop));
jcifs.smb.NtlmPasswordAuthentication creds = new jcifs.smb.NtlmPasswordAuthentication(bc, domain, user, pass);
mSmbLatestAuth = bc.withCredentials(creds);
} catch (jcifs.CIFSException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -178,6 +191,21 @@ public JcifsAuth(int smb_level, String domain, String user, String pass, boolean
} catch (jcifsng214.CIFSException e) {
e.printStackTrace();
}
} else if (mSmbLevel==JCIFS_FILE_SMB_LATEST) {
try {
Properties prop = new Properties();
if (ipc_signing_enforced) prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "true");
else prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "false");

prop.setProperty("jcifs.smb.client.minVersion", "SMB202");
prop.setProperty("jcifs.smb.client.maxVersion", "SMB311");

jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop));
jcifs.smb.NtlmPasswordAuthentication creds = new jcifs.smb.NtlmPasswordAuthentication(bc, domain, user, pass);
mSmbLatestAuth = bc.withCredentials(creds);
} catch (jcifs.CIFSException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -262,6 +290,24 @@ public JcifsAuth(int smb_level, String domain, String user, String pass, boolean
} catch (jcifsng214.CIFSException e) {
e.printStackTrace();
}
} if (isSmbLatest()) {
try {
Properties prop = new Properties();
if (ipc_signing_enforced) prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "true");
else prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "false");

if (use_smb2_nego) prop.setProperty("jcifs.smb.client.useSMB2Negotiation", "true");
else prop.setProperty("jcifs.smb.client.useSMB2Negotiation", "false");

prop.setProperty("jcifs.smb.client.minVersion", "SMB202");
prop.setProperty("jcifs.smb.client.maxVersion", "SMB311");

jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop));
jcifs.smb.NtlmPasswordAuthentication creds = new jcifs.smb.NtlmPasswordAuthentication(bc, domain, user, pass);
mSmbLatestAuth = bc.withCredentials(creds);
} catch (jcifs.CIFSException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -345,6 +391,23 @@ public JcifsAuth(int smb_level, String domain, String user, String pass, boolean
} catch (jcifsng214.CIFSException e) {
e.printStackTrace();
}
} if (isSmbLatest()) {
try {
if (ipc_signing_enforced) prop_new.setProperty("jcifs.smb.client.ipcSigningEnforced", "true");
else prop_new.setProperty("jcifs.smb.client.ipcSigningEnforced", "false");

if (use_smb2_nego) prop_new.setProperty("jcifs.smb.client.useSMB2Negotiation", "true");
else prop_new.setProperty("jcifs.smb.client.useSMB2Negotiation", "false");

prop_new.setProperty("jcifs.smb.client.minVersion", "SMB202");
prop_new.setProperty("jcifs.smb.client.maxVersion", "SMB311");

jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop_new));
jcifs.smb.NtlmPasswordAuthentication creds = new jcifs.smb.NtlmPasswordAuthentication(bc, domain, user, pass);
mSmbLatestAuth = bc.withCredentials(creds);
} catch (jcifs.CIFSException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -428,6 +491,22 @@ public JcifsAuth(int smb_level, String domain, String user, String pass, boolean
} catch (jcifsng214.CIFSException e) {
e.printStackTrace();
}
} else if (isSmbLatest()) {
try {
Properties prop = new Properties();
if (ipc_signing_enforced)
prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "true");
else prop.setProperty("jcifs.smb.client.ipcSigningEnforced", "false");
prop.setProperty("jcifs.smb.client.useSMB2Negotiation", "true");
prop.setProperty("jcifs.smb.client.minVersion", min_version);
prop.setProperty("jcifs.smb.client.maxVersion", max_version);

jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop));
jcifs.smb.NtlmPasswordAuthentication creds = new jcifs.smb.NtlmPasswordAuthentication(bc, domain, user, pass);
mSmbLatestAuth = bc.withCredentials(creds);
} catch (jcifs.CIFSException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -455,7 +534,11 @@ public boolean isSmb214() {
return mSmbLevel==JCIFS_FILE_SMB214;
}

public jcifs.smb.NtlmPasswordAuthentication getSmb1Auth() {
public boolean isSmbLatest() {
return mSmbLevel==JCIFS_FILE_SMB_LATEST;
}

public jcifs13.smb.NtlmPasswordAuthentication getSmb1Auth() {
return mSmb1Auth;
}

Expand All @@ -475,6 +558,10 @@ public jcifsng214.CIFSContext getSmb214Auth() {
return mSmb214Auth;
}

public jcifs.CIFSContext getSmbLatestAuth() {
return mSmbLatestAuth;
}

public String getDomain() {
return mDomain;
}
Expand Down
Loading