The oauth client exchanges Firefox Account assertions for oauth token grants. The client_id is assumed to have the "canGrant" capability on the oauth endpoint. ========d1a25c8233Author: Nick Alexander <nalexander@mozilla.com> Bug 1117829 - Part 3: Add FxA oauth and profile clients. ========6c52ce9b53Author: Nick Alexander <nalexander@mozilla.com> Date: Mon Aug 18 13:53:56 2014 -0700 Bug 1117829 - Part 2: Support remote verifier v1 and v2. ========679e972d2cAuthor: Nick Alexander <nalexander@mozilla.com> Date: Mon Aug 18 11:52:45 2014 -0700 Bug 1117829 - Part 1: Generalize bearer token auth header providers. ========b55a14fe88Author: Nick Alexander <nalexander@mozilla.com> Date: Mon Aug 18 13:54:46 2014 -0700 Bug 1117829 - Pre: Add static methods for cross-class testing. ========5576662dd3Author: Nick Alexander <nalexander@mozilla.com> Date: Mon Aug 18 11:42:45 2014 -0700 Bug 1117829 - Pre: Fix debug printing of JWT structures.
35 lines
1.2 KiB
Java
35 lines
1.2 KiB
Java
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.sync.net;
|
|
|
|
import ch.boye.httpclientandroidlib.Header;
|
|
import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
|
|
import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
|
|
import ch.boye.httpclientandroidlib.message.BasicHeader;
|
|
import ch.boye.httpclientandroidlib.protocol.BasicHttpContext;
|
|
|
|
/**
|
|
* An <code>AuthHeaderProvider</code> that returns an Authorization header for
|
|
* bearer tokens, adding a simple prefix.
|
|
*/
|
|
public abstract class AbstractBearerTokenAuthHeaderProvider implements AuthHeaderProvider {
|
|
protected final String header;
|
|
|
|
public AbstractBearerTokenAuthHeaderProvider(String token) {
|
|
if (token == null) {
|
|
throw new IllegalArgumentException("token must not be null.");
|
|
}
|
|
|
|
this.header = getPrefix() + " " + token;
|
|
}
|
|
|
|
protected abstract String getPrefix();
|
|
|
|
@Override
|
|
public Header getAuthHeader(HttpRequestBase request, BasicHttpContext context, DefaultHttpClient client) {
|
|
return new BasicHeader("Authorization", header);
|
|
}
|
|
}
|