src/org/sonews/daemon/NNTPConnection.java
changeset 103 a788bf0e1080
parent 49 8df94bfd3e2f
child 108 fdc075324ef3
     1.1 --- a/src/org/sonews/daemon/NNTPConnection.java	Sun Sep 11 17:01:19 2011 +0200
     1.2 +++ b/src/org/sonews/daemon/NNTPConnection.java	Thu Oct 20 10:50:58 2011 +0200
     1.3 @@ -59,6 +59,9 @@
     1.4  	private int readLock = 0;
     1.5  	private final Object readLockGate = new Object();
     1.6  	private SelectionKey writeSelKey = null;
     1.7 +	
     1.8 +	private String username;
     1.9 +	private boolean userAuthenticated = false;
    1.10  
    1.11  	public NNTPConnection(final SocketChannel channel)
    1.12  			throws IOException {
    1.13 @@ -360,4 +363,36 @@
    1.14  	void setLastActivity(long timestamp) {
    1.15  		this.lastActivity = timestamp;
    1.16  	}
    1.17 +
    1.18 +	/**
    1.19 +	 * @return Current username. 
    1.20 +	 * But user may not have been authenticated yet.
    1.21 +	 * You must check {@link #isUserAuthenticated()}
    1.22 +	 */
    1.23 +	public String getUsername() {
    1.24 +		return username;
    1.25 +	}
    1.26 +
    1.27 +	/**
    1.28 +	 * This method is to be called from AUTHINFO USER Command implementation.
    1.29 +	 * @param username username from AUTHINFO USER username.
    1.30 +	 */
    1.31 +	public void setUsername(String username) {
    1.32 +		this.username = username;
    1.33 +	}
    1.34 +
    1.35 +	/**
    1.36 +	 * @return true if current user (see {@link #getUsername()}) has been succesfully authenticated.
    1.37 +	 */
    1.38 +	public boolean isUserAuthenticated() {
    1.39 +		return userAuthenticated;
    1.40 +	}
    1.41 +
    1.42 +	/**
    1.43 +	 * This method is to be called from AUTHINFO PASS Command implementation.
    1.44 +	 * @param userAuthenticated true if user has provided right password in AUTHINFO PASS password.
    1.45 +	 */
    1.46 +	public void setUserAuthenticated(boolean userAuthenticated) {
    1.47 +		this.userAuthenticated = userAuthenticated;
    1.48 +	}
    1.49  }