Package models

Examples of models.User$UserMapper


public class ResidenceJSON extends AbstractJSON {
  public ResidenceJSON(Residence residence) {
    put("id", residence.id);
    put("name", residence.name);
    User admin = User.getAdmins().get(0);
    if(admin != null) {
      put("admin", new UserResidenceJSON(admin));
    }
  }
View Full Code Here


    put("admin", Boolean.FALSE);
    put("access",Boolean.TRUE);
  }
 
  public User getUser() {
    User user = new User();
    user.id = (Long) get("id");
    user.username = (String) get("username");
    user.password = (String) get("password");
    user.access = (Boolean) get("access");
    return user;
View Full Code Here

 
  protected static final int LIMIT = 50;
 
  @Before
  static void addDefaults() {
    User user = Security.getCurrentUser(Session.current().get(SessionConstants.USER));
    if(user!=null) {
      String username = Session.current().get(SessionConstants.USER);
      if(username.contains("@")){
        NamespaceManager.set(username.substring(username.indexOf("@")+1));
      } else {
View Full Code Here

  public static final String INTERNED_ROLE = "INTERNED_ROLE";
  public static final String FAMILIAR_ROLE = "FAMILIAR_ROLE";
 
  static boolean authenticate(String username, String password) { // TODO implement this method!!!!
    // First check if the user is accessing to a residence
    User user = getCurrentUser(username);
    if(user != null && password != null && !("").equals(password)) {
      try {
        String encodedPassword = PasswdUtils.encodePassword(password);
        return encodedPassword.equals(user.password);
      } catch(Exception e) {
View Full Code Here

          String confUser = Play.configuration.getProperty("batzen.username", "root");
          if(confUser.equals(username)) {
            return true;
          }
        } else {
          User user = getCurrentUser(Session.current().get(SessionConstants.USER));
          Logger.debug("Checking role: %s for user: %s", role, user != null ? user.username : "Unknown!!!");
          if(user != null) {
            if(Security.USER_ROLE.equals(role)) return true;
            return user.securityRoles.contains(role);
          }
View Full Code Here

        return false;
    }
 
  static User getCurrentUser(String username) {
    if(username == null) return null;
    User user = null;
    if(username.contains("@")) {
      String oldNamespace = NamespaceManager.get();
      String subscriberName = username.substring(username.indexOf("@")+1);
      Subscriber subscriber = Subscriber.findByName(subscriberName);
      if(null==subscriber) return null;
      username = username.substring(0, username.indexOf("@"));
      flash.put("residence", subscriber.name);
      flash.put("usernameV", username);
      NamespaceManager.set(subscriber.name);
      user = User.findByUsername(username);
      NamespaceManager.set(oldNamespace);
    } else {
      if(Play.configuration.getProperty("batzen.username", "root").equals(username)) {
        user = new User();
        user.username =  Play.configuration.getProperty("batzen.username", "root");
        user.password = Play.configuration.getProperty("batzen.password", "7af34762e3acde5ebb77e1ea37bc4be69cb3ba660b3637e3fb3aa84fb0ce36f9fd51880bdc5c455b9b63221d671ce0ed4726542713d658ce8b43e9b77bd2d2ca");
        return user;
      }
    }
View Full Code Here

    if(owned==null) owned=true;
    if(offset == null) offset = 0;
    if(limit==null || limit > LIMIT || limit==0) {
      limit = LIMIT;
    }
    User current = getCurrentUser();
    Data<Photo> data = new Data<Photo>();
    if(owned) {
      data.total = Photo.countByOwner(current);
      data.data = Photo.paginate(Photo.all(current), offset, limit);
    } else {
View Full Code Here

  }
 
  public static void add(Upload data) throws IOException {
    //TO-DO Security control check.
    String key = GAEFileService.createFile(MimeTypes.getContentType(data.getFileName()), data.getFileName(),data.asBytes());
    User currentUser = getCurrentUser();
    Photo photo = new Photo();
    photo.filename = data.getFileName();
    photo.owner = currentUser;
    response.status = StatusCode.CREATED;
    Map map = new HashMap();
View Full Code Here

  public static void get(Long id) {
    Photo photo = Photo.findById(id);
    if(photo == null) {
      notFound();
    }
    User currentUser = getCurrentUser();
    if(photo.owner.id!=currentUser.id &&
        !ContentTag.exists(photo.id, Tag.findOrCreateByName("shared", currentUser)))
      forbidden();
    renderJSON(gson().toJson(photo));
  }
View Full Code Here

      forbidden();
    renderJSON(gson().toJson(photo));
  }
 
  public static void delete(Long id) {
    User currentUser = getCurrentUser();
    Photo photo = Photo.findById(id);
    if(photo == null) notFound();
    if(photo.owner.id!=currentUser.id) forbidden();
    photo.delete();
    response.status = StatusCode.NO_RESPONSE;
View Full Code Here

TOP

Related Classes of models.User$UserMapper

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.