1 23 24 package com.sun.enterprise.security.auth.login; 25 26 import java.util.logging.Level ; 27 28 import com.sun.enterprise.security.LoginException; 29 import com.sun.enterprise.security.auth.login.PasswordLoginModule; 30 import com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm; 31 32 33 39 public class JDBCLoginModule extends PasswordLoginModule { 40 45 protected void authenticate() throws LoginException { 46 if (!(_currentRealm instanceof JDBCRealm)) { 47 String msg = sm.getString("jdbclm.badrealm"); 48 throw new LoginException(msg); 49 } 50 51 final JDBCRealm jdbcRealm = (JDBCRealm)_currentRealm; 52 53 if ( (_username == null) || (_username.length() == 0) ) { 55 String msg = sm.getString("jdbclm.nulluser"); 56 throw new LoginException(msg); 57 } 58 59 String [] grpList = jdbcRealm.authenticate(_username, _password); 60 61 if (grpList == null) { String msg = sm.getString("jdbclm.loginfail", _username); 63 throw new LoginException(msg); 64 } 65 66 if (_logger.isLoggable(Level.FINEST)) { 67 _logger.finest("JDBC login succeeded for: " + _username 68 + " groups:" + grpList); 69 } 70 71 final String [] groupListToForward = new String [grpList.length]; 75 System.arraycopy(grpList, 0, groupListToForward, 0, grpList.length); 76 77 commitAuthentication(_username, _password, 78 _currentRealm, groupListToForward); 79 } 80 } 81 | Popular Tags |