- private Uri mUri;\r
- private Credentials mCredentials;
- final private static String TAG = "WebdavClient";\r
- private static final String USER_AGENT = "Android-ownCloud";
-
- public WebdavClient(Uri uri) {
- mUri = uri;\r
- getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
- }
-
- public void setCredentials(String username, String password) {\r
- getParams().setAuthenticationPreemptive(true);
- getState().setCredentials(AuthScope.ANY, getCredentials(username, password));
- }
-
- private Credentials getCredentials(String username, String password) {\r
- if (mCredentials == null)\r
- mCredentials = new UsernamePasswordCredentials(username, password); \r
- return mCredentials;\r
- }\r
-\r
- public void allowUnsignedCertificates() {
- // https\r
- Protocol.registerProtocol("https", new Protocol("https", new EasySSLSocketFactory(), 443));
- }
-
- public boolean downloadFile(String filepath, File targetPath) {
- //HttpGet get = new HttpGet(mUri.toString() + filepath.replace(" ", "%20"));\r
- \r
- Log.e("ASD", mUri.toString() + URLDecoder.decode(filepath) + "");\r
- GetMethod get = new GetMethod(mUri.toString() + URLDecoder.decode(filepath));\r
+ private Uri mUri;
+ private Credentials mCredentials;
+ private boolean mFollowRedirects;
+ private String mSsoSessionCookie;
+ final private static String TAG = "WebdavClient";
+ public static final String USER_AGENT = "Android-ownCloud";
+
+ static private byte[] sExhaustBuffer = new byte[1024];
+
+ /**
+ * Constructor
+ */
+ public WebdavClient(HttpConnectionManager connectionMgr) {
+ super(connectionMgr);
+ Log_OC.d(TAG, "Creating WebdavClient");
+ getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
+ getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
+ mFollowRedirects = true;
+ mSsoSessionCookie = null;
+ }
+
+ public void setBearerCredentials(String accessToken) {
+ AuthPolicy.registerAuthScheme(BearerAuthScheme.AUTH_POLICY, BearerAuthScheme.class);
+
+ List<String> authPrefs = new ArrayList<String>(1);
+ authPrefs.add(BearerAuthScheme.AUTH_POLICY);
+ getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
+
+ mCredentials = new BearerCredentials(accessToken);
+ getState().setCredentials(AuthScope.ANY, mCredentials);
+ mSsoSessionCookie = null;
+ }
+
+ public void setBasicCredentials(String username, String password) {
+ List<String> authPrefs = new ArrayList<String>(1);
+ authPrefs.add(AuthPolicy.BASIC);
+ getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
+
+ getParams().setAuthenticationPreemptive(true);
+ mCredentials = new UsernamePasswordCredentials(username, password);
+ getState().setCredentials(AuthScope.ANY, mCredentials);
+ mSsoSessionCookie = null;
+ }
+
+ public void setSsoSessionCookie(String accessToken) {
+ getParams().setAuthenticationPreemptive(false);
+ getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
+ mSsoSessionCookie = accessToken;
+ mCredentials = null;
+ }