97367c5f6dc8d2100006e96f3fa6a182eb97c296
1 /* ownCloud Android Library is available under MIT license
2 * Copyright (C) 2014 ownCloud (http://www.owncloud.org/)
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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
25 package com
.owncloud
.android
.oc_framework
.network
;
27 import org
.apache
.commons
.httpclient
.Credentials
;
28 import org
.apache
.commons
.httpclient
.util
.LangUtils
;
31 * Bearer token {@link Credentials}
33 * @author David A. Velasco
35 public class BearerCredentials
implements Credentials
{
38 private String mAccessToken
;
42 * The constructor with the bearer token
44 * @param token The bearer token
46 public BearerCredentials(String token
) {
47 /*if (token == null) {
48 throw new IllegalArgumentException("Bearer token may not be null");
50 mAccessToken
= (token
== null
) ?
"" : token
;
55 * Returns the access token
57 * @return The access token
59 public String
getAccessToken() {
65 * Get this object string.
67 * @return The access token
69 public String
toString() {
74 * Does a hash of the access token.
76 * @return The hash code of the access token
78 public int hashCode() {
79 int hash
= LangUtils
.HASH_SEED
;
80 hash
= LangUtils
.hashCode(hash
, mAccessToken
);
85 * These credentials are assumed equal if accessToken is the same.
87 * @param o The other object to compare with.
89 * @return 'True' if the object is equivalent.
91 public boolean equals(Object o
) {
92 if (o
== null
) return false
;
93 if (this == o
) return true
;
94 if (this.getClass().equals(o
.getClass())) {
95 BearerCredentials that
= (BearerCredentials
) o
;
96 if (LangUtils
.equals(mAccessToken
, that
.mAccessToken
)) {