Refine search
public String getEmail() { return _user.getEmail(); }
@Override protected String getUserId(HttpServletRequest req) throws ServletException, IOException { // Use GAE Standard's users service to fetch the current user of the application. return UserServiceFactory.getUserService().getCurrentUser().getUserId(); } }
public GaeUser(String email, String authDomain, String userId, String federatedIdentity) { _user = new User(email, authDomain, userId, federatedIdentity); }
response.sendRedirect( scheme.getErrorUrl(new LeanException(LeanException.Error.OpenIdAuthNotEnabled), errorUrl)); return; String loginUrl = UserServiceFactory.getUserService().createLoginURL(redirectUrl, null, openIdProvider, null); response.sendRedirect(loginUrl); User currentUser = UserServiceFactory.getUserService().getCurrentUser(); response.sendRedirect( scheme.getErrorUrl(new LeanException(LeanException.Error.OpenIdAuthFailed), errorUrl)); return; LeanAccount account = AccountUtils.findAccountByProvider(currentUser.getUserId(), currentUser.getFederatedIdentity()); props.put("email", currentUser.getEmail()); currentUser.getNickname(), currentUser.getUserId(), currentUser.getFederatedIdentity(), props );
@Override protected void clientInit() { service = UserServiceFactory.getUserService(); CommonHelper.assertNotNull("service", this.service); defaultRedirectActionBuilder(ctx -> { final String destinationUrl = computeFinalCallbackUrl(ctx); final String loginUrl = authDomain == null ? service.createLoginURL(destinationUrl) : service.createLoginURL(destinationUrl, authDomain); return RedirectAction.redirect(loginUrl); }); defaultCredentialsExtractor(ctx -> { final GaeUserCredentials credentials = new GaeUserCredentials(); credentials.setUser(service.getCurrentUser()); return credentials; }); defaultAuthenticator((credentials, ctx) -> { final User user = credentials.getUser(); if (user != null) { final GaeUserServiceProfile profile = PROFILE_DEFINITION.newProfile(); profile.setId(user.getEmail()); PROFILE_DEFINITION.convertAndAdd(profile, PROFILE_ATTRIBUTE, CommonProfileDefinition.EMAIL, user.getEmail()); PROFILE_DEFINITION.convertAndAdd(profile, PROFILE_ATTRIBUTE, CommonProfileDefinition.DISPLAY_NAME, user.getNickname()); if (service.isUserAdmin()) { profile.addRole(GaeUserServiceProfile.PAC4J_GAE_GLOBAL_ADMIN_ROLE); } credentials.setUserProfile(profile); } }); }
public static void serialize(SerializationStreamWriter streamWriter, User instance) throws SerializationException { streamWriter.writeString(instance.getEmail()); streamWriter.writeString(instance.getAuthDomain()); streamWriter.writeString(instance.getUserId()); } }
public String getUserId() { return _user.getUserId(); }
public String getNickname() { return _user.getNickname(); }
public String getFederatedIdentity() { return _user.getFederatedIdentity(); }
public String getAuthDomain() { return _user.getAuthDomain(); }
@Override protected String getUserId(HttpServletRequest req) throws ServletException, IOException { // Use GAE Standard's users service to fetch the current user of the application. return UserServiceFactory.getUserService().getCurrentUser().getUserId(); } }
private String callMethod(String method, String scope) { try { if (method.equals("getEmail")) { if (errorOnScope != null) { return errorOnScope; } if (user == null) { return "user is null"; } else { return user.getEmail(); } } else if (method.equals("isUserAdmin")) { if (scope == null) { return "" + oAuthService.isUserAdmin(); } else { return "" + oAuthService.isUserAdmin(scope); } } else if (method.equals("getClientId")) { return oAuthService.getClientId(scope); } else if (method.equals("getOAuthConsumerKey")) { return oAuthService.getOAuthConsumerKey(); } else if (method.equals("isUserAdmin")) { return "" + oAuthService.isUserAdmin(); } else { return "UNRECOGNIZED METHOD:" + method; } } catch (Exception e) { return method + ":" + e.toString(); } }
@Test public void testUserProperty() { testEqualityQueries(new User("foo@foo.com", "authDomain", "userId", "federatedIdentity"), new User("bar@bar.com", "authDomain", "userId", "federatedIdentity")); testInequalityQueries(new User("aaa@foo.com", "authDomain"), new User("bbb@foo.com", "authDomain"), new User("ccc@foo.com", "authDomain")); }
/** * Return the user id for the currently logged in user. */ static final String getUserId() { UserService userService = UserServiceFactory.getUserService(); User loggedIn = userService.getCurrentUser(); Preconditions.checkState(loggedIn != null, "This servlet requires the user to be logged in."); return loggedIn.getUserId(); } }
public static User instantiate(SerializationStreamReader streamReader) throws SerializationException { String email = streamReader.readString(); String auth = streamReader.readString(); String userid = streamReader.readString(); return new User(email, auth, userid); }
/** * Return the user id for the currently logged in user. */ static final String getUserId() { UserService userService = UserServiceFactory.getUserService(); User loggedIn = userService.getCurrentUser(); Preconditions.checkState(loggedIn != null, "This servlet requires the user to be logged in."); return loggedIn.getUserId(); } }