Package org.atomojo.auth.service.db

Examples of org.atomojo.auth.service.db.User


            getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            return null;
         }
         String authid = authorization.getIdentifier().trim();
         String password = new String(authorization.getSecret());
         User user = null;
         if (realm!=null) {
            RealmUser ruser = findRealmUser(db,realm,authid);
            if (ruser!=null) {
               user = ruser.getUser();
            }
            if (user==null) {
               // see if the user is a super user across realms
               user = findUser(db,authid);
               if (user!=null) {
                  // The user must either be a superuser or have the cross-realm permission
                  Permission superuser = db.getPermission(AuthDB.SUPERUSER_PERMISSION);
                  Permission crossrealm = db.getPermission(AuthDB.ACROSS_REALM_PERMISSION);
                  if (!user.hasPermission(superuser) && !user.hasPermission(crossrealm)) {
                     user = null;
                  }
               }
            }
         } else {
            user = findUser(db,authid);
         }
         if (user!=null) {
            try {
               String seconds = requestForm.getFirstValue("expiration");
               long requestExpiration = seconds==null ? expiration : Long.parseLong(seconds)*1000;
               if ("false".equals(requestForm.getFirstValue("session"))) {
                  requestExpiration = 0;
               }
               User.Authenticated authd = user.authenticate(realm,password,requestExpiration);
               if (authd!=null) {
                  String userAlias = authd.getUser().getAlias();
                  UUID userId = authd.getUser().getUUID();
                  String name = authd.getUser().getName();
                  String email = authd.getUser().getEmail();
View Full Code Here


               getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            }
            return null;
           
         } else {
            User user = fetchUser();
            if (user==null) {
               getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
               return new StringRepresentation("User not found.");
            }
            if (user.hasRole(role)) {
               getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
            } else {
               getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            }
            return null;
View Full Code Here

   }
 
   protected User fetchUser()
      throws SQLException,IllegalArgumentException
   {
      User user = null;
      if (userAlias!=null) {
         user = db.getUser(userAlias);
      }
      if (userId!=null) {
         UUID id = UUID.fromString(userId);
View Full Code Here

            }
            if (realm==null) {
               getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
               return new StringRepresentation("Realm not found.");
            }
            User user = null;
            if (id!=null) {
               user = db.getUser(id);
               if (user==null) {
                  getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                  return new StringRepresentation("User with id "+id+" not found.");
               } else if (alias==null && user.getAlias()==null) {
                  getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
                  return new StringRepresentation("The global user "+id+" does not have an alias and the alias was not specified on the request.");
               }
            }
            if (user==null) {
               // we have a request to create a realm user not tied to an existing user.
               // create a new user and then the realm user
               user = db.createUser(UUID.randomUUID(),null,null,null);
               if (user==null) {
                  // this really shouldn't happen because we don't have an alias
                  getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                  return new StringRepresentation("User creation is not available.");
               }
               // set the password if they specified it
               if (password!=null) {
                  user.setPassword(password);
               }
            }
            if (alias!=null && alias.equals(user.getAlias())) {
               // inherit the alias as it is the same
               alias = null;
            }
           
            if (db.isRealmUserAliasAvailable(realm,user,alias)) {
View Full Code Here

TOP

Related Classes of org.atomojo.auth.service.db.User

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.