User: jules_gosnell
  Date: 02/04/04 23:01:36

  Modified:    jetty/src/main/org/jboss/jetty/security JBossUserRealm.java
  Log:
  tidy up and optimise
  
  Revision  Changes    Path
  1.7       +27 -32    
contrib/jetty/src/main/org/jboss/jetty/security/JBossUserRealm.java
  
  Index: JBossUserRealm.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jetty/src/main/org/jboss/jetty/security/JBossUserRealm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JBossUserRealm.java       21 Mar 2002 12:12:34 -0000      1.6
  +++ JBossUserRealm.java       5 Apr 2002 07:01:35 -0000       1.7
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: JBossUserRealm.java,v 1.6 2002/03/21 12:12:34 janb Exp $
  +// $Id: JBossUserRealm.java,v 1.7 2002/04/05 07:01:35 jules_gosnell Exp $
   
   package org.jboss.jetty.security;
   
  @@ -29,30 +29,30 @@
   /** An implementation of UserRealm that integrates with the JBossSX
    * security manager associted with the web application.
    * @author  [EMAIL PROTECTED]
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   
  -// TODO
  -
   public class JBossUserRealm
     implements UserRealm               // Jetty API
   {
  +  private final Logger                 _log;
  +  private final String                 _realmName;
  +  private final String                 _subjAttrName;
  +  private final boolean                _useJAAS;
  +  private final HashMap                _users        =new HashMap();
  +  private       AuthenticationManager  _authMgr      =null;
  +  private       RealmMapping           _realmMapping =null;
  +  private       SubjectSecurityManager _subjSecMgr   =null;
  +
     class JBossUserPrincipal
  -    extends SimplePrincipal  // JBoss API
       implements UserPrincipal // Jetty API
     {
  +    private final SimplePrincipal _principal;        // JBoss API
  +    private String                _password;
   
  -      
  -      /* ------------------------------------------------------------ */
  -      /*  principal's credential
  -       */
  -      private String  _password;
  -
  -
  -      
       JBossUserPrincipal(String name)
       {
  -      super(name);
  +      _principal=new SimplePrincipal(name);
   
         if (_log.isDebugEnabled())
        _log.debug("created JBossUserRealm::JBossUserPrincipal: "+name);
  @@ -61,7 +61,6 @@
       protected boolean
         isAuthenticated(String password)
       {
  -      String  userName      = this.getName(); // needs disambiguation because our 
outer class....
         boolean authenticated = false;
   
         if (password==null)
  @@ -69,22 +68,22 @@
   
         char[] passwordChars = password.toCharArray();
         if (_log.isDebugEnabled())
  -     _log.debug("authenticating: Name:"+userName+" Password:****"/*+password*/);
  +     _log.debug("authenticating: Name:"+_principal+" Password:****"/*+password*/);
         if(_authMgr!=null &&_authMgr.isValid(this, passwordChars))
         {
        if (_log.isDebugEnabled())
  -       _log.debug("authenticated: "+userName);
  +       _log.debug("authenticated: "+_principal);
   
        // work around the fact that we are not serialisable - thanks Anatoly
        //      SecurityAssociation.setPrincipal(this);
  -     SecurityAssociation.setPrincipal(new SimplePrincipal(userName));
  +     SecurityAssociation.setPrincipal(_principal);
   
        SecurityAssociation.setCredential(passwordChars);
        authenticated=true;
         }
         else
         {
  -     _log.warn("authentication failure: "+userName);
  +     _log.warn("authentication failure: "+_principal);
         }
   
         return authenticated;
  @@ -117,6 +116,12 @@
       //----------------------------------------
       // SimplePrincipal - for JBoss
   
  +    public String
  +      getName()
  +    {
  +      return _principal.getName();
  +    }
  +
       //----------------------------------------
       // UserPrincipal - for Jetty
   
  @@ -156,40 +161,30 @@
         isUserInRole(String role)
       {
         boolean isUserInRole = false;
  -      String userName      = this.getName();
   
         Set requiredRoles = Collections.singleton(new SimplePrincipal(role));
         if(_realmMapping!=null && _realmMapping.doesUserHaveRole(this, requiredRoles))
         {
        if (_log.isDebugEnabled())
  -       _log.debug("JBossUserPrincipal: "+userName+" is in Role: "+role);
  +       _log.debug("JBossUserPrincipal: "+_principal+" is in Role: "+role);
   
        isUserInRole = true;
         }
         else
         {
        if (_log.isDebugEnabled())
  -       _log.debug("JBossUserPrincipal: "+userName+" is NOT in Role: "+role);
  +       _log.debug("JBossUserPrincipal: "+_principal+" is NOT in Role: "+role);
         }
   
         return isUserInRole;
       }
     }
   
  -  private Logger                 _log;
  -  private String                 _realmName;
  -  private AuthenticationManager  _authMgr;
  -  private RealmMapping           _realmMapping;
  -  private HashMap                _users = new HashMap();
  -  private SubjectSecurityManager _subjSecMgr;
  -  private String                 _subjAttrName;
  -  private boolean                _useJAAS;
  -
     public
       JBossUserRealm(String realmName, String subjAttrName)
     {
  -    _log          = Logger.getLogger(JBossUserRealm.class.getName() + "#" + 
_realmName);
       _realmName    = realmName;
  +    _log          = Logger.getLogger(JBossUserRealm.class.getName() + "#" + 
_realmName);
       _subjAttrName = subjAttrName;
       _useJAAS      = (_subjAttrName!=null);
   
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to