diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2014-09-22 06:40:21 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2014-09-22 06:40:21 -0700 |
commit | dd4f34e216132e3a066566daf30a6f1fc1e1b872 (patch) | |
tree | 8c9e2ac3b30f207e7945dfe5f885101a6dcee995 /src/com/p4square/f1oauth/SecondPartyVerifier.java | |
parent | 6eba410e5eb53ee887e430f4f98ba03ffaa2a474 (diff) | |
parent | 3e703186928c5bd8f2c31f90b1c6e262c4080328 (diff) |
Merge branch 'f1-attributes'
Diffstat (limited to 'src/com/p4square/f1oauth/SecondPartyVerifier.java')
-rw-r--r-- | src/com/p4square/f1oauth/SecondPartyVerifier.java | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/com/p4square/f1oauth/SecondPartyVerifier.java b/src/com/p4square/f1oauth/SecondPartyVerifier.java index b1afcfa..882c7e7 100644 --- a/src/com/p4square/f1oauth/SecondPartyVerifier.java +++ b/src/com/p4square/f1oauth/SecondPartyVerifier.java @@ -30,9 +30,9 @@ public class SecondPartyVerifier implements Verifier { private static final Logger LOG = Logger.getLogger(SecondPartyVerifier.class); private final Restlet mDispatcher; - private final F1OAuthHelper mHelper; + private final F1Access mHelper; - public SecondPartyVerifier(Context context, F1OAuthHelper helper) { + public SecondPartyVerifier(Context context, F1Access helper) { if (helper == null) { throw new IllegalArgumentException("Helper can not be null."); } @@ -54,7 +54,7 @@ public class SecondPartyVerifier implements Verifier { OAuthUser ouser = mHelper.getAccessToken(username, password); // Once we have a user, fetch the people record to get the user id. - F1User user = getF1User(ouser); + F1User user = mHelper.getAuthenticatedApi(ouser).getF1User(ouser); user.setEmail(username); // This seems like a hack... but it'll work @@ -69,25 +69,4 @@ public class SecondPartyVerifier implements Verifier { return RESULT_INVALID; // Invalid credentials } - private F1User getF1User(OAuthUser user) throws OAuthException, IOException { - Request request = new Request(Method.GET, user.getLocation() + ".json"); - request.setChallengeResponse(user.getChallengeResponse()); - Response response = mDispatcher.handle(request); - - try { - Status status = response.getStatus(); - if (status.isSuccess()) { - JacksonRepresentation<Map> entity = new JacksonRepresentation<Map>(response.getEntity(), Map.class); - Map data = entity.getObject(); - return new F1User(user, data); - - } else { - throw new OAuthException(status); - } - } finally { - if (response.getEntity() != null) { - response.release(); - } - } - } } |