73fdb652198108f83489114eb64fbb5c2edb7517
[pub/Android/ownCloud.git] / oc_framework / src / com / owncloud / android / oc_framework / accounts / OwnCloudAccount.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 package com.owncloud.android.oc_framework.accounts;
19
20 import android.accounts.Account;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 /**
25 * Account with extra information specific for ownCloud accounts.
26 *
27 * TODO integrate in the main app
28 *
29 * @author David A. Velasco
30 */
31 public class OwnCloudAccount extends Account {
32
33 public static class Constants {
34 /**
35 * Value under this key should handle path to webdav php script. Will be
36 * removed and usage should be replaced by combining
37 * {@link com.owncloud.android.authentication.AuthenticatorActivity.KEY_OC_BASE_URL} and
38 * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
39 *
40 * @deprecated
41 */
42 public static final String KEY_OC_URL = "oc_url";
43 /**
44 * Version should be 3 numbers separated by dot so it can be parsed by
45 * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
46 */
47 public static final String KEY_OC_VERSION = "oc_version";
48 /**
49 * Base url should point to owncloud installation without trailing / ie:
50 * http://server/path or https://owncloud.server
51 */
52 public static final String KEY_OC_BASE_URL = "oc_base_url";
53 /**
54 * Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens.
55 */
56 public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2";
57 /**
58 * Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on.
59 */
60 public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso";
61 }
62
63 private String mAuthTokenType;
64
65 public OwnCloudAccount(String name, String type, String authTokenType) {
66 super(name, type);
67 // TODO validate authTokentype as supported
68 mAuthTokenType = authTokenType;
69 }
70
71 /**
72 * Reconstruct from parcel
73 *
74 * @param source The source parcel
75 */
76 public OwnCloudAccount(Parcel source) {
77 super(source);
78 mAuthTokenType = source.readString();
79 }
80
81 @Override
82 public void writeToParcel(Parcel dest, int flags) {
83 super.writeToParcel(dest, flags);
84 dest.writeString(mAuthTokenType);
85 }
86
87
88 public String getAuthTokenType() {
89 return mAuthTokenType;
90 }
91
92
93 public static final Parcelable.Creator<OwnCloudAccount> CREATOR = new Parcelable.Creator<OwnCloudAccount>() {
94 @Override
95 public OwnCloudAccount createFromParcel(Parcel source) {
96 return new OwnCloudAccount(source);
97 }
98
99 @Override
100 public OwnCloudAccount [] newArray(int size) {
101 return new OwnCloudAccount[size];
102 }
103 };
104
105 }