View Javadoc
1   /******************************************************************************
2    * UserWebSession.java - Manage who is on the other side of the browser
3    * 
4    * BSAccount - BuckoSoft Web Account Manager 
5    * Copyright(c) 2007 - Dick Balaska and BuckoSoft, Corp.
6    * 
7    */
8   package com.buckosoft.BSAccount.domain;
9   
10  
11  import java.io.Serializable;
12  
13  import javax.servlet.http.HttpServletRequest;
14  
15  /**
16   * Manage who is on the other side of the browser.
17   * @author Dick Balaska
18   */
19  public class BSAccountUserWebSession implements Serializable {
20  	private static final long serialVersionUID = 1L;
21  
22  	private BSAccountUser		bsuser;
23  
24  	public BSAccountUserWebSession() {}
25  
26  	/** Create a new session for this user.
27  	 * @param user The user who is logging in, or null for an anonymous user
28  	 */
29  	public BSAccountUserWebSession(BSAccountUser bsuser) {
30  		this.bsuser = bsuser;
31  	}
32  
33  	/** Get the user attached to this session.
34  	 * @return The BSAccountUser
35  	 */
36  	public BSAccountUser getUser() {
37  		return bsuser;
38  	}
39  
40  	public void setUser(BSAccountUser bsAccountUser) {
41  		this.bsuser = bsAccountUser;
42  	}
43  
44  	/** Is this session user logged in?
45  	 * @return ja/nein
46  	 */
47  	public	boolean isLoggedIn() {
48  		if (this.bsuser == null)
49  			return(false);
50  		return(bsuser.isRegisteredUser());
51  	}
52  
53  	/** Is this request coming in on a handheld phone thingy?
54  	 * @param request
55  	 * @return oui/non
56  	 */
57  	public static boolean isWapDevice(HttpServletRequest request) {
58  		if (request.getParameter("x-wap_profile") != null)
59  			return(true);
60  		return(false);
61  	}
62  
63  }