Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.gecko.sync.net;
7 import ch.boye.httpclientandroidlib.Header;
8 import ch.boye.httpclientandroidlib.client.methods.HttpRequestBase;
9 import ch.boye.httpclientandroidlib.impl.client.DefaultHttpClient;
10 import ch.boye.httpclientandroidlib.message.BasicHeader;
11 import ch.boye.httpclientandroidlib.protocol.BasicHttpContext;
13 /**
14 * An <code>AuthHeaderProvider</code> that returns an Authorization header for
15 * BrowserID assertions in the format expected by a Mozilla Services Token
16 * Server.
17 * <p>
18 * See <a href="http://docs.services.mozilla.com/token/apis.html">http://docs.services.mozilla.com/token/apis.html</a>.
19 */
20 public class BrowserIDAuthHeaderProvider implements AuthHeaderProvider {
21 protected final String assertion;
23 public BrowserIDAuthHeaderProvider(String assertion) {
24 if (assertion == null) {
25 throw new IllegalArgumentException("assertion must not be null.");
26 }
28 this.assertion = assertion;
29 }
31 @Override
32 public Header getAuthHeader(HttpRequestBase request, BasicHttpContext context, DefaultHttpClient client) {
33 Header header = new BasicHeader("Authorization", "BrowserID " + assertion);
35 return header;
36 }
37 }