congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DataSourceRealm
Code IndexAdd Tabnine to your IDE (free)

How to use
DataSourceRealm
in
org.apache.catalina.realm

Best Java code snippets using org.apache.catalina.realm.DataSourceRealm (Showing top 20 results out of 315)

origin: org.apache.tomcat/tomcat-catalina

/**
 * Create a new DataSource Realm.
 *
 * @param parent MBean Name of the associated parent component
 * @param dataSourceName the datasource name
 * @param roleNameCol the column name for the role names
 * @param userCredCol the column name for the user credentials
 * @param userNameCol the column name for the user names
 * @param userRoleTable the table name for the roles table
 * @param userTable the table name for the users
 * @return the object name of the created realm
 * @exception Exception if an MBean cannot be created or registered
 */
public String createDataSourceRealm(String parent, String dataSourceName,
  String roleNameCol, String userCredCol, String userNameCol,
  String userRoleTable, String userTable) throws Exception {
  // Create a new DataSourceRealm instance
  DataSourceRealm realm = new DataSourceRealm();
  realm.setDataSourceName(dataSourceName);
  realm.setRoleNameCol(roleNameCol);
  realm.setUserCredCol(userCredCol);
  realm.setUserNameCol(userNameCol);
  realm.setUserRoleTable(userRoleTable);
  realm.setUserTable(userTable);
  // Add the new instance to its parent component
  return addRealmToParent(parent, realm);
}
origin: com.ovea.tajin.server/tajin-server-tomcat7

dbConnection = open();
if (dbConnection == null) {
Principal principal = authenticate(dbConnection, username, credentials);
close(dbConnection);
origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Return the Principal associated with the given user name.
 */
@Override
protected Principal getPrincipal(String username) {
  Connection dbConnection = open();
  if (dbConnection == null) {
    return new GenericPrincipal(username, null, null);
  }
  try {
    return (new GenericPrincipal(username,
        getPassword(dbConnection, username),
        getRoles(dbConnection, username)));
  } finally {
    close(dbConnection);
  }
}
origin: org.apache.tomcat/tomcat-catalina

/**
 * @return the password associated with the given principal's user name.
 */
@Override
protected String getPassword(String username) {
  Connection dbConnection = null;
  // Ensure that we have an open database connection
  dbConnection = open();
  if (dbConnection == null) {
    return null;
  }
  try {
    return getPassword(dbConnection, username);
  } finally {
    close(dbConnection);
  }
}
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Return the roles associated with the given user name.
 * @param username User name for which roles should be retrieved
 * @return an array list of the role names
 */
protected ArrayList<String> getRoles(String username) {
  Connection dbConnection = null;
  // Ensure that we have an open database connection
  dbConnection = open();
  if (dbConnection == null) {
    return null;
  }
  try {
    return getRoles(dbConnection, username);
  } finally {
    close(dbConnection);
  }
}
origin: tomcat/catalina-optional

                    String credentials) throws SQLException{
String dbCredentials = getPassword(dbConnection, username);
if (hasMessageDigest()) {
  validated = (digest(credentials).equalsIgnoreCase(dbCredentials));
} else
  validated = (digest(credentials).equals(dbCredentials));
ArrayList list = getRoles(dbConnection, username);
origin: org.apache.tomcat/tomcat-catalina

String dbCredentials = getPassword(dbConnection, username);
  getCredentialHandler().mutate(credentials);
boolean validated = getCredentialHandler().matches(credentials, dbCredentials);
ArrayList<String> list = getRoles(dbConnection, username);
origin: org.apache.tomcat/tomcat-catalina

/**
 * Return the password associated with the given principal's user name.
 * @param dbConnection The database connection to be used
 * @param username Username for which password should be retrieved
 * @return the password for the specified user
 */
protected String getPassword(Connection dbConnection,
               String username) {
  String dbCredentials = null;
  try (PreparedStatement stmt = credentials(dbConnection, username);
      ResultSet rs = stmt.executeQuery()) {
    if (rs.next()) {
      dbCredentials = rs.getString(1);
    }
    return (dbCredentials != null) ? dbCredentials.trim() : null;
  } catch (SQLException e) {
    containerLog.error(
        sm.getString("dataSourceRealm.getPassword.exception",
               username), e);
  }
  return null;
}
origin: codefollower/Tomcat-Research

                    String credentials) {
String dbCredentials = getPassword(dbConnection, username);
boolean validated = compareCredentials(credentials, dbCredentials);
ArrayList<String> list = getRoles(dbConnection, username);
origin: org.apache.tomcat/tomcat-catalina

/**
 * Return the roles associated with the given user name
 * @param dbConnection The database connection to be used
 * @param username User name for which roles should be retrieved
 * @return an array list of the role names
 */
protected ArrayList<String> getRoles(Connection dbConnection,
                 String username) {
  if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) {
    // Using an authentication only configuration and no role store has
    // been defined so don't spend cycles looking
    return null;
  }
  ArrayList<String> list = null;
  try (PreparedStatement stmt = roles(dbConnection, username);
      ResultSet rs = stmt.executeQuery()) {
    list = new ArrayList<>();
    while (rs.next()) {
      String role = rs.getString(1);
      if (role != null) {
        list.add(role.trim());
      }
    }
    return list;
  } catch(SQLException e) {
    containerLog.error(
      sm.getString("dataSourceRealm.getRoles.exception", username), e);
  }
  return null;
}
origin: tomcat/catalina-optional

stmt = roles(dbConnection, username);
rs = stmt.executeQuery();
list = new ArrayList();
origin: tomcat/catalina-optional

/**
 * Return the password associated with the given principal's user name.
 */
protected String getPassword(String username) {
  Connection dbConnection = null;
  // Ensure that we have an open database connection
  dbConnection = open();
  if (dbConnection == null) {
    return null;
  }
  try {
    return getPassword(dbConnection, username);        	
  } finally {
    close(dbConnection);
  }
}

origin: org.apache.catalina/com.springsource.org.apache.catalina

/**
 * Return the roles associated with the given user name.
 * @param username Username for which roles should be retrieved
 */
protected ArrayList<String> getRoles(String username) {
  Connection dbConnection = null;
  // Ensure that we have an open database connection
  dbConnection = open();
  if (dbConnection == null) {
    return null;
  }
  try {
    return getRoles(dbConnection, username);
  } finally {
    close(dbConnection);
  }
}
 
origin: org.apache.geronimo.ext.tomcat/catalina

                    String credentials) {
String dbCredentials = getPassword(dbConnection, username);
if (hasMessageDigest()) {
  validated = (digest(credentials).equalsIgnoreCase(dbCredentials));
} else
  validated = (digest(credentials).equals(dbCredentials));
ArrayList<String> list = getRoles(dbConnection, username);
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

String dbCredentials = getPassword(dbConnection, username);
  getCredentialHandler().mutate(credentials);
boolean validated = getCredentialHandler().matches(credentials, dbCredentials);
ArrayList<String> list = getRoles(dbConnection, username);
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Return the password associated with the given principal's user name.
 * @param dbConnection The database connection to be used
 * @param username Username for which password should be retrieved
 * @return the password for the specified user
 */
protected String getPassword(Connection dbConnection,
               String username) {
  String dbCredentials = null;
  try (PreparedStatement stmt = credentials(dbConnection, username);
      ResultSet rs = stmt.executeQuery()) {
    if (rs.next()) {
      dbCredentials = rs.getString(1);
    }
    return (dbCredentials != null) ? dbCredentials.trim() : null;
  } catch (SQLException e) {
    containerLog.error(
        sm.getString("dataSourceRealm.getPassword.exception",
               username), e);
  }
  return null;
}
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Return the roles associated with the given user name
 * @param dbConnection The database connection to be used
 * @param username User name for which roles should be retrieved
 * @return an array list of the role names
 */
protected ArrayList<String> getRoles(Connection dbConnection,
                 String username) {
  if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) {
    // Using an authentication only configuration and no role store has
    // been defined so don't spend cycles looking
    return null;
  }
  ArrayList<String> list = null;
  try (PreparedStatement stmt = roles(dbConnection, username);
      ResultSet rs = stmt.executeQuery()) {
    list = new ArrayList<>();
    while (rs.next()) {
      String role = rs.getString(1);
      if (role != null) {
        list.add(role.trim());
      }
    }
    return list;
  } catch(SQLException e) {
    containerLog.error(
      sm.getString("dataSourceRealm.getRoles.exception", username), e);
  }
  return null;
}
origin: com.ovea.tajin.server/tajin-server-jetty9

stmt = roles(dbConnection, username);
rs = stmt.executeQuery();
list = new ArrayList<String>();
origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Create a new DataSource Realm.
 *
 * @param parent MBean Name of the associated parent component
 * @param dataSourceName the datasource name
 * @param roleNameCol the column name for the role names
 * @param userCredCol the column name for the user credentials
 * @param userNameCol the column name for the user names
 * @param userRoleTable the table name for the roles table
 * @param userTable the table name for the users
 * @return the object name of the created realm
 * @exception Exception if an MBean cannot be created or registered
 */
public String createDataSourceRealm(String parent, String dataSourceName,
  String roleNameCol, String userCredCol, String userNameCol,
  String userRoleTable, String userTable) throws Exception {
  // Create a new DataSourceRealm instance
  DataSourceRealm realm = new DataSourceRealm();
  realm.setDataSourceName(dataSourceName);
  realm.setRoleNameCol(roleNameCol);
  realm.setUserCredCol(userCredCol);
  realm.setUserNameCol(userNameCol);
  realm.setUserRoleTable(userRoleTable);
  realm.setUserTable(userTable);
  // Add the new instance to its parent component
  return addRealmToParent(parent, realm);
}
origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Return the Principal associated with the given user name.
 */
@Override
protected Principal getPrincipal(String username) {
  Connection dbConnection = open();
  if (dbConnection == null) {
    return new GenericPrincipal(username, null, null);
  }
  try {
    return (new GenericPrincipal(username,
        getPassword(dbConnection, username),
        getRoles(dbConnection, username)));
  } finally {
    close(dbConnection);
  }
}
org.apache.catalina.realmDataSourceRealm

Javadoc

Implementation of Realm that works with any JDBC JNDI DataSource. See the JDBCRealm.howto for more details on how to set up the database and for configuration options.

Most used methods

  • <init>
  • authenticate
    Return the Principal associated with the specified username and credentials, if there is one; otherw
  • close
    Close the specified database connection.
  • credentials
    Return a PreparedStatement configured to perform the SELECT required to retrieve user credentials fo
  • getPassword
    Return the password associated with the given principal's user name.
  • getRoles
    Return the roles associated with the given user name
  • open
    Open the specified database connection.
  • roles
    Return a PreparedStatement configured to perform the SELECT required to retrieve user roles for the
  • setDataSourceName
    Set the name of the JNDI JDBC DataSource.
  • setRoleNameCol
    Set the column in the user role table that names a role.
  • setUserCredCol
    Set the column in the user table that holds the user's credentials.
  • setUserNameCol
    Set the column in the user table that holds the user's name.
  • setUserCredCol,
  • setUserNameCol,
  • setUserRoleTable,
  • setUserTable,
  • getServer,
  • getObjectName,
  • digest,
  • hasMessageDigest,
  • isRoleStoreDefined,
  • getCredentialHandler

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JFrame (javax.swing)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now