Skip to content

@Nican /Login.java secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
OpenID Simple Openid
package controllers;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Promise;
import play.libs.Json;
import play.libs.OpenID;
import play.libs.OpenID.UserInfo;
import play.mvc.Controller;
import play.mvc.Result;
public class Login extends Controller {
@SuppressWarnings("serial")
public static final Map<String, String> identifiers = new HashMap<String, String>() {
{
put("google", "https://www.google.com/accounts/o8/id");
}
};
public static Result getProvider( String providerId ) {
String providerUrl = identifiers.get(providerId);
String returnToUrl = "http://localhost:9000/login/verify";
if (providerUrl == null)
return badRequest("Could not find provider " + providerId);
Promise<String> redirectUrl = OpenID.redirectURL(providerUrl, returnToUrl);
ObjectNode node = Json.newObject();
node.put("url", redirectUrl.get());
//The page is going to be redicted using javascript
return ok(node);
}
public static Result verifyLogin() {
Promise<UserInfo> userInfoPromise = OpenID.verifiedId();
UserInfo userInfo = userInfoPromise.get();
return ok(Json.toJson(userInfo));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.