Files
tubestation/mobile/android/base/sync/net/AbstractBearerTokenAuthHeaderProvider.java
Nick Alexander 37667fb441 Bug 1117829 - Add Firefox Account-backed oauth client. r=rnewman
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.

========

d1a25c8233
Author: Nick Alexander <nalexander@mozilla.com>
    Bug 1117829 - Part 3: Add FxA oauth and profile clients.

========

6c52ce9b53
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Mon Aug 18 13:53:56 2014 -0700

    Bug 1117829 - Part 2: Support remote verifier v1 and v2.

========

679e972d2c
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Mon Aug 18 11:52:45 2014 -0700

    Bug 1117829 - Part 1: Generalize bearer token auth header providers.

========

b55a14fe88
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Mon Aug 18 13:54:46 2014 -0700

    Bug 1117829 - Pre: Add static methods for cross-class testing.

========

5576662dd3
Author: Nick Alexander <nalexander@mozilla.com>
Date:   Mon Aug 18 11:42:45 2014 -0700

    Bug 1117829 - Pre: Fix debug printing of JWT structures.
2014-08-18 14:07:57 -07:00

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);
}
}