01: package org.manentia.kasai.services;
02:
03: import java.io.IOException;
04: import java.util.ResourceBundle;
05:
06: import org.manentia.kasai.Constants;
07: import org.manentia.kasai.exceptions.InvalidPasswordException;
08: import org.manentia.kasai.exceptions.ServiceException;
09:
10: import com.ibm.as400.access.AS400;
11: import com.ibm.as400.access.AS400SecurityException;
12: import com.manentia.commons.log.Log;
13:
14: /*
15: *
16: */
17:
18: /**
19: *
20: * @author JK Adams
21: */
22: public class AS400AuthService implements AuthService {
23:
24: public int checkPassword(String userName, String password)
25: throws ServiceException {
26:
27: int result = AUTH_BAD_USERNAME;
28:
29: ResourceBundle res = ResourceBundle
30: .getBundle(Constants.CONFIG_PROPERTY_FILE);
31: try {
32: String ip = res.getString("kasai.as400.IPAddress");
33: AS400 system = new AS400(ip, userName, password);
34: if (system.validateSignon()) {
35: result = AUTH_OK;
36: }
37: } catch (AS400SecurityException e) {
38: Log.write("Error contacting the AS/400 server", e,
39: Log.ERROR, "checkPassword", AS400AuthService.class);
40:
41: throw new ServiceException(AS400AuthService.class.getName()
42: + ".securityException", e);
43: } catch (IOException e) {
44: Log.write("Error contacting the AS/400 server", e,
45: Log.ERROR, "checkPassword", AS400AuthService.class);
46:
47: throw new ServiceException(AS400AuthService.class.getName()
48: + ".IOException", e);
49: }
50: return result;
51: }
52:
53: public void changePassword(String userName, String oldPassword,
54: String newPassword) throws ServiceException {
55: // NOT SUPPORTED YET
56: }
57:
58: public void setPassword(String userName, String password)
59: throws ServiceException, InvalidPasswordException {
60:
61: // NOT SUPPORTED YET
62: }
63:
64: public String resetPassword(String userName)
65: throws ServiceException {
66: return null;
67: }
68:
69: }
|