Java Code Examples for com.google.appengine.api.users.User#getNickname()

The following examples show how to use com.google.appengine.api.users.User#getNickname() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Fido2RequestHandler.java    From webauthndemo with Apache License 2.0 6 votes vote down vote up
@ApiMethod(name = "getRegistrationRequest", path="get/register")
public List<String> getRegistrationRequest(User user) throws OAuthRequestException {
  if (user == null) {
    throw new OAuthRequestException("User is not authenticated");
  }

  PublicKeyCredentialCreationOptions options = new PublicKeyCredentialCreationOptions(
      user.getNickname() /* userName */, user.getEmail() /* userId */,
      Constants.APP_ID /* rpId */, Constants.APP_ID /* rpName */);
  SessionData session = new SessionData(options.challenge, Constants.APP_ID);
  session.save(user.getEmail());
  JsonObject sessionJson = session.getJsonObject();
  JsonObject optionsJson = options.getJsonObject();
  optionsJson.add("session", sessionJson);

  List<String> resultList = new ArrayList<String>();
  resultList.add(optionsJson.toString());
  return resultList;
}
 
Example 2
Source File: BeginMakeCredential.java    From webauthndemo with Apache License 2.0 5 votes vote down vote up
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  User user = userService.getCurrentUser();
  // String rpId = (request.isSecure() ? "https://" : "http://") + request.getHeader("Host");
  String rpId = Iterables.get(Splitter.on(':').split(request.getHeader("Host")), 0);
  String rpName = getServletContext().getInitParameter("name");
  rpName = (rpName == null ? "" : rpName);

  PublicKeyCredentialCreationOptions options =
      new PublicKeyCredentialCreationOptions(user.getNickname(), user.getEmail(), rpId, rpName);

  String hasAdvanced = request.getParameter("advanced");
  if (hasAdvanced.equals("true")) {
    parseAdvancedOptions(request.getParameter("advancedOptions"), options);
  }

  SessionData session = new SessionData(options.challenge, rpId);

  session.save(userService.getCurrentUser().getEmail());
  JsonObject sessionJson = session.getJsonObject();
  JsonObject optionsJson = options.getJsonObject();
  optionsJson.add("session", sessionJson);

  AuthenticationExtensionsClientInputs extensions = new AuthenticationExtensionsClientInputs();
  try {
    KeyPair cableKeyPair = extensions.addCableRegistrationData();
    // Store the KeyPair in storage
    CableKeyPair storedKeyPair = new CableKeyPair(cableKeyPair);
    storedKeyPair.save(session.getId());
  } catch (Exception e) {}

  optionsJson.add("extensions", extensions.getRegistrationExtensions());

  response.setContentType("application/json");
  response.getWriter().println(optionsJson.toString());
}
 
Example 3
Source File: UserInfo.java    From teammates with GNU General Public License v2.0 4 votes vote down vote up
public UserInfo(User user) {
    this.id = user.getNickname();
}