org.outerj.xreporter.authorisation
Class AuthorisationManagerImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.outerj.xreporter.authorisation.AuthorisationManagerImpl
All Implemented Interfaces:
AuthorisationManager, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.thread.ThreadSafe

public class AuthorisationManagerImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements AuthorisationManager, org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable

Default implementation of the AuthorisationManager. Access to reports is allowed based on the roles of the user. Access to datasources is controlled by a datasource authorisation code. The association between roles and report id's is managed in a database table. The association between userss and datasource authorisation codes is also managed in a database table. The association between a datasource authorisation code and datasources is managed in an XML file.


Nested Class Summary
protected  class AuthorisationManagerImpl.AuthorisationCodesHandler
          ContentHandler to parse the file with datasource authorisation codes.
 
Field Summary
protected  java.lang.String accessControlStatementBase
           
protected  java.lang.String allAllowedReportsStatementBase
           
protected  java.lang.String authorisationCodesLocation
          Location of the file containing the authorisation code to datasource id mapping.
protected  java.lang.String authorisationCodeStatement
          SQL statement to get the authorisation code of a user
protected  java.util.Properties connectionProperties
           
protected  ConnectionProvider connectionProvider
           
protected  ConnectionProviderManager connectionProviderManager
           
protected  java.util.Map dataSourcesByAuthorisationCode
          The values in this map are Sets of authorisation codes.
 
Fields inherited from interface org.outerj.xreporter.authorisation.AuthorisationManager
ROLE
 
Constructor Summary
AuthorisationManagerImpl()
           
 
Method Summary
 void addRoleInClause(User user, java.lang.StringBuffer statement)
           
 int bindRoleInClause(User user, java.sql.PreparedStatement stmt, int start)
           
 boolean canAccessDataSource(User user, java.lang.String dataSourceId)
           
 boolean canAccessReport(User user, java.lang.String reportDefinitionId)
           
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 java.util.Set getAllowedDataSourceIds(User user)
          Returns a set of all data source id's (= String objects) that the user is allowed to access.
 java.util.Set getAllowedReportDefinitionIds(User user)
          Returns a set of all report definition id's (= String objects) that the user is allowed to access.
 java.lang.String getAuthorisationCode(User user)
          Fetches the user's authorisation code from the database.
 void initialize()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionProperties

protected java.util.Properties connectionProperties

connectionProviderManager

protected ConnectionProviderManager connectionProviderManager

connectionProvider

protected ConnectionProvider connectionProvider

accessControlStatementBase

protected java.lang.String accessControlStatementBase

allAllowedReportsStatementBase

protected java.lang.String allAllowedReportsStatementBase

dataSourcesByAuthorisationCode

protected java.util.Map dataSourcesByAuthorisationCode
The values in this map are Sets of authorisation codes.


authorisationCodesLocation

protected java.lang.String authorisationCodesLocation
Location of the file containing the authorisation code to datasource id mapping.


authorisationCodeStatement

protected java.lang.String authorisationCodeStatement
SQL statement to get the authorisation code of a user

Constructor Detail

AuthorisationManagerImpl

public AuthorisationManagerImpl()
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
             throws org.apache.avalon.framework.component.ComponentException
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Throws:
org.apache.avalon.framework.component.ComponentException

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

canAccessReport

public boolean canAccessReport(User user,
                               java.lang.String reportDefinitionId)
                        throws AuthorisationException
Specified by:
canAccessReport in interface AuthorisationManager
Throws:
AuthorisationException

getAllowedReportDefinitionIds

public java.util.Set getAllowedReportDefinitionIds(User user)
                                            throws AuthorisationException
Description copied from interface: AuthorisationManager
Returns a set of all report definition id's (= String objects) that the user is allowed to access.

Specified by:
getAllowedReportDefinitionIds in interface AuthorisationManager
Throws:
AuthorisationException

addRoleInClause

public void addRoleInClause(User user,
                            java.lang.StringBuffer statement)

bindRoleInClause

public int bindRoleInClause(User user,
                            java.sql.PreparedStatement stmt,
                            int start)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

canAccessDataSource

public boolean canAccessDataSource(User user,
                                   java.lang.String dataSourceId)
                            throws AuthorisationException
Specified by:
canAccessDataSource in interface AuthorisationManager
Throws:
AuthorisationException

getAllowedDataSourceIds

public java.util.Set getAllowedDataSourceIds(User user)
                                      throws AuthorisationException
Description copied from interface: AuthorisationManager
Returns a set of all data source id's (= String objects) that the user is allowed to access.

Specified by:
getAllowedDataSourceIds in interface AuthorisationManager
Throws:
AuthorisationException

getAuthorisationCode

public java.lang.String getAuthorisationCode(User user)
                                      throws AuthorisationException
Fetches the user's authorisation code from the database. If none is found, an empty string is returned.

Throws:
AuthorisationException