Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jetty.security
Class JDBCLoginService

    java.lang.Object
      org.eclipse.jetty.util.component.AbstractLifeCycle
          org.eclipse.jetty.security.MappedLoginService
              org.eclipse.jetty.security.JDBCLoginService

All Implemented Interfaces:
  LoginService, LifeCycle

    public class JDBCLoginService

extends MappedLoginService

HashMapped User Realm with JDBC as data source. JDBCLoginService extends HashULoginService and adds a method to fetch user information from database. The login() method checks the inherited Map for the user. If the user is not found, it will fetch details from the database and populate the inherited Map. It then calls the superclass login() method to perform the actual authentication. Periodically (controlled by configuration parameter), internal hashes are cleared. Caching can be disabled by setting cache refresh interval to zero. Uses one database connection that is initialized at startup. Reconnect on failures. authenticate() is 'synchronized'. An example properties file for configuration is in $JETTY_HOME/etc/jdbcRealm.properties

Version:
  $Id: JDBCLoginService.java 4792 2009-03-18 21:55:52Z gregw $

Nested Class Summary

Nested classes/interfaces inherited from class org.eclipse.jetty.security.MappedLoginService
`MappedLoginService.Anonymous, MappedLoginService.KnownUser, MappedLoginService.RolePrincipal, MappedLoginService.UserPrincipal`

Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`AbstractLifeCycle.AbstractLifeCycleListener`

Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
`LifeCycle.Listener`

Field Summary

Fields inherited from class org.eclipse.jetty.security.MappedLoginService
`_identityService, _name, _users`

Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

Constructor Summary
`JDBCLoginService()`
`JDBCLoginService(java.lang.String name)`
`JDBCLoginService(java.lang.String name, IdentityService identityService, java.lang.String config)`
`JDBCLoginService(java.lang.String name, java.lang.String config)`

Method Summary
`void` | `connectDatabase()` (re)Connect to database with parameters setup by loadConfig()
`protected void` | `doStart()`
`java.lang.String` | `getConfig()`
`protected UserIdentity` | `loadUser(java.lang.String username)`
`protected void` | `loadUsers()`
`UserIdentity` | `login(java.lang.String username, java.lang.Object credentials)` Login a user.
`void` | `setConfig(java.lang.String config)` Load JDBC connection configuration from properties file.

Methods inherited from class org.eclipse.jetty.security.MappedLoginService
`doStop, getIdentityService, getName, getUsers, logout, putUser, putUser, removeUser, setIdentityService, setName, setUsers, toString, validate`

Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JDBCLoginService

    public JDBCLoginService()
                     throws java.io.IOException

Throws:
  `java.io.IOException`

### JDBCLoginService

    public JDBCLoginService(java.lang.String name)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

### JDBCLoginService

    public JDBCLoginService(java.lang.String name,
                            java.lang.String config)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

### JDBCLoginService

    public JDBCLoginService(java.lang.String name,
                            IdentityService identityService,
                            java.lang.String config)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### doStart

    protected void doStart()
                    throws java.lang.Exception

  Overrides:
    `doStart` in class `MappedLoginService`
  Throws:
    `java.lang.Exception`
  See Also:
    `MappedLoginService.doStart()`

### getConfig

    public java.lang.String getConfig()

### setConfig

    public void setConfig(java.lang.String config)

  Load JDBC connection configuration from properties file.

  Parameters:
    `config` - Filename or url of user properties file.

### connectDatabase

    public void connectDatabase()

  (re)Connect to database with parameters setup by loadConfig()

### login

    public UserIdentity login(java.lang.String username,
                              java.lang.Object credentials)

  Description copied from interface: `LoginService`
  Login a user.

  Specified by:
    `login` in interface `LoginService`
  Overrides:
    `login` in class `MappedLoginService`
  Parameters:
    `username` - The user name
    `credentials` - The users credentials
  Returns:
    A UserIdentity if the credentials matched, otherwise null
  See Also:
    `LoginService.login(java.lang.String, java.lang.Object)`

### loadUsers

    protected void loadUsers()

  Specified by:
    `loadUsers` in class `MappedLoginService`

### loadUser

    protected UserIdentity loadUser(java.lang.String username)

  Specified by:
    `loadUser` in class `MappedLoginService`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.