net.sourceforge.guacamole.net.basic.auth
Class Authorization

java.lang.Object
  extended by net.sourceforge.guacamole.net.basic.auth.Authorization

public class Authorization
extends Object

Mapping of username/password pair to configuration set. In addition to basic storage of the username, password, and configurations, this class also provides password validation functions.

Author:
Mike Jumper

Nested Class Summary
static class Authorization.Encoding
          All supported password encodings.
 
Constructor Summary
Authorization()
           
 
Method Summary
 void addConfiguration(String name, net.sourceforge.guacamole.protocol.GuacamoleConfiguration config)
          Adds the given GuacamoleConfiguration to the set of stored configurations under the given name.
 net.sourceforge.guacamole.protocol.GuacamoleConfiguration getConfiguration(String name)
          Returns the GuacamoleConfiguration having the given name and associated with the username/password pair stored within this authorization.
 Map<String,net.sourceforge.guacamole.protocol.GuacamoleConfiguration> getConfigurations()
          Returns a Map of all stored GuacamoleConfigurations associated with the username/password pair stored within this authorization, indexed by configuration name.
 Authorization.Encoding getEncoding()
          Returns the encoding used to hash the password, if any.
 String getPassword()
          Returns the password associated with this authorization, which may be encoded or hashed.
 String getUsername()
          Returns the username associated with this authorization.
 void setEncoding(Authorization.Encoding encoding)
          Sets the encoding which will be used to hash the password or when comparing a given password for validation.
 void setPassword(String password)
          Sets the password associated with this authorization, which must be encoded using the encoding specified with setEncoding().
 void setUsername(String username)
          Sets the username associated with this authorization.
 boolean validate(String username, String password)
          Returns whether a given username/password pair is authorized based on the stored username and password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Authorization

public Authorization()
Method Detail

getUsername

public String getUsername()
Returns the username associated with this authorization.

Returns:
The username associated with this authorization.

setUsername

public void setUsername(String username)
Sets the username associated with this authorization.

Parameters:
username - The username to associate with this authorization.

getPassword

public String getPassword()
Returns the password associated with this authorization, which may be encoded or hashed.

Returns:
The password associated with this authorization.

setPassword

public void setPassword(String password)
Sets the password associated with this authorization, which must be encoded using the encoding specified with setEncoding(). By default, passwords are plain text.

Parameters:
password - Sets the password associated with this authorization.

getEncoding

public Authorization.Encoding getEncoding()
Returns the encoding used to hash the password, if any.

Returns:
The encoding used to hash the password.

setEncoding

public void setEncoding(Authorization.Encoding encoding)
Sets the encoding which will be used to hash the password or when comparing a given password for validation.

Parameters:
encoding - The encoding to use for password hashing.

validate

public boolean validate(String username,
                        String password)
Returns whether a given username/password pair is authorized based on the stored username and password. The password given must be plain text. It will be hashed as necessary to perform the validation.

Parameters:
username - The username to validate.
password - The password to validate.
Returns:
true if the username/password pair given is authorized, false otherwise.

getConfiguration

public net.sourceforge.guacamole.protocol.GuacamoleConfiguration getConfiguration(String name)
Returns the GuacamoleConfiguration having the given name and associated with the username/password pair stored within this authorization.

Parameters:
name - The name of the GuacamoleConfiguration to return.
Returns:
The GuacamoleConfiguration having the given name, or null if no such GuacamoleConfiguration exists.

addConfiguration

public void addConfiguration(String name,
                             net.sourceforge.guacamole.protocol.GuacamoleConfiguration config)
Adds the given GuacamoleConfiguration to the set of stored configurations under the given name.

Parameters:
name - The name to associate this GuacamoleConfiguration with.
config - The GuacamoleConfiguration to store.

getConfigurations

public Map<String,net.sourceforge.guacamole.protocol.GuacamoleConfiguration> getConfigurations()
Returns a Map of all stored GuacamoleConfigurations associated with the username/password pair stored within this authorization, indexed by configuration name.

Returns:
A Map of all stored GuacamoleConfigurations.


Copyright © 2013. All Rights Reserved.