/** * Create a new JDBC Realm. * * @param parent MBean Name of the associated parent component * @param driverName JDBC driver name * @param connectionName the user name for the connection * @param connectionPassword the password for the connection * @param connectionURL the connection URL to the database * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ public String createJDBCRealm(String parent, String driverName, String connectionName, String connectionPassword, String connectionURL) throws Exception { // Create a new JDBCRealm instance JDBCRealm realm = new JDBCRealm(); realm.setDriverName(driverName); realm.setConnectionName(connectionName); realm.setConnectionPassword(connectionPassword); realm.setConnectionURL(connectionURL); // Add the new instance to its parent component return addRealmToParent(parent, realm); }
/** * Gracefully shut down active use of the public methods of this Component. * * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ public void stop() throws LifecycleException { // Perform normal superclass finalization super.stop(); // Close any open DB connection close(this.dbConnection); }
/** * Get the principal associated with the specified user. * @param username The user name * @return the Principal associated with the given user name. */ @Override protected synchronized Principal getPrincipal(String username) { return new GenericPrincipal(username, getPassword(username), getRoles(username)); }
try { open(); PreparedStatement stmt = credentials(dbConnection, username); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { close(dbConnection);
open(); Principal principal = authenticate(dbConnection, username, credentials); close(dbConnection);
String dbCredentials = getPassword(username); if (hasMessageDigest()) { validated = (digest(credentials).equalsIgnoreCase(dbCredentials)); } else { validated = (digest(credentials).equals(dbCredentials)); ArrayList roles = getRoles(username);
if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) { try { open(); PreparedStatement stmt = roles(dbConnection, username); try (ResultSet rs = stmt.executeQuery()) { close(dbConnection);
String dbCredentials = getPassword(username); getCredentialHandler().mutate(credentials); boolean validated = getCredentialHandler().matches(credentials, dbCredentials); ArrayList<String> roles = getRoles(username);
/** * * Prepare for active use of the public methods of this Component. * * @exception LifecycleException if this component detects a fatal error * that prevents it from being started */ public void start() throws LifecycleException { // Perform normal superclass initialization super.start(); // Validate that we can open our connection - but let tomcat // startup in case the database is temporarily unavailable try { open(); } catch (SQLException e) { containerLog.error(sm.getString("jdbcRealm.open"), e); } }
String dbCredentials = getPassword(username); boolean validated = compareCredentials(credentials, dbCredentials); ArrayList<String> roles = getRoles(username);
try { open(); PreparedStatement stmt = credentials(dbConnection, username); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { close(dbConnection);
open(); Principal principal = authenticate(dbConnection, username, credentials); close(dbConnection);
String dbCredentials = getPassword(username); if (hasMessageDigest()) { validated = (digest(credentials).equalsIgnoreCase(dbCredentials)); } else { validated = (digest(credentials).equals(dbCredentials)); ArrayList<String> roles = getRoles(username);
if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) { try { open(); PreparedStatement stmt = roles(dbConnection, username); try (ResultSet rs = stmt.executeQuery()) { close(dbConnection);
String dbCredentials = getPassword(username); getCredentialHandler().mutate(credentials); boolean validated = getCredentialHandler().matches(credentials, dbCredentials); ArrayList<String> roles = getRoles(username);
/** * Prepare for the beginning of active use of the public methods of this * component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { // Validate that we can open our connection - but let tomcat // startup in case the database is temporarily unavailable try { open(); } catch (SQLException e) { containerLog.error(sm.getString("jdbcRealm.open"), e); } super.startInternal(); }
/** * Create a new JDBC Realm. * * @param parent MBean Name of the associated parent component * @param driverName JDBC driver name * @param connectionName the user name for the connection * @param connectionPassword the password for the connection * @param connectionURL the connection URL to the database * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ public String createJDBCRealm(String parent, String driverName, String connectionName, String connectionPassword, String connectionURL) throws Exception { // Create a new JDBCRealm instance JDBCRealm realm = new JDBCRealm(); realm.setDriverName(driverName); realm.setConnectionName(connectionName); realm.setConnectionPassword(connectionPassword); realm.setConnectionURL(connectionURL); // Add the new instance to its parent component return addRealmToParent(parent, realm); }
open(); stmt = credentials(dbConnection, username); rs = stmt.executeQuery(); close(dbConnection);