Skip to content
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
6 changes: 3 additions & 3 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<classpath>
<classpathentry kind="src" path="src"/>
<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.6-20201207-01.jar"/>
<classpathentry kind="lib" path="jars/jcifs13-1.3.19.jar"/>
<classpathentry kind="lib" path="jars/jcifsng-latest.jar"/>
<classpathentry kind="src" path="/JcifsFile"/>
<classpathentry kind="lib" path="jars/WrapperForSlf4j-1.0.2.jar"/>
<classpathentry kind="lib" path="jars/WrapperForSlf4j-1.7.36.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/bin/
/bin/com/
#/jars/
Binary file added bin/JcifsFile2-1.0.9.jar
Binary file not shown.
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 removed jars/jcifs-1.3.17_patch.jar
Binary file not shown.
Binary file removed jars/jcifs-ng-2.1.6-20201207-01.jar
Binary file not shown.
Binary file added jars/jcifs13-1.3.19.jar
Binary file not shown.
Binary file added jars/jcifsng-latest.jar
Binary file not shown.
24 changes: 14 additions & 10 deletions src/com/sentaroh/android/JcifsFile2/JcifsAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ this software and associated documentation files (the "Software"), to deal
public class JcifsAuth {
final static public String JCIFS_FILE_SMB1 = "SMBv1";
final static public String JCIFS_FILE_SMB23 = "SMBv2/3";
private jcifs.smb.NtlmPasswordAuthentication mSmb1Auth = null;
private jcifsng.CIFSContext mSmb23Auth = null;

final static public String SMB_CLIENT_MIN_VERSION = "SMB202"; //prop jcifs.smb.client.minVersion
final static public String SMB_CLIENT_MAX_VERSION = "SMB311"; //prop jcifs.smb.client.maxVersion

private jcifs13.smb.NtlmPasswordAuthentication mSmb1Auth = null;
private jcifs.CIFSContext mSmb23Auth = null;
private String mSmbLevel = JCIFS_FILE_SMB23;

private String mDomain = null, mUserName = null, mUserPass = null;
Expand All @@ -44,7 +48,7 @@ public class JcifsAuth {
* @throws JcifsException
*/
public JcifsAuth(String smb_level, String domain, String user, String pass) throws JcifsException {
init_type(smb_level, domain, user, pass, "SMB202", "SMB311", new Properties());
init_type(smb_level, domain, user, pass, SMB_CLIENT_MIN_VERSION, SMB_CLIENT_MAX_VERSION, new Properties());
}

/**
Expand All @@ -58,7 +62,7 @@ public JcifsAuth(String smb_level, String domain, String user, String pass) thro
* @throws JcifsException
*/
public JcifsAuth(String smb_level, String domain, String user, String pass, Properties prop) throws JcifsException {
init_type(smb_level, domain, user, pass, "SMB202", "SMB311", prop);
init_type(smb_level, domain, user, pass, SMB_CLIENT_MIN_VERSION, SMB_CLIENT_MAX_VERSION, prop);
}

/**
Expand Down Expand Up @@ -98,17 +102,17 @@ private void init_type(String smb_level, String domain, String user, String pass
mUserName = user;
mUserPass = pass;
if (isSmb1()) {
mSmb1Auth = new jcifs.smb.NtlmPasswordAuthentication(domain, user, pass);
mSmb1Auth = new jcifs13.smb.NtlmPasswordAuthentication(domain, user, pass);
} else if (isSmb23()) {
try {
Properties prop_new = new Properties(prop);
prop_new.setProperty("jcifs.smb.client.minVersion", min_version);
prop_new.setProperty("jcifs.smb.client.maxVersion", max_version);

jcifsng.context.BaseContext bc = new jcifsng.context.BaseContext(new jcifsng.config.PropertyConfiguration(prop_new));
jcifsng.smb.NtlmPasswordAuthenticator creds = new jcifsng.smb.NtlmPasswordAuthenticator(domain, user, pass);
jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(prop_new));
jcifs.smb.NtlmPasswordAuthenticator creds = new jcifs.smb.NtlmPasswordAuthenticator(domain, user, pass);
mSmb23Auth = bc.withCredentials(creds);
} catch (jcifsng.CIFSException e) {
} catch (jcifs.CIFSException e) {
e.printStackTrace();
throw new JcifsException(e, -1, e.getCause());
}
Expand All @@ -130,11 +134,11 @@ public boolean isSmb23() {
return mSmbLevel.equals(JCIFS_FILE_SMB23);
}

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

public jcifsng.CIFSContext getSmb214Auth() {
public jcifs.CIFSContext getSmb214Auth() {
return mSmb23Auth;
}

Expand Down
104 changes: 52 additions & 52 deletions src/com/sentaroh/android/JcifsFile2/JcifsFile.java

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/com/sentaroh/android/JcifsFile2/JcifsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final static public String getSmbHostIpAddressByHostName(String smb_level, Strin
final static private String getSmbHostIpAddressFromNameSmb1(String hn) {
String ipAddress = null;
try {
jcifs.netbios.NbtAddress nbtAddress = jcifs.netbios.NbtAddress.getByName(hn);
jcifs13.netbios.NbtAddress nbtAddress = jcifs13.netbios.NbtAddress.getByName(hn);
InetAddress address = nbtAddress.getInetAddress();
ipAddress = address.getHostAddress();
} catch (UnknownHostException e) {
Expand All @@ -93,11 +93,11 @@ final static private String getSmbHostIpAddressFromNameSmb1(String hn) {
final static private String getSmbHostIpAddressFromNameSmb23(String hn) {
String ipAddress = null;
try {
jcifsng.context.BaseContext bc = new jcifsng.context.BaseContext(new jcifsng.config.PropertyConfiguration(System.getProperties()));
jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(System.getProperties()));
ipAddress = bc.getNameServiceClient().getByName(hn).getHostAddress();
} catch (UnknownHostException e) {
log.error("getSmbHostIpAddressFromNameSmb23 UnknownHostException", e);
} catch (jcifsng.CIFSException e) {
} catch (jcifs.CIFSException e) {
log.error("getSmbHostIpAddressFromNameSmb23 CIFSException", e);
} catch (Exception e) {
log.error("getSmbHostIpAddressFromNameSmb23 Exception", e);
Expand Down Expand Up @@ -133,10 +133,10 @@ final static public String getSmbHostNameByAddress(String smb_level, String addr
final static private String getSmbHostNameFromAddressSmb1(String address) {
String srv_name = "";
try {
jcifs.netbios.NbtAddress[] uax = jcifs.netbios.NbtAddress.getAllByAddress(address);
jcifs13.netbios.NbtAddress[] uax = jcifs13.netbios.NbtAddress.getAllByAddress(address);
if (uax != null) {
for (int i = 0; i < uax.length; i++) {
jcifs.netbios.NbtAddress ua = uax[i];
jcifs13.netbios.NbtAddress ua = uax[i];
String hn;
hn = ua.firstCalledName();
if (ua.getNameType() == 32) {
Expand All @@ -156,11 +156,11 @@ final static private String getSmbHostNameFromAddressSmb1(String address) {
final static private String getSmbHostNameFromAddressSmb23(String address) {
String srv_name = "";
try {
jcifsng.context.BaseContext bc = new jcifsng.context.BaseContext(new jcifsng.config.PropertyConfiguration(System.getProperties()));
jcifsng.NetbiosAddress[] uax = bc.getNameServiceClient().getNbtAllByAddress(address);
jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(System.getProperties()));
jcifs.NetbiosAddress[] uax = bc.getNameServiceClient().getNbtAllByAddress(address);
if (uax != null) {
for (int i = 0; i < uax.length; i++) {
jcifsng.NetbiosAddress ua = uax[i];
jcifs.NetbiosAddress ua = uax[i];
String hn;
hn = ua.firstCalledName();
if (ua.getNameType() == 32) {
Expand All @@ -171,7 +171,7 @@ final static private String getSmbHostNameFromAddressSmb23(String address) {
}
} catch (UnknownHostException e) {
log.error("getSmbHostNameFromAddressSmb23 UnknownHostException", e);
} catch (jcifsng.CIFSException e) {
} catch (jcifs.CIFSException e) {
log.error("getSmbHostNameFromAddressSmb23 CIFSException", e);
} catch (Exception e) {
log.error("getSmbHostNameFromAddressSmb23 Exception", e);
Expand All @@ -191,7 +191,7 @@ final static public boolean isNetbiosAddress(String smb_level, String address) {
final static private boolean isNbtAddressActiveSmb1(String address) {
boolean result = false;
try {
jcifs.netbios.NbtAddress na = jcifs.netbios.NbtAddress.getByName(address);
jcifs13.netbios.NbtAddress na = jcifs13.netbios.NbtAddress.getByName(address);
result = na.isActive();
} catch (UnknownHostException e) {
log.error("isNbtAddressActiveSmb1 UnknownHostException", e);
Expand All @@ -204,12 +204,12 @@ final static private boolean isNbtAddressActiveSmb1(String address) {
final static private boolean isNbtAddressActiveSmb214(String address) {
boolean result = false;
try {
jcifsng.context.BaseContext bc = new jcifsng.context.BaseContext(new jcifsng.config.PropertyConfiguration(System.getProperties()));
jcifsng.NetbiosAddress na = bc.getNameServiceClient().getNbtByName(address);
jcifs.context.BaseContext bc = new jcifs.context.BaseContext(new jcifs.config.PropertyConfiguration(System.getProperties()));
jcifs.NetbiosAddress na = bc.getNameServiceClient().getNbtByName(address);
result = na.isActive(bc);
} catch (UnknownHostException e) {
log.error("isNbtAddressActiveSmb2 UnknownHostException", e);
} catch (jcifsng.CIFSException e) {
} catch (jcifs.CIFSException e) {
log.error("isNbtAddressActiveSmb2 CIFSException", e);
} catch (Exception e) {
log.error("isNbtAddressActiveSmb2 Exception", e);
Expand Down