[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security/config ...

Shane Bryzak Shane_Bryzak at symantec.com
Sun Jul 30 20:50:55 EDT 2006


  User: sbryzak2
  Date: 06/07/30 20:50:55

  Modified:    src/main/org/jboss/seam/security/config   
                        SecurityConfig.java SecurityConfigFileLoader.java
                        SecurityConfigLoader.java
  Log:
  Redesign
  
  Revision  Changes    Path
  1.4       +8 -10     jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfig.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SecurityConfig.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfig.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- SecurityConfig.java	26 Jul 2006 06:04:35 -0000	1.3
  +++ SecurityConfig.java	31 Jul 2006 00:50:55 -0000	1.4
  @@ -3,8 +3,7 @@
   import java.util.Collections;
   import java.util.Set;
   
  -import org.jboss.seam.security.authenticator.Authenticator;
  -import org.jboss.seam.security.realm.Realm;
  +import org.jboss.seam.security.filter.handler.Handler;
   import javax.servlet.ServletContext;
   
   /**
  @@ -37,7 +36,7 @@
     /**
      * The authenticator
      */
  -  private Authenticator authenticator;
  +  private Handler authenticator;
   
     /**
      * Security roles with access to the application
  @@ -47,7 +46,7 @@
     /**
      * Authentication realm
      */
  -  private Realm realm;
  +//  private Realm realm;
   
     /**
      * The ServletContext for this application.  This is required because various
  @@ -89,7 +88,6 @@
         authenticator.setSecurityConfig(this);
   
         securityRoles = configLoader.getSecurityRoles();
  -      realm = configLoader.getRealm();
   
         configLoaded = true;
       }
  @@ -135,7 +133,7 @@
      *
      * @return Authenticator
      */
  -  public Authenticator getAuthenticator()
  +  public Handler getAuthenticator()
     {
       return authenticator;
     }
  @@ -144,10 +142,10 @@
      *
      * @return Realm
      */
  -  public Realm getRealm()
  -  {
  -    return realm;
  -  }
  +//  public Realm getRealm()
  +//  {
  +//    return realm;
  +//  }
   
     /**
      *
  
  
  
  1.2       +12 -93    jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfigFileLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SecurityConfigFileLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfigFileLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- SecurityConfigFileLoader.java	25 Jul 2006 06:50:19 -0000	1.1
  +++ SecurityConfigFileLoader.java	31 Jul 2006 00:50:55 -0000	1.2
  @@ -11,11 +11,9 @@
   import org.dom4j.Document;
   import org.dom4j.Element;
   import org.dom4j.io.SAXReader;
  -import org.jboss.seam.security.authenticator.Authenticator;
  -import org.jboss.seam.security.authenticator.BasicAuthenticator;
  -import org.jboss.seam.security.authenticator.FormAuthenticator;
  -import org.jboss.seam.security.authenticator.SeamAuthenticator;
  -import org.jboss.seam.security.realm.Realm;
  +import org.jboss.seam.security.filter.handler.Handler;
  +import org.jboss.seam.security.filter.handler.BasicHandler;
  +import org.jboss.seam.security.filter.handler.FormHandler;
   
   /**
    * Loads the security configuration from an XML configuration file.
  @@ -49,22 +47,16 @@
     // <security-role>
     private static final String SECURITY_ROLE = "security-role";
   
  -  // <realm>
  -  private static final String REALM = "realm";
  -  private static final String CLASSNAME_ATTRIBUTE = "className";
  -
     private Set<SecurityConstraint> securityConstraints = new HashSet<SecurityConstraint>();
   
     private Set<String> securityRoles = new HashSet<String>();
   
     private AuthMethod authMethod;
   
  -  private Authenticator authenticator;
  +  private Handler authenticator;
   
     private ServletContext servletContext;
   
  -  private Realm realm;
  -
     /**
      * Constructor, loads the configuration from configFile.
      *
  @@ -85,7 +77,6 @@
         loadSecurityConstraints(env.elements(SECURITY_CONSTRAINT));
         loadLoginConfig(env.element(LOGIN_CONFIG));
         loadSecurityRoles(env.element(SECURITY_ROLE));
  -      loadRealm(env.element(REALM));
       }
       catch (Exception ex)
       {
  @@ -118,7 +109,7 @@
      *
      * @return Authenticator
      */
  -  public Authenticator getAuthenticator()
  +  public Handler getAuthenticator()
     {
       return authenticator;
     }
  @@ -133,15 +124,6 @@
     }
   
     /**
  -   *
  -   * @return Realm
  -   */
  -  public Realm getRealm()
  -  {
  -    return realm;
  -  }
  -
  -  /**
      * Load security constraints
      *
      * @param elements List
  @@ -223,20 +205,20 @@
       switch (authMethod)
       {
         case BASIC:
  -        authenticator = new BasicAuthenticator();
  +        authenticator = new BasicHandler();
           break;
         case FORM:
           Element formConfigElement = loginConfigElement.element(FORM_LOGIN_CONFIG);
           String loginPage = formConfigElement.elementText(FORM_LOGIN_PAGE);
           String errorPage = formConfigElement.elementText(FORM_ERROR_PAGE);
           String defaultPage = formConfigElement.elementText(FORM_DEFAULT_PAGE);
  -        authenticator = new FormAuthenticator(loginPage, errorPage, defaultPage);
  -        break;
  -      case SEAM:
  -        Element seamConfigElement = loginConfigElement.element(SEAM_LOGIN_CONFIG);
  -        loginPage = seamConfigElement.elementText(SEAM_LOGIN_PAGE);
  -        authenticator = new SeamAuthenticator(loginPage);
  +        authenticator = new FormHandler(loginPage, errorPage, defaultPage);
           break;
  +//      case SEAM:
  +//        Element seamConfigElement = loginConfigElement.element(SEAM_LOGIN_CONFIG);
  +//        loginPage = seamConfigElement.elementText(SEAM_LOGIN_PAGE);
  +//        authenticator = new SeamAuthenticator(loginPage);
  +//        break;
       }
   
       if (authenticator == null)
  @@ -259,67 +241,4 @@
         securityRoles.add(roleName.getTextTrim());
       }
     }
  -
  -  /**
  -   *
  -   * @param realmElement Element
  -   * @throws SecurityConfigException
  -   */
  -  private void loadRealm(Element realmElement)
  -      throws SecurityConfigException
  -  {
  -    String contextPath = "";
  -
  -    try
  -    {
  -      // Determine the context path from servletContext
  -      Class acfCls = Class.forName(
  -          "org.apache.catalina.core.ApplicationContextFacade");
  -      if (acfCls.isAssignableFrom(servletContext.getClass()))
  -      {
  -        Method getContextPath = acfCls.getMethod("getContextPath");
  -        contextPath = (String) getContextPath.invoke(servletContext);
  -      }
  -    }
  -    catch (Exception ex)
  -    {
  -      // Swallow exceptions here
  -    }
  -
  -    String realmClass = realmElement.attributeValue(CLASSNAME_ATTRIBUTE);
  -    try
  -    {
  -      Class cls = Class.forName(realmClass);
  -
  -      /**
  -       * The only reason we jump through the following hoops is so that
  -       * CatalinaRealm gets access to the servlet context path, otherwise we
  -       * would just use the default constructor for the realm.
  -       *
  -       * NOTE: we don't want to add a setServletContext() method to the Realm
  -       * interface at this stage because that would introduce a dependency on the
  -       * servlet API (though does it matter really???)
  -       *
  -       * TODO - see if this can be refactored into something more elegant
  -       */
  -      Constructor[] constructors = cls.getConstructors();
  -      if (constructors.length > 0 &&
  -          constructors[0].getParameterTypes().length == 1 &&
  -          constructors[0].getParameterTypes()[0].equals(String.class))
  -      {
  -        realm = (Realm) constructors[0].newInstance(contextPath);
  -      }
  -      else
  -        realm = (Realm) cls.newInstance();
  -    }
  -    catch (ClassNotFoundException ex)
  -    {
  -      throw new SecurityConfigException(
  -          String.format("Realm class [%s] not found.", realmClass), ex);
  -    }
  -    catch (Exception ex)
  -    {
  -      throw new SecurityConfigException("Error creating realm", ex);
  -    }
  -  }
   }
  
  
  
  1.2       +2 -4      jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfigLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SecurityConfigLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/config/SecurityConfigLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- SecurityConfigLoader.java	25 Jul 2006 06:50:19 -0000	1.1
  +++ SecurityConfigLoader.java	31 Jul 2006 00:50:55 -0000	1.2
  @@ -2,8 +2,7 @@
   
   import java.util.Set;
   
  -import org.jboss.seam.security.authenticator.Authenticator;
  -import org.jboss.seam.security.realm.Realm;
  +import org.jboss.seam.security.filter.handler.Handler;
   
   /**
    * <p> </p>
  @@ -14,7 +13,6 @@
   {
     Set<SecurityConstraint> getSecurityConstraints();
     AuthMethod getAuthMethod();
  -  Authenticator getAuthenticator();
  +  Handler getAuthenticator();
     Set<String> getSecurityRoles();
  -  Realm getRealm();
   }
  
  
  



More information about the jboss-cvs-commits mailing list