Commit 6fd1cc46 authored by 0Tyler's avatar 0Tyler

add User in UserProxyService

parent 2838287e
Pipeline #1674 failed with stages
package com.google.webauthn.gaedemo.service; package com.google.webauthn.gaedemo.service;
import com.google.appengine.api.users.User;
public class UserProxyService { public class UserProxyService {
private static UserProxyService instance; private static UserProxyService instance;
private String username; private User user;
public UserProxyService() {} public UserProxyService() {}
...@@ -17,11 +19,11 @@ public class UserProxyService { ...@@ -17,11 +19,11 @@ public class UserProxyService {
return instance; return instance;
} }
public String getUsername() { public User getCurrentUser() {
return username; return user;
} }
public void setUsername(String username) { public void setUser(User user) {
this.username = username; this.user = user;
} }
} }
...@@ -65,7 +65,6 @@ public class BeginMakeCredential extends HttpServlet { ...@@ -65,7 +65,6 @@ public class BeginMakeCredential extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
// Tyler ----------------- // Tyler -----------------
String username = request.getParameter("username");
// User user = new User(username, "localhost"); // User user = new User(username, "localhost");
// // String rpId = (request.isSecure() ? "https://" : "http://") + request.getHeader("Host"); // // String rpId = (request.isSecure() ? "https://" : "http://") + request.getHeader("Host");
// String rpId = Iterables.get(Splitter.on(':').split(request.getHeader("Host")), 0); // String rpId = Iterables.get(Splitter.on(':').split(request.getHeader("Host")), 0);
...@@ -99,9 +98,11 @@ public class BeginMakeCredential extends HttpServlet { ...@@ -99,9 +98,11 @@ public class BeginMakeCredential extends HttpServlet {
// //
// response.setContentType("application/json"); // response.setContentType("application/json");
// response.getWriter().println(optionsJson.toString()); // response.getWriter().println(optionsJson.toString());
UserProxyService.getInstance().setUsername(username); String username = request.getParameter("username");
String username2 = UserProxyService.getInstance().getUsername(); UserProxyService.getInstance().setUser(new User(username, "gmail.com",
log.info("make" + username2); userService.getCurrentUser().getUserId()));
User cloneUser = UserProxyService.getInstance().getCurrentUser();
log.info("make" + cloneUser.toString());
// Tyler ----------------- // Tyler -----------------
// Original Code // Original Code
......
...@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletResponse;
* Servlet implementation class Home * Servlet implementation class Home
*/ */
public class Login extends HttpServlet { public class Login extends HttpServlet {
private final Logger log= Logger.getLogger(Login.class.getSimpleName());
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final UserService userService = UserServiceFactory.getUserService(); private final UserService userService = UserServiceFactory.getUserService();
...@@ -39,8 +38,6 @@ public class Login extends HttpServlet { ...@@ -39,8 +38,6 @@ public class Login extends HttpServlet {
throws ServletException, IOException { throws ServletException, IOException {
String nickname = userService.getCurrentUser().getNickname(); String nickname = userService.getCurrentUser().getNickname();
String logoutUrl = userService.createLogoutURL(request.getRequestURI()); String logoutUrl = userService.createLogoutURL(request.getRequestURI());
System.out.println("Login");
log.info("Login");
request.setAttribute("nickname", nickname); request.setAttribute("nickname", nickname);
request.setAttribute("logoutUrl", logoutUrl); request.setAttribute("logoutUrl", logoutUrl);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/login.jsp"); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/login.jsp");
......
...@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory; import com.google.appengine.api.users.UserServiceFactory;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
...@@ -54,8 +55,8 @@ public class RegisteredKeys extends HttpServlet { ...@@ -54,8 +55,8 @@ public class RegisteredKeys extends HttpServlet {
@Override @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
String username = UserProxyService.getInstance().getUsername(); User cloneUser = UserProxyService.getInstance().getCurrentUser();
log.info("Get " + username); log.info("Get " + cloneUser.toString());
// Tyler-------------------- // Tyler--------------------
String currentUser = userService.getCurrentUser().getEmail(); String currentUser = userService.getCurrentUser().getEmail();
List<Credential> savedCreds = Credential.load(currentUser); List<Credential> savedCreds = Credential.load(currentUser);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment