Package com.feth.play.module.pa.user

Examples of com.feth.play.module.pa.user.AuthUser


    public static final String FLASH_MESSAGE_KEY = "message";

    @Override
    public String getUsername(final Context ctx) {
  final AuthUser u = PlayAuthenticate.getUser(ctx.session());
  return (u != null ? u.getId() : null);
    }
View Full Code Here


  public static final String FLASH_ERROR_KEY = "error";

  @Security.Authenticated(JavaSecured.class)
  public static Result index() {
    AuthUser user = PlayAuthenticate.getUser(ctx());
    return ok(user.getProvider() + ": " + user.getId());
  }
View Full Code Here

  public static Result index() {
    return ok(index.render());
  }

  public static User getLocalUser(final Session session) {
    final AuthUser currentAuthUser = PlayAuthenticate.getUser(session);
    final User localUser = User.findByAuthUserIdentity(currentAuthUser);
    return localUser;
  }
View Full Code Here

  }

  @Override
  protected AuthUser authenticateUser(String username, String password) {
    if (username.equals("example") && password.equals("secret")) {
      return new AuthUser() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getId() {
          return "example";
View Full Code Here

public class Secured extends Security.Authenticator {

  @Override
  public String getUsername(final Context ctx) {
    final AuthUser u = PlayAuthenticate.getUser(ctx.session());

    if (u != null) {
      return u.getId();
    } else {
      return null;
    }
  }
View Full Code Here

  }

  public static void storeUser(final Session session, final AuthUser authUser) {

    // User logged in once more - wanna make some updates?
    final AuthUser u = getUserService().update(authUser);

    session.put(PlayAuthenticate.USER_KEY, u.getId());
    session.put(PlayAuthenticate.PROVIDER_KEY, u.getProvider());
    if (u.expires() != AuthUser.NO_EXPIRATION) {
      session.put(EXPIRES_KEY, Long.toString(u.expires()));
    } else {
      session.remove(EXPIRES_KEY);
    }
  }
View Full Code Here

      return "/";
    }
  }

  public static Result link(final Context context, final boolean link) {
    final AuthUser linkUser = getLinkUser(context.session());

    if (linkUser == null) {
      return Controller.forbidden();
    }

    final AuthUser loginUser;
    if (link) {
      // User accepted link - add account to existing local user
      loginUser = getUserService().link(getUser(context.session()),
          linkUser);
    } else {
View Full Code Here

    storeUser(context.session(), loginUser);
    return Controller.redirect(getJumpUrl(context));
  }

  public static Result merge(final Context context, final boolean merge) {
    final AuthUser mergeUser = getMergeUser(context.session());

    if (mergeUser == null) {
      return Controller.forbidden();
    }
    final AuthUser loginUser;
    if (merge) {
      // User accepted merge, so do it
      loginUser = getUserService().merge(mergeUser,
          getUser(context.session()));
    } else {
View Full Code Here

        return Controller.redirect((String) o);
      } else if (o instanceof Result) {
        return (Result) o;
      } else if (o instanceof AuthUser) {

        final AuthUser newUser = (AuthUser) o;
        final Session session = context.session();

        // We might want to do merging here:
        // Adapted from:
        // http://stackoverflow.com/questions/6666267/architecture-for-merging-multiple-user-accounts-together
        // 1. The account is linked to a local account and no session
        // cookie is present --> Login
        // 2. The account is linked to a local account and a session
        // cookie is present --> Merge
        // 3. The account is not linked to a local account and no
        // session cookie is present --> Signup
        // 4. The account is not linked to a local account and a session
        // cookie is present --> Linking Additional account

        // get the user with which we are logged in - is null if we
        // are
        // not logged in (does NOT check expiration)

        AuthUser oldUser = getUser(session);

        // checks if the user is logged in (also checks the expiration!)
        boolean isLoggedIn = isLoggedIn(session);

        Object oldIdentity = null;

        // check if local user still exists - it might have been
        // deactivated/deleted,
        // so this is a signup, not a link
        if (isLoggedIn) {
          oldIdentity = getUserService().getLocalIdentity(oldUser);
          isLoggedIn = oldIdentity != null;
          if (!isLoggedIn) {
            // if isLoggedIn is false here, then the local user has
            // been deleted/deactivated
            // so kill the session
            logout(session);
            oldUser = null;
          }
        }

        final Object loginIdentity = getUserService().getLocalIdentity(
            newUser);
        final boolean isLinked = loginIdentity != null;

        final AuthUser loginUser;
        if (isLinked && !isLoggedIn) {
          // 1. -> Login
          loginUser = newUser;

        } else if (isLinked) {
View Full Code Here

    }
    int ix = auth.indexOf(32);
    if (ix == -1 || !authScheme().equalsIgnoreCase(auth.substring(0,ix))) {
      return deny(context);
    }
    AuthUser user = authenticateResponse(auth.substring(ix+1));
    if (user == null) {
      return deny(context);
    } else {
      return user;
    }
View Full Code Here

TOP

Related Classes of com.feth.play.module.pa.user.AuthUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.