diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/DropboxV2AppFolderStorage.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/DropboxV2AppFolderStorage.java new file mode 100644 index 00000000..b7112c1d --- /dev/null +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/DropboxV2AppFolderStorage.java @@ -0,0 +1,30 @@ +package keepass2android.javafilestorage; + +import android.content.Context; + +/** + * Created by Philipp on 22.11.2016. + */ +public class DropboxV2AppFolderStorage extends DropboxV2Storage{ + + public DropboxV2AppFolderStorage(Context ctx, String _appKey, + String _appSecret) { + super(ctx, _appKey, _appSecret, false, AccessType.AppFolder); + + + } + + public DropboxV2AppFolderStorage(Context ctx, String _appKey, String _appSecret, boolean clearKeysOnStart) + { + super(ctx, _appKey, _appSecret, clearKeysOnStart, AccessType.AppFolder); + + } + + + @Override + public String getProtocolId() { + return "dropboxKP2A"; + } + + } + diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/ICertificateErrorHandler.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/ICertificateErrorHandler.java new file mode 100644 index 00000000..b292906e --- /dev/null +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/ICertificateErrorHandler.java @@ -0,0 +1,13 @@ +package keepass2android.javafilestorage; + +/** + * Created by Philipp on 22.11.2016. + */ +public interface ICertificateErrorHandler { + //callback when certificate validation fails. + //must return true to ignore the error and false to throw a CertificateException + boolean onValidationError(String error); + + //indicates whether the handler is configured to never accept validation errors. If true, the ssl default configuration can be used. + boolean alwaysFailOnValidationError(); +} diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/ConnectionInfo.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/ConnectionInfo.java new file mode 100644 index 00000000..b682a104 --- /dev/null +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/ConnectionInfo.java @@ -0,0 +1,10 @@ +package keepass2android.javafilestorage.webdav; + +/** + * Created by Philipp on 22.11.2016. + */ +public class ConnectionInfo { + public String URL; + public String username; + public String password; +} diff --git a/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/DecoratedTrustManager.java b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/DecoratedTrustManager.java new file mode 100644 index 00000000..4b416ddd --- /dev/null +++ b/src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/webdav/DecoratedTrustManager.java @@ -0,0 +1,63 @@ +package keepass2android.javafilestorage.webdav; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.X509TrustManager; + +import keepass2android.javafilestorage.ICertificateErrorHandler; + +/** + * Created by Philipp on 22.11.2016. + */ +public class DecoratedTrustManager implements X509TrustManager { + private final X509TrustManager mTrustManager; + private final ICertificateErrorHandler mCertificateErrorHandler; + + public DecoratedTrustManager(X509TrustManager trustManager, ICertificateErrorHandler certificateErrorHandler) { + mTrustManager = trustManager; + this.mCertificateErrorHandler = certificateErrorHandler; + } + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + try + { + mTrustManager.checkClientTrusted(x509Certificates,s); + } + catch (CertificateException e) + { + if ((mCertificateErrorHandler == null) || (!mCertificateErrorHandler.onValidationError(getMessage(e)))) + throw e; + } + + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + try + { + mTrustManager.checkServerTrusted(x509Certificates,s); + } + catch (CertificateException e) + { + if ((mCertificateErrorHandler == null) || (!mCertificateErrorHandler.onValidationError(getMessage(e)))) + throw e; + } + + } + + private String getMessage(CertificateException e) { + String msg = e.getLocalizedMessage(); + if (msg == null) + msg = e.getMessage(); + if (msg == null) + msg = e.toString(); + return msg; + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return mTrustManager.getAcceptedIssuers(); + } +}