All Downloads are FREE. Search and download functionalities are using the official Maven repository.

models.gsn.auth.Client Maven / Gradle / Ivy

The newest version!
/**
* Global Sensor Networks (GSN) Source Code
* Copyright (c) 2006-2016, Ecole Polytechnique Federale de Lausanne (EPFL)
* 
* This file is part of GSN.
* 
* GSN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* GSN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with GSN.  If not, see .
* 
* File: app/models/gsn/auth/Client.java
*
* @author Julien Eberle
*
*/
package models.gsn.auth;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;


@Entity
public class Client extends AppModel{

	private static final long serialVersionUID = 1L;

	@Id
	public Long id;
	public String name;
	public String clientId;
	public String secret;
	public String redirect;
	@OneToMany(cascade = CascadeType.ALL)
	public List tokens;
	@OneToMany(cascade = CascadeType.ALL)
	public List codes;
	@ManyToOne
	public User user;
	@ManyToMany
	public List trusted_users;
	public Boolean linked = false;

	public static final play.db.ebean.Model.Finder find = new play.db.ebean.Model.Finder(
			Long.class, Client.class);

	public boolean isLinked() {
		return linked;
	}

	public void setLinked(boolean l) {
		linked = l;
	}
	
    public void setName(String n){
    	name = n;
    }

    public void setSecret(String s){
    	secret = s;
    }
    
    public void setClientId(String i){
    	clientId = i;
    }
    
    public String getClientId(){
    	return clientId;
    }
    
    public void setRedirect(String u){
    	redirect = u;
    }
    
    public String getRedirect(){
    	return redirect;
    }
    
    public void setUser(User r){
    	user = r;
    }
    
    public User getUser(){
    	return user;
    }
    
	public static Client findByName(String value) {
		return find.where().eq("name", value).findUnique();
	}
	
	public static Client findById(String value) {
		return find.where().eq("clientId", value).findUnique();
	}
	
	public static List findByUser(User u){
		return find.where().eq("user", u).findList();
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy