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.
63 lines
2.1 KiB
Java
63 lines
2.1 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.browserid.verifier;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URI;
|
|
import java.net.URISyntaxException;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import org.mozilla.gecko.sync.net.BaseResource;
|
|
|
|
import ch.boye.httpclientandroidlib.NameValuePair;
|
|
import ch.boye.httpclientandroidlib.client.entity.UrlEncodedFormEntity;
|
|
import ch.boye.httpclientandroidlib.message.BasicNameValuePair;
|
|
|
|
/**
|
|
* The verifier protocol changed: version 1 posts form-encoded data; version 2
|
|
* posts JSON data.
|
|
*/
|
|
public class BrowserIDRemoteVerifierClient10 extends AbstractBrowserIDRemoteVerifierClient {
|
|
public static final String LOG_TAG = BrowserIDRemoteVerifierClient10.class.getSimpleName();
|
|
|
|
public static final String DEFAULT_VERIFIER_URL = "https://verifier.login.persona.org/verify";
|
|
|
|
public BrowserIDRemoteVerifierClient10() throws URISyntaxException {
|
|
super(new URI(DEFAULT_VERIFIER_URL));
|
|
}
|
|
|
|
public BrowserIDRemoteVerifierClient10(URI verifierUri) {
|
|
super(verifierUri);
|
|
}
|
|
|
|
@Override
|
|
public void verify(String audience, String assertion, final BrowserIDVerifierDelegate delegate) {
|
|
if (audience == null) {
|
|
throw new IllegalArgumentException("audience cannot be null.");
|
|
}
|
|
if (assertion == null) {
|
|
throw new IllegalArgumentException("assertion cannot be null.");
|
|
}
|
|
if (delegate == null) {
|
|
throw new IllegalArgumentException("delegate cannot be null.");
|
|
}
|
|
|
|
BaseResource r = new BaseResource(verifierUri);
|
|
|
|
r.delegate = new RemoteVerifierResourceDelegate(r, delegate);
|
|
|
|
List<NameValuePair> nvps = Arrays.asList(new NameValuePair[] {
|
|
new BasicNameValuePair("audience", audience),
|
|
new BasicNameValuePair("assertion", assertion) });
|
|
|
|
try {
|
|
r.post(new UrlEncodedFormEntity(nvps, "UTF-8"));
|
|
} catch (UnsupportedEncodingException e) {
|
|
delegate.handleError(e);
|
|
}
|
|
}
|
|
}
|