installation de jGuard dans j2ee

  1. Librairies requises
  2. AccessFilter et web.xml
  3. Integrer jGuard dans vos jsp
  4. Integrer jGuard dans vos servlets

Login Modules

Authorization Managers

jGuard avancé

installation de jGuard sur la jvm

  1. java.home
  2. librairies et bootclasspath
  3. java.security
  4. jGuard.loginScheme
  5. jGuard.policy








AccessFilter et web.xml

Ajoutez à votre web.xml, la partie déclarant le servlet filter(AccessFilter) de jGuard et configurez le:
net.sf.jguard.filters.AccessFilter doit être localisé au début de la liste des servlet filters dans web.xml, pour restreindre toutes les ressources protégées. Son role est aussi de configurer le mécanisme d'autorisation pour l'application web. Ainsi, il requiert des paramètres 'récurrents', et des paramètres spécifiques aux mécanismes d'autorisation. Ici sont décrits les paramètres récurrents:

    .........
    .........
      <filter>
        <filter-name>AccessFilter</filter-name>
         <description>access filter</description>
        <filter-class>net.sf.jguard.filters.AccessFilter</filter-class>
        <!--global settings -->
        <init-param>
            <param-name>loginField</param-name>
            <param-value>login</param-value>
            <description>parameter's name of the form's field which holds the login</description>
        </init-param>
        <init-param>
            <param-name>passwordField</param-name>
            <param-value>password</param-value>
            <description>parameter's name of the form's field which holds the password</description>
        </init-param>
        <!--global settings -->
        <!-- authentication settings -->
        <init-param>
            <param-name>indexURI</param-name>
            <param-value>/myApplication/index.jsp</param-value>
            <description>page to redirect if authentication success</description>
        </init-param>
        <init-param>
            <param-name>authenticationFailedURI</param-name>
            <param-value>
            /myApplication/SwitchToModule.do?prefix=/reg&page=/Logon.do&authenticationFailed=authentication%20Failed
            </param-value>
            <description>page to redirect if authentication failed</description>
        </init-param>
        <init-param>
            <param-name>logonProcessURI</param-name>
            <param-value>/myApplication/reg/LogonProcess.do</param-value>
            <description>page with authentication form</description>
        </init-param>
        <init-param>
            <param-name>logoffURI</param-name>
            <param-value>/myApplication/reg/Logoff.do</param-value>
            <description>uri to logoff</description>
        </init-param>
        <init-param>
            <param-name>accessDeniedURI</param-name>
            <param-value>/myApplication/AccessDenied.do</param-value>
            <description>page to redirect if access to the rssource is denied</description>
        </init-param>
        <init-param>
            <param-name>loginModules</param-name>
            <param-value>net.sf.jguard.loginmodules.XmlLoginModule</param-value>
            <description> loginModules used for authentication, and splitted with the ',' character </description>
        </init-param>
        <init-param>
            <param-name>net.sf.jguard.loginmodules.XmlLoginModule.Flag</param-name>
            <param-value>required</param-value>
            <description>flag corresponding to the first loginModule. each loginModule defined
             above must have his own Flag which can be 'REQUIRED','OPTIONAL','REQUISITE',
            or 'SUFFICIENT'</description>
        </init-param>
        <init-param>
            <param-name>net.sf.jguard.loginmodules.XmlLoginModule.Options</param-name>
            <param-value>debug="false",fileLocation="WEBAPP_HOME/WEB-INF/conf/jGuard/jGuardUsersRoles.xml"</param-value>
            <description>
            options related to one of the loginModule defined in the 'loginModules' init parameters. WEBAPP_HOME is
            a reserved keyword, and refers to the webapp location.it permits to avoid webapp resolution (which is automatically
            detected by jGuard).
            </description>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
            <description>enable debug with true to trace authorization settings</description>
        </init-param>
        <!-- authentication settings -->
        <!-- authorization settings -->
        <init-param>
            <param-name>authorizationManager</param-name>
            <param-value>net.sf.jguard.authorization.XmlPermissionManager</param-value>
            <description>class which handle to collect permissionsCollection</description>
        </init-param>

        <!-- XmlAuthorizationManager parameter -->
        <init-param>
            <param-name>fileLocation</param-name>
            <param-value>D:\jGuardPrincipalsPermissions.xml</param-value>
            <description>xml file Location</description>
        </init-param>
        <!-- XmlAuthorizationManager parameter -->

        <!-- authorization settings -->
  </filter>
  <filter-mapping>
    .........
    .........
  </filter-mapping>
    <listener>
    <listener-class>net.sf.jguard.listeners.SessionListener</listener-class>
    </listener>
    <listener>
    <listener-class>net.sf.jguard.listeners.ContextListener</listener-class>
  </listener>
  .........
  .........