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 |
Definition at line 51 of file AuthenticatingMBeanServer.java.
|
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 }
|
|
Overridden just to make it public
Reimplemented from org.objectweb.cjdbc.controller.jmx.ChainedMBeanServer. Definition at line 64 of file AuthenticatingMBeanServer.java. 00065 { 00066 super.setMBeanServer(server); 00067 }
|
|
Initial value: Trace
.getLogger("org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer")
Definition at line 55 of file AuthenticatingMBeanServer.java. Referenced by org.objectweb.cjdbc.controller.jmx.AuthenticatingMBeanServer.invoke(). |