add missing files

This commit is contained in:
Philipp Crocoll 2016-11-28 12:03:53 +01:00
parent 7ddba53426
commit 8f4ddae86e
4 changed files with 116 additions and 0 deletions

View File

@ -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";
}
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();
}
}