Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void setMBeanServer (MBeanServer server)
Object invoke (ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException

Static Package Attributes

Trace logger

Detailed Description

An MBeanServer authenticating all invoke() requests.

Author:
Marc Wick

Nicolas Modrzyk

Version:
1.0

Definition at line 51 of file AuthenticatingMBeanServer.java.


Member Function Documentation

Object org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.invoke ObjectName  name,
String  operationName,
Object[]  params,
String[]  signature
throws InstanceNotFoundException, MBeanException, ReflectionException
 

See also:
javax.management.MBeanServerConnection#invoke(javax.management.ObjectName, java.lang.String, java.lang.Object[], java.lang.String[])

Reimplemented from org.objectweb.cjdbc.controller.jmx.ChainedMBeanServer.

Definition at line 73 of file AuthenticatingMBeanServer.java.

References org.objectweb.cjdbc.common.users.AbstractDatabaseUser.getName(), org.objectweb.cjdbc.common.users.AbstractDatabaseUser.getPassword(), and org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.logger.

00076   {
00077     if (JmxConstants.mbeanNeedAuthentication(name)
00078         && (operationName.equalsIgnoreCase("checkAdminAuthentication") == false))
00079     {
00080       // we have to check all methods that access a virtual database
00081       // except
00082       // authentication
00083       boolean authenticationOk = false;
00084       String username = null;
00085       String password = null;
00086 
00087       Subject subject = Subject.getSubject(java.security.AccessController
00088           .getContext());
00089       if (subject == null || subject.getPrincipals().size() == 0)
00090       {
00091         username = (String) params[0];
00092         password = (String) params[1];
00093         authenticationOk = authenticate(name, username, password);
00094         if (!authenticationOk)
00095           throw new MBeanException(new Exception(
00096               "Authentication failed (username,password) invalid"));
00097 
00098         if (logger.isDebugEnabled())
00099           logger
00100               .debug("Authentication with username and password was successfull");
00101 
00102         // we have to strip the username and password from the params
00103         // and args
00104         return super.invoke(name, operationName, cleanO(params),
00105             cleanS(signature));
00106       }
00107       else
00108       {
00109         Set principals = subject.getPrincipals(AbstractDatabaseUser.class);
00110         for (Iterator it = principals.iterator(); it.hasNext();)
00111         {
00112           AbstractDatabaseUser user = (AbstractDatabaseUser) it.next();
00113           username = user.getName();
00114           password = user.getPassword();
00115           authenticationOk = authenticate(name, username, password);
00116           if (authenticationOk)
00117             break;
00118         }
00119 
00120         if (principals.size() == 0 && logger.isDebugEnabled())
00121           throw new MBeanException(new Exception(
00122               "Authentication failed : no principal"));
00123 
00124         if (!authenticationOk)
00125           throw new MBeanException(new Exception(
00126               "Authentication failed : principal invalid"));
00127         if (logger.isDebugEnabled())
00128           logger.debug("Authentication with principal was successfull");
00129         return super.invoke(name, operationName, params, signature);
00130       }
00131     }
00132     else
00133     {
00134       if (logger.isDebugEnabled())
00135         logger.debug("no authentication required");
00136 
00137       return super.invoke(name, operationName, params, signature);
00138     }
00139   }

void org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.setMBeanServer MBeanServer  server  ) 
 

Overridden just to make it public

See also:
org.objectweb.cjdbc.controller.jmx.ChainedMBeanServer#setMBeanServer(javax.management.MBeanServer)

Reimplemented from org.objectweb.cjdbc.controller.jmx.ChainedMBeanServer.

Definition at line 64 of file AuthenticatingMBeanServer.java.

00065   {
00066     super.setMBeanServer(server);
00067   }


Member Data Documentation

Trace org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.logger [static, package]
 

Initial value:

 Trace
                          .getLogger("org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer")
Logger instance

Definition at line 55 of file AuthenticatingMBeanServer.java.

Referenced by org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.invoke().


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:51 2005 for C-JDBC by  doxygen 1.3.9.1