KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > manentia > kasai > services > AS400AuthService


1 package org.manentia.kasai.services;
2
3 import com.ibm.as400.access.AS400;
4 import com.ibm.as400.access.AS400SecurityException;
5 import com.koala.commons.log.Log;
6 import java.io.IOException JavaDoc;
7 import java.util.*;
8 import org.apache.commons.lang.exception.ExceptionUtils;
9 import org.manentia.kasai.exceptions.InvalidPasswordException;
10 import org.manentia.kasai.exceptions.ServiceException;
11 import org.manentia.kasai.util.Constants;
12 /*
13  *
14  */

15
16
17
18
19 /**
20  *
21  * @author JK Adams
22  */

23 public class AS400AuthService implements AuthService {
24     
25     public int checkPassword(String JavaDoc userName, String JavaDoc password) throws ServiceException {
26         
27         int result = AUTH_BAD_USERNAME;
28         
29         ResourceBundle res = ResourceBundle.getBundle(
30                     Constants.PROPERTY_FILE);
31         try {
32             String JavaDoc ip = res.getString("kasai.as400.IPAddress");
33             AS400 system = new AS400(ip, userName, password);
34             if (system.validateSignon()){
35                 result = AUTH_OK;
36             }
37         }
38         catch (AS400SecurityException e){
39             Log.getInstance(Constants.PROPERTY_FILE).write(AS400AuthService.class.getName(),
40                     "checkPassword", "Error contacting the AS/400 server (" + ExceptionUtils.getStackTrace(e) + ")", java.util.logging.Level.SEVERE);
41                                                                                                                                                                                                            
42             throw new ServiceException(AS400AuthService.class.getName() + ".securityException", e);
43         }
44         catch (IOException JavaDoc e){
45             Log.getInstance(Constants.PROPERTY_FILE).write(AS400AuthService.class.getName(),
46                     "checkPassword", "Error contacting the AS/400 server (" + ExceptionUtils.getStackTrace(e) + ")", java.util.logging.Level.SEVERE);
47                                                                                                                                                                                                            
48             throw new ServiceException(AS400AuthService.class.getName() + ".IOException", e);
49         }
50         return result;
51     }
52     
53     public void changePassword(String JavaDoc userName, String JavaDoc oldPassword, String JavaDoc newPassword) throws ServiceException {
54         // NOT SUPPORTED YET
55
}
56     
57     public void setPassword(String JavaDoc userName, String JavaDoc password)
58         throws ServiceException, InvalidPasswordException{
59     
60         // NOT SUPPORTED YET
61
}
62     
63     public String JavaDoc resetPassword(String JavaDoc userName) throws ServiceException {
64         return null;
65     }
66
67 }
68
Popular Tags