Skip to content

Instantly share code, notes, and snippets.

@tleyden
Created October 7, 2013 23:52
Show Gist options
  • Save tleyden/6877087 to your computer and use it in GitHub Desktop.
Save tleyden/6877087 to your computer and use it in GitHub Desktop.
FB params passed in CBLReplicator ctor
public CBLReplicator(CBLDatabase db, URL remote, boolean continuous, HttpClientFactory clientFacotry, ScheduledExecutorService workExecutor) {
this.db = db;
this.continuous = continuous;
this.workExecutor = workExecutor;
this.remote = remote;
this.remoteRequestExecutor = Executors.newCachedThreadPool();
if (remote.getQuery() != null && !remote.getQuery().isEmpty()) {
Uri uri = Uri.parse(remote.toExternalForm());
String personaAssertion = uri.getQueryParameter(CBLPersonaAuthorizer.QUERY_PARAMETER);
if (personaAssertion != null && !personaAssertion.isEmpty()) {
String email = CBLPersonaAuthorizer.registerAssertion(personaAssertion);
CBLPersonaAuthorizer authorizer = new CBLPersonaAuthorizer(email);
setAuthorizer(authorizer);
}
String facebookAccessToken = uri.getQueryParameter(CBLFacebookAuthorizer.QUERY_PARAMETER);
if (facebookAccessToken != null && !facebookAccessToken.isEmpty()) {
String email = uri.getQueryParameter(CBLFacebookAuthorizer.QUERY_PARAMETER_EMAIL);
CBLFacebookAuthorizer authorizer = new CBLFacebookAuthorizer(email);
URL remoteWithQueryRemoved = null;
try {
remoteWithQueryRemoved = new URL(remote.getProtocol(), remote.getHost(), remote.getPort(), remote.getPath());
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
authorizer.registerAccessToken(facebookAccessToken, email, remoteWithQueryRemoved.toExternalForm());
setAuthorizer(authorizer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment