Changeset 280


Ignore:
Timestamp:
12/02/11 14:42:13 (13 years ago)
Author:
vmipsl
Message:

Encrypt password

Location:
ether_megapoli/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java

    r269 r280  
    2828    public static final String PARAMETER_STATE = "state"; 
    2929    public static final String PARAMETER_HAS_ACCESS = "hasAccess"; 
     30    public static final String PARAMETER_KEEP_SAME_PASSWORD = "keepSamePassword"; 
    3031} 
  • ether_megapoli/trunk/common/implementation/com/medias/Context.java

    r251 r280  
    11package com.medias; 
    22 
    3 import com.medias.annuaire.Personne; 
     3import com.ether.user.User; 
    44import net.sf.json.JSONObject; 
    55import org.apache.struts.Globals; 
     
    190190        final JSONObject jSONPeople = new JSONObject(); 
    191191 
    192         final Personne people = (Personne) request.getSession().getAttribute( "SES_USER" ); 
    193         if( null == people ) 
     192        final User user = (User) request.getSession().getAttribute( "SES_USER" ); 
     193        if( null == user ) 
    194194            return null; 
    195195 
    196         jSONPeople.put( "name", people.getNom() ); 
    197         jSONPeople.put( "firstName", people.getPrenom() ); 
    198         jSONPeople.put( "role", people.getRoles() ); 
     196        jSONPeople.put( "name", user.getLastName() ); 
     197        jSONPeople.put( "firstName", user.getFirstName() ); 
     198        jSONPeople.put( "role", user.getRole().name() ); 
    199199        return jSONPeople; 
    200200    } 
  • ether_megapoli/trunk/service/implementation/com/medias/megapoli/struts/forms/DatasForm.java

    r151 r280  
    44package com.medias.megapoli.struts.forms; 
    55 
     6import com.ether.user.User; 
    67import com.medias.DateTime; 
    78import com.medias.Nombre; 
    8 import com.medias.annuaire.Personne; 
    99import com.medias.database.objects.Capteur; 
    1010import com.medias.database.objects.Jeu; 
     
    259259    { 
    260260        ActionErrors errors = new ActionErrors(); 
    261         Personne pers = (Personne) arg1.getSession().getAttribute( "SES_USER" ); 
    262         if( pers == null ) 
     261        final User user = (User) arg1.getSession().getAttribute( "SES_USER" ); 
     262        if( user == null ) 
    263263        { 
    264264            errors.add( "dateFin", new ActionError( "errors.access.login" ) ); 
  • ether_megapoli/trunk/service/implementation/com/medias/megapoli/utils/MegapoliInitialisation.java

    r170 r280  
    1616/** 
    1717 * @author Caroline Combaz 
    18  * Created on 02 fev. 2005 
     18 *         Created on 02 fev. 2005 
    1919 */ 
    20 public class MegapoliInitialisation extends HttpServlet { 
     20public class MegapoliInitialisation 
     21        extends HttpServlet 
     22{ 
    2123 
    2224    /** 
    23      *  
     25     * 
    2426     */ 
    2527    private static final long serialVersionUID = 1L; 
    2628    // Le chemin vers les images des plates-formes 
    2729    public static String pathImages; 
    28      
    29         /** 
    30          * Constructeur par defaut 
    31          */ 
    32         public MegapoliInitialisation() { 
    33                 super(); 
    34         } 
    3530 
    36         /** 
    37          * Destruction de la servlet  
    38          */ 
    39         public void destroy() { 
    40                 super.destroy(); // Just puts "destroy" string in log 
    41         } 
     31    /** 
     32     * Constructeur par defaut 
     33     */ 
     34    public MegapoliInitialisation() 
     35    { 
     36        super(); 
     37    } 
    4238 
    43         /** 
    44          * Initialisation de la servlet :  
    45          * <ul> 
    46          *              <li>un objet representant l'arborescence de fichiers du site de depot est cree et place au niveau de l'application, 
    47          *              <li>l'arborescence de dossiers est egalement creee, 
    48          *              <li>la vue representant cette arborescence, et permettant a l'utilisateur de deposer de nouveaux fichiers est generee. 
    49          * </ul> 
    50          * @throws ServletException if an error occure 
    51          */ 
    52         public void init () throws ServletException { 
    53                 System.out.println ("************** INITIALISATION MEGAPOLI **************"); 
    54                 String root = this.getServletContext().getRealPath(""); 
    55                 String webinf = this.getServletContext().getRealPath("WEB-INF"); 
    56                  
    57                 //on charge le fichier de proprietes 
    58                 Properties prop = new Properties(); 
    59                 try { 
    60                         prop.load(new FileInputStream (webinf + "/megapoli.properties")); 
    61                 } 
    62                 catch (Exception e) { 
    63                         e.printStackTrace(); 
    64                 } 
    65                 //on initialise l'objet représentant l'arborescence de fichiers du site de dépot et on le place au niveau de l'appli 
    66                 String uploadRoot = prop.getProperty("data.upload.root"); 
    67                 String uploadFile = prop.getProperty("data.upload.desc"); 
    68                 String accessRoot = prop.getProperty ("data.access.root"); 
    69                 this.getServletContext().setAttribute("DataDescPathName", uploadFile); 
    70                 pathImages = prop.getProperty("data.img"); 
    71                 Hashtable<String, String> uploadStylesheets = new Hashtable<String, String>(); 
    72                 uploadStylesheets.put( Hierarchie.TREE, webinf + prop.getProperty("data.upload.tree.stylesheet")); 
    73                 uploadStylesheets.put(Hierarchie.FILES, webinf + prop.getProperty("data.upload.files.stylesheet")); 
    74                 Hashtable<String, String> uploadViews = new Hashtable<String, String>(); 
    75                 uploadViews.put(Hierarchie.TREE,root + prop.getProperty("data.upload.tree.view")); 
    76                 uploadViews.put(Hierarchie.FILES,root + prop.getProperty("data.upload.files.view")); 
    77                 Hierarchie uploadTree = new Hierarchie(uploadFile, uploadRoot, uploadStylesheets, uploadViews); 
    78                 uploadTree.setDataRoot2(accessRoot); 
    79                 try { 
    80                         uploadTree.createTree(); 
    81                         uploadTree.createTreeView(); 
    82                 } 
    83                 catch (Exception e) { 
    84                         e.printStackTrace(); 
    85                 } 
    86                 this.getServletContext().setAttribute("APP_UPLOADTREE", uploadTree); 
    87                  
    88                 //on fait de même avec l'arborescence de fichiers du site de consultation 
    89                 this.getServletContext().setAttribute("uploadDir", uploadRoot); 
    90                 this.getServletContext().setAttribute("accessDir", accessRoot); 
     39    /** 
     40     * Destruction de la servlet 
     41     */ 
     42    public void destroy() 
     43    { 
     44        super.destroy(); // Just puts "destroy" string in log 
     45    } 
     46 
     47    /** 
     48     * Initialisation de la servlet : 
     49     * <ul> 
     50     * <li>un objet representant l'arborescence de fichiers du site de depot est cree et place au niveau de l'application, 
     51     * <li>l'arborescence de dossiers est egalement creee, 
     52     * <li>la vue representant cette arborescence, et permettant a l'utilisateur de deposer de nouveaux fichiers est generee. 
     53     * </ul> 
     54     * 
     55     * @throws ServletException if an error occure 
     56     */ 
     57    public void init() 
     58            throws ServletException 
     59    { 
     60        System.out.println( "************** INITIALISATION MEGAPOLI **************" ); 
     61        String root = this.getServletContext().getRealPath( "" ); 
     62        String webinf = this.getServletContext().getRealPath( "WEB-INF" ); 
     63 
     64        //on charge le fichier de proprietes 
     65        Properties prop = new Properties(); 
     66        try 
     67        { 
     68            prop.load( new FileInputStream( webinf + "/megapoli.properties" ) ); 
     69        } 
     70        catch( Exception e ) 
     71        { 
     72            e.printStackTrace(); 
     73        } 
     74        //on initialise l'objet représentant l'arborescence de fichiers du site de dépot et on le place au niveau de l'appli 
     75        String uploadRoot = prop.getProperty( "data.upload.root" ); 
     76        String uploadFile = prop.getProperty( "data.upload.desc" ); 
     77        String accessRoot = prop.getProperty( "data.access.root" ); 
     78        this.getServletContext().setAttribute( "DataDescPathName", uploadFile ); 
     79        pathImages = prop.getProperty( "data.img" ); 
     80        Hashtable<String, String> uploadStylesheets = new Hashtable<String, String>(); 
     81        uploadStylesheets.put( Hierarchie.TREE, webinf + prop.getProperty( "data.upload.tree.stylesheet" ) ); 
     82        uploadStylesheets.put( Hierarchie.FILES, webinf + prop.getProperty( "data.upload.files.stylesheet" ) ); 
     83        Hashtable<String, String> uploadViews = new Hashtable<String, String>(); 
     84        uploadViews.put( Hierarchie.TREE, root + prop.getProperty( "data.upload.tree.view" ) ); 
     85        uploadViews.put( Hierarchie.FILES, root + prop.getProperty( "data.upload.files.view" ) ); 
     86        Hierarchie uploadTree = new Hierarchie( uploadFile, uploadRoot, uploadStylesheets, uploadViews ); 
     87        uploadTree.setDataRoot2( accessRoot ); 
     88        try 
     89        { 
     90            uploadTree.createTree(); 
     91            uploadTree.createTreeView(); 
     92        } 
     93        catch( Exception e ) 
     94        { 
     95            e.printStackTrace(); 
     96        } 
     97        this.getServletContext().setAttribute( "APP_UPLOADTREE", uploadTree ); 
     98 
     99        //on fait de même avec l'arborescence de fichiers du site de consultation 
     100        this.getServletContext().setAttribute( "uploadDir", uploadRoot ); 
     101        this.getServletContext().setAttribute( "accessDir", accessRoot ); 
    91102//              String accessFile = prop.getProperty ("data.access.desc"); 
    92103//              Hashtable<String, String> accessStylesheets = new Hashtable<String, String> (); 
     
    106117//              this.getServletContext ().setAttribute ("APP_ACCESSTREE", accessTree); 
    107118 
    108                 //on charge l'annuaire et on le met aussi au niveau de l'appli... 
    109                 Annuaire annu = new Annuaire(prop.getProperty("annuaire")); 
    110                 this.getServletContext().setAttribute("APP_ANNUAIRE", annu); 
    111                  
    112                 //et idem pour l'utilitaire d'envoi des mails 
    113                 MailFactory mail = new MailFactory(prop.getProperty("mail.host")); 
    114                 this.getServletContext().setAttribute("APP_MAILFACTORY", mail); 
    115                 String webmaster = prop.getProperty("mail.webmaster"); 
    116                 this.getServletContext().setAttribute("APP_WEBMASTER", webmaster); 
    117                 String urlCGI = prop.getProperty("url.extractcgi"); 
    118                 this.getServletContext().setAttribute("APP_CGI", urlCGI); 
     119        //on charge l'annuaire et on le met aussi au niveau de l'appli... 
     120        Annuaire annu = new Annuaire( prop.getProperty( "annuaire" ) ); 
     121        this.getServletContext().setAttribute( "APP_ANNUAIRE", annu ); 
    119122 
    120                 // Initialisation d'Hibernate 
    121                 try { 
    122                         CommunicationBD.open(); 
    123                         CommunicationBD.getList("select count(*) from Jeu"); 
     123        //et idem pour l'utilitaire d'envoi des mails 
     124        MailFactory mail = new MailFactory( prop.getProperty( "mail.host" ) ); 
     125        this.getServletContext().setAttribute( "APP_MAILFACTORY", mail ); 
     126        String webmaster = prop.getProperty( "mail.webmaster" ); 
     127        this.getServletContext().setAttribute( "APP_WEBMASTER", webmaster ); 
     128        String urlCGI = prop.getProperty( "url.extractcgi" ); 
     129        this.getServletContext().setAttribute( "APP_CGI", urlCGI ); 
     130        final String mailPI = prop.getProperty( "mail.PI" ); 
     131        this.getServletContext().setAttribute( "APP_PI", mailPI ); 
     132 
     133        // Initialisation d'Hibernate 
     134        try 
     135        { 
     136            CommunicationBD.open(); 
     137            CommunicationBD.getList( "select count(*) from Jeu" ); 
    124138//                      System.out.println("nombre de jeux insérés="+nbjeux.get(0)); 
    125                         CommunicationBD.close(); 
    126                 } catch (HibernateException e) { 
    127                         e.printStackTrace(); 
    128                 } 
    129         } 
     139            CommunicationBD.close(); 
     140        } 
     141        catch( HibernateException e ) 
     142        { 
     143            e.printStackTrace(); 
     144        } 
     145    } 
    130146} 
  • ether_megapoli/trunk/web/WEB-INF/megapoli_dev.properties

    r278 r280  
    1212mail.host=mailhost.ipsl.jussieu.fr 
    1313mail.webmaster=megapoli-admin@ipsl.jussieu.fr 
     14mail.PI=vmaigne@hotmail.com 
    1415url.upload=http://megapoli-dev.ipsl.jussieu.fr:8080/megapoli-dev/InitLogon.do 
    1516url.extractcgi=http://megapoli-dev.ipsl.jussieu.fr/cgi-bin/megapoli_extract.cgi 
  • ether_megapoli/trunk/web/WEB-INF/megapoli_prod.properties

    r278 r280  
    1212mail.host=mailhost.ipsl.jussieu.fr 
    1313mail.webmaster=megapoli-admin@ipsl.jussieu.fr 
     14mail.PI=Matthias.Beekmann@lisa.u-pec.fr 
    1415url.upload=http://chewie.private.ipsl.fr:8080/megapoli/InitLogon.do 
    1516url.extractcgi=http://chewie.private.ipsl.fr/cgi-bin/megapoli_extract.cgi 
  • ether_megapoli/trunk/web/backoffice/user-script.jsp

    r277 r280  
    4242        this.displayStates(); 
    4343        this.displayRoles(); 
     44 
     45        $( "#keepSamePassword" ).attr( 'disabled', true ); 
     46        $( "#keepSamePassword" ).bind( 'click', this.onCheckKeepSamePassword ); 
    4447    }, 
    4548 
     
    7376        { 
    7477            var parametersUrl = "id=" + this.user.id + "&name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + 
    75                     "&pwd=" + $( "#password" ).val() + "&role=" + this.selectRoles.getValue() + "&state=" + this.selectStates.getValue() + "&hasAccess=" + $( "#boAccess" ).attr( 'checked' ); 
     78                    "&pwd=" + $( "#password" ).val() + "&role=" + this.selectRoles.getValue() + "&state=" + this.selectStates.getValue() + 
     79                    "&hasAccess=" + $( "#boAccess" ).attr( 'checked' ) + "&keepSamePassword=" + $( "#keepSamePassword" ).attr( 'checked' ); 
    7680            $.ajax( { 
    7781                url: "backoffice?methodName=modifyUser&" + parametersUrl, 
     
    263267        $( "#firstName" ).val( user.firstName ); 
    264268        $( "#email" ).val( user.email ); 
    265         $( "#password" ).val( user.password ); 
     269        $( "#password" ).attr( 'disabled', true ); 
     270        $( "#keepSamePassword" ).attr( 'disabled', false ); 
     271        $( "#keepSamePassword" ).attr( 'checked', true ); 
    266272        this.selectRoles.select( user.role, false ); 
    267273        this.selectStates.select( user.state, false ); 
     
    276282        if( window.confirm( interfaceTexts["bo.user.remove.confirm"] + " " + user.firstName + " " + user.lastName + " ?" ) ) 
    277283            jQuery.proxy( this.requestRemoveUser(), this ); 
     284    }, 
     285 
     286    onCheckKeepSamePassword: function() 
     287    { 
     288        var actualState = $( "#keepSamePassword" ).attr( 'checked' ); 
     289        $( "#password" ).attr( 'disabled', actualState ); 
    278290    }, 
    279291 
     
    305317                .removeAttr( 'selected' ); 
    306318 
     319        $( "#keepSamePassword" ).attr( 'disabled', true ); 
    307320        this.selectRoles.selectFirst( false ); 
    308321        this.selectStates.selectFirst( false ); 
     
    318331        if( '' == $( "#email" ).val() ) 
    319332            errors = !errors ? interfaceTexts["bo.field.email"] : errors + "<BR/>" + interfaceTexts["bo.field.email"]; 
    320         if( '' == $( "#password" ).val() ) 
     333        if( '' == $( "#password" ).val() && !$( "#keepSamePassword" ).attr( 'checked' ) ) 
    321334            errors = !errors ? interfaceTexts["bo.field.password"] : errors + "<BR/>" + interfaceTexts["bo.field.password"]; 
    322335 
  • ether_megapoli/trunk/web/backoffice/user.jsp

    r278 r280  
     1<%@ page import="com.ether.WebException" %> 
    12<%@ page import="com.ether.user.UserRole" %> 
    23<%@ page import="com.ether.user.UserState" %> 
    3 <%@ page import="com.ether.WebException" %> 
    44<%@ page language="java" contentType="text/html; charset=UTF-8" %> 
    55<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> 
     
    108108                <td><input id="password" size="40"></td> 
    109109 
     110                <td></td> 
     111                <td></td> 
     112            </tr> 
     113            <tr> 
     114                <td><bean:message key="bo.user.password.same"/></td> 
     115                <td><input id="keepSamePassword" type="checkbox"><bean:message key="bo.user.password.same.help"/></td> 
     116 
    110117                <td><bean:message key="bo.action"/></td> 
    111118                <td> 
  • ether_megapoli/trunk/web/resources/templates/templateMegapoli.jsp

    r278 r280  
    172172    loginTexts["data.authentification.loginForget"] = '<bean:message key="data.authentification.loginForget"/>'; 
    173173    loginTexts["data.authentification.inscription"] = '<bean:message key="data.authentification.inscription"/>'; 
    174     loginTexts["errors.logon.notFound"] = "<bean:message key='errors.logon.notFound' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     174    loginTexts["errors.logon.notFound"] = "<bean:message key='errors.logon.notFound'/>"; 
    175175    loginTexts["errors.logon.failed"] = "<bean:message key='errors.logon.failed' arg0="<%=Context.getWebmaster( request )%>"/>"; 
     176    loginTexts["errors.logon.notAccepted"] = "<bean:message key='errors.logon.notAccepted'/>"; 
    176177    loginTexts["app.admin"] = '<bean:message key="app.admin"/>'; 
    177178    loginTexts["data.authentification.text"] = "<bean:message key="data.authentification.text"/>"; 
  • ether_megapoli/trunk/web/src/ApplicationResources.properties

    r279 r280  
    376376 
    377377errors.logon.failed=Echec de l\'op\u00E9ration d'authentification.<br> Veuillez contacter le <a href\='mailto\:{0}?subject\=[MEGAPOLI]'>webmaster</a> pour lui signaler le probl\u00E8me.<br> 
    378 errors.logon.notFound=Ce login et/ou ce mot de passe sont inconnus.<br> Si vous voulez vous enregistrer pour obtenir l'acc\u00E8s aux zones prot\u00E9g\u00E9es du site, veuillez \u00E9crire un mail au <a href\='mailto\:{0}?subject\=[MEGAPOLI]'>webmaster</a>. <br> 
     378errors.logon.notFound=Ce login et/ou ce mot de passe sont inconnus.<br> Si vous voulez vous enregistrer pour obtenir l'acc\u00E8s aux zones prot\u00E9g\u00E9es du site, veuillez cliquez sur 'Nouvelle inscription'. <br> 
    379379errors.logon.login=Veuillez saisir votre login (normalement : votre mail).<br> 
    380380errors.logon.password=Veuillez saisir votre mot de passe.<br> 
     381errors.logon.notAccepted=Vous n'\u00EAtes pas autoris\u00E9 \u00E0 acc\u00E9der aux zones prot\u00E9g\u00E9s. 
    381382 
    382383errors.upload.file=Vous devez s\u00E9lectionner un fichier\!<br> 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r279 r280  
    376376 
    377377errors.logon.failed=The logon transaction failed. Please contact the <a href\='mailto\:{0}?subject\=[MEGAPOLI]'>webmaster</a> to report this problem.<br> 
    378 errors.logon.notFound=Unknown login and/or password.<br> To register and access the protected areas of this site, please write an email to the <a href\='mailto\:{0}?subject\=[MEGAPOLI]'>webmaster</a>.<br> 
     378errors.logon.notFound=Unknown login and/or password.<br> To register and access the protected areas of this site, please click on 'New inscription'.<br> 
    379379errors.logon.login=Please type your login (should be your email).<br> 
    380380errors.logon.password=Please type your password.<br> 
     381errors.logon.notAccepted=You are not allowed to access to protected areas. 
    381382 
    382383errors.upload.file=You must select a file!<br> 
  • ether_megapoli/trunk/web/src/com/ether/ControllerEponge.java

    r279 r280  
    66import com.ether.user.UserRole; 
    77import com.ether.user.UserState; 
    8 import com.medias.annuaire.Annuaire; 
    9 import com.medias.annuaire.Personne; 
    108import com.medias.mail.Mail; 
    119import com.medias.mail.MailFactory; 
     
    5452    @ControllerMethod(requestMandatory = true, jsonResult = true) 
    5553    public JSONObject login( @ParamName(ParameterConstants.PARAMETER_LOGIN) final String login, 
    56                              @ParamName(ParameterConstants.PARAMETER_PWD) final String pwd, 
     54                             @ParamName(ParameterConstants.PARAMETER_PWD) final String password, 
    5755                             @NotNull final HttpServletRequest request ) 
    5856            throws ServiceException 
     
    6159        final JSONObject result = new JSONObject(); 
    6260 
    63         if( login != null && pwd != null ) 
     61        if( login != null && password != null ) 
    6462        { 
    65             final Annuaire annu = (Annuaire) getServletContext().getAttribute( "APP_ANNUAIRE" ); 
    6663            try 
    6764            { 
    68                 final Personne people = annu.getPersonne( login, pwd ); 
    69                 if( people == null ) 
     65                final User user = _etherService.getUserByEmail( login ); 
     66                final String encryptedPassword = EtherHelper.encryptPassword( password ); 
     67                if( user == null || ( null != user && !encryptedPassword.equals( user.getPassword() ) ) ) 
    7068                    result.put( "errors", "errors.logon.notFound" ); 
     69                else if( !UserState.ACCEPTED.equals( user.getState() ) ) 
     70                    result.put( "errors", "errors.logon.notAccepted" ); 
    7171                else 
    7272                { 
    73                     request.getSession().setAttribute( "SES_USER", people ); 
    74                     jSONPeople.put( "name", people.getNom() ); 
    75                     jSONPeople.put( "firstName", people.getPrenom() ); 
    76                     jSONPeople.put( "role", people.getRoles() ); 
     73                    request.getSession().setAttribute( "SES_USER", user ); 
     74                    jSONPeople.put( "name", user.getLastName() ); 
     75                    jSONPeople.put( "firstName", user.getFirstName() ); 
     76                    jSONPeople.put( "role", user.getRole().name() ); 
    7777                } 
    7878            } 
  • ether_megapoli/trunk/web/src/com/ether/ControllerEther.java

    r278 r280  
    55import com.ether.annotation.ParamName; 
    66import com.ether.annotation.UseJSON; 
    7 import com.medias.annuaire.Personne; 
     7import com.ether.user.User; 
    88import net.sf.json.JSON; 
    99import net.sf.json.JSONArray; 
     
    8888            if( methodDescription.isLoginMandatory() ) 
    8989            { 
    90                 final Personne pers = (Personne) request.getSession().getAttribute( "SES_USER" ); 
    91                 params[params.length - 1] = pers; 
     90                final User user = (User) request.getSession().getAttribute( "SES_USER" ); 
     91                params[params.length - 1] = user; 
    9292            } 
    9393 
Note: See TracChangeset for help on using the changeset viewer.