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 version 2,
6 * as published by the Free Software Foundation.
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.
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/>.
18 package com
.owncloud
.android
.network
;
20 import org
.apache
.commons
.httpclient
.Credentials
;
21 import org
.apache
.commons
.httpclient
.util
.LangUtils
;
24 * Bearer token {@link Credentials}
26 * @author David A. Velasco
28 public class BearerCredentials
implements Credentials
{
31 private String mAccessToken
;
35 * The constructor with the bearer token
37 * @param token The bearer token
39 public BearerCredentials(String token
) {
40 /*if (token == null) {
41 throw new IllegalArgumentException("Bearer token may not be null");
43 mAccessToken
= (token
== null
) ?
"" : token
;
48 * Returns the access token
50 * @return The access token
52 public String
getAccessToken() {
58 * Get this object string.
60 * @return The access token
62 public String
toString() {
67 * Does a hash of the access token.
69 * @return The hash code of the access token
71 public int hashCode() {
72 int hash
= LangUtils
.HASH_SEED
;
73 hash
= LangUtils
.hashCode(hash
, mAccessToken
);
78 * These credentials are assumed equal if accessToken is the same.
80 * @param o The other object to compare with.
82 * @return 'True' if the object is equivalent.
84 public boolean equals(Object o
) {
85 if (o
== null
) return false
;
86 if (this == o
) return true
;
87 if (this.getClass().equals(o
.getClass())) {
88 BearerCredentials that
= (BearerCredentials
) o
;
89 if (LangUtils
.equals(mAccessToken
, that
.mAccessToken
)) {