2032504cd6ea72f5257064c4c064eff755584ec2
[pub/Android/ownCloud.git] / oc_framework / src / com / owncloud / android / oc_framework / accounts / OwnCloudAccount.java
1 /* ownCloud Android Library is available under MIT license
2 * Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 *
23 */
24
25 package com.owncloud.android.oc_framework.accounts;
26
27 import android.accounts.Account;
28 import android.os.Parcel;
29 import android.os.Parcelable;
30
31 /**
32 * Account with extra information specific for ownCloud accounts.
33 *
34 * TODO integrate in the main app
35 *
36 * @author David A. Velasco
37 */
38 public class OwnCloudAccount extends Account {
39
40 public static class Constants {
41 /**
42 * Value under this key should handle path to webdav php script. Will be
43 * removed and usage should be replaced by combining
44 * {@link com.owncloud.android.authentication.AuthenticatorActivity.KEY_OC_BASE_URL} and
45 * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
46 *
47 * @deprecated
48 */
49 public static final String KEY_OC_URL = "oc_url";
50 /**
51 * Version should be 3 numbers separated by dot so it can be parsed by
52 * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
53 */
54 public static final String KEY_OC_VERSION = "oc_version";
55 /**
56 * Base url should point to owncloud installation without trailing / ie:
57 * http://server/path or https://owncloud.server
58 */
59 public static final String KEY_OC_BASE_URL = "oc_base_url";
60 /**
61 * Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens.
62 */
63 public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2";
64 /**
65 * Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on.
66 */
67 public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso";
68 }
69
70 private String mAuthTokenType;
71
72 public OwnCloudAccount(String name, String type, String authTokenType) {
73 super(name, type);
74 // TODO validate authTokentype as supported
75 mAuthTokenType = authTokenType;
76 }
77
78 /**
79 * Reconstruct from parcel
80 *
81 * @param source The source parcel
82 */
83 public OwnCloudAccount(Parcel source) {
84 super(source);
85 mAuthTokenType = source.readString();
86 }
87
88 @Override
89 public void writeToParcel(Parcel dest, int flags) {
90 super.writeToParcel(dest, flags);
91 dest.writeString(mAuthTokenType);
92 }
93
94
95 public String getAuthTokenType() {
96 return mAuthTokenType;
97 }
98
99
100 public static final Parcelable.Creator<OwnCloudAccount> CREATOR = new Parcelable.Creator<OwnCloudAccount>() {
101 @Override
102 public OwnCloudAccount createFromParcel(Parcel source) {
103 return new OwnCloudAccount(source);
104 }
105
106 @Override
107 public OwnCloudAccount [] newArray(int size) {
108 return new OwnCloudAccount[size];
109 }
110 };
111
112 }