package edu.yale.its.tp.cas.auth.provider; import edu.yale.its.tp.cas.auth.*; import java.io.*; import java.util.*; /** *
Titre :
*Description :
*Copyright : Copyright (c) 2003
*Société :
* @author non attribuable * @version 1.0 */ public class FlatFileHandler extends WatchfulPasswordHandler{ public boolean authenticate(javax.servlet.ServletRequest request, String username, String password) { /* * As a demonstration, accept any username/password combination * where the username matches the password. */ String [] tab_line=new String[2]; String user_file=""; String pass_file=""; String UserFile ="/tmp/userCAS"; try { FileReader fr = new FileReader(UserFile); BufferedReader in = new BufferedReader(fr); String line; while ( (line = in.readLine()) != null){ tab_line=line.split(";"); user_file=tab_line[0]; pass_file=tab_line[1]; if(username.equals(user_file) && password.equals(pass_file)){ in.close(); System.out.println("INFO AUTH CAS FlatFileHandler: ("+username+";"+password+")"); return(true); } } in.close(); }catch(Exception e){ System.out.println("ERREUR AUTH CAS FlatFileHandler: impossible d'ouvrir "+UserFile); } return false; } }