1 /* ownCloud Android client application
2 * Copyright (C) 2012 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.network
;
21 import org
.apache
.commons
.httpclient
.Credentials
;
22 import org
.apache
.commons
.httpclient
.util
.LangUtils
;
25 * Bearer token {@link Credentials}
27 * @author David A. Velasco
29 public class BearerCredentials
implements Credentials
{
32 private String mAccessToken
;
36 * The constructor with the bearer token
38 * @param token The bearer token
40 public BearerCredentials(String token
) {
41 /*if (token == null) {
42 throw new IllegalArgumentException("Bearer token may not be null");
44 mAccessToken
= (token
== null
) ?
"" : token
;
49 * Returns the access token
51 * @return The access token
53 public String
getAccessToken() {
59 * Get this object string.
61 * @return The access token
63 public String
toString() {
68 * Does a hash of the access token.
70 * @return The hash code of the access token
72 public int hashCode() {
73 int hash
= LangUtils
.HASH_SEED
;
74 hash
= LangUtils
.hashCode(hash
, mAccessToken
);
79 * These credentials are assumed equal if accessToken is the same.
81 * @param o The other object to compare with.
83 * @return 'True' if the object is equivalent.
85 public boolean equals(Object o
) {
86 if (o
== null
) return false
;
87 if (this == o
) return true
;
88 if (this.getClass().equals(o
.getClass())) {
89 BearerCredentials that
= (BearerCredentials
) o
;
90 if (LangUtils
.equals(mAccessToken
, that
.mAccessToken
)) {