01: package org.manentia.kasai.services;
02:
03: import java.net.UnknownHostException;
04: import java.util.ResourceBundle;
05:
06: import jcifs.UniAddress;
07: import jcifs.smb.NtlmPasswordAuthentication;
08: import jcifs.smb.SmbException;
09: import jcifs.smb.SmbSession;
10:
11: import org.manentia.kasai.Constants;
12: import org.manentia.kasai.exceptions.InvalidPasswordException;
13: import org.manentia.kasai.exceptions.ServiceException;
14:
15: import com.manentia.commons.log.Log;
16:
17: /*
18: *
19: */
20:
21: /**
22: *
23: * @author JK Adams
24: */
25: public class Win32AuthService implements AuthService {
26: public int checkPassword(String userName, String password)
27: throws ServiceException {
28:
29: int result = AUTH_BAD_USERNAME;
30:
31: ResourceBundle res = ResourceBundle
32: .getBundle(Constants.CONFIG_PROPERTY_FILE);
33: try {
34: NtlmPasswordAuthentication npa = new NtlmPasswordAuthentication(
35: res.getString("kasai.win32.domain"), userName,
36: password);
37: SmbSession.logon(UniAddress.getByName(res
38: .getString("kasai.win32.domainController")), npa);
39: result = AUTH_OK;
40: } catch (UnknownHostException uhe) {
41: Log.write("The domain controller could not be reached",
42: uhe, Log.ERROR, "checkPassword",
43: Win32AuthService.class);
44:
45: throw new ServiceException(Win32AuthService.class.getName()
46: + ".unknownhost", uhe);
47: } catch (SmbException se) {
48: Log.write("Invalid username or password in the domain", se,
49: Log.INFO, "checkPassword", Win32AuthService.class);
50: }
51: return result;
52: }
53:
54: public void changePassword(String userName, String oldPassword,
55: String newPassword) throws ServiceException {
56: // NOT SUPPORTED YET
57: }
58:
59: public void setPassword(String userName, String password)
60: throws ServiceException, InvalidPasswordException {
61:
62: // NOT SUPPORTED YET
63: }
64:
65: public String resetPassword(String userName)
66: throws ServiceException {
67: return null;
68: }
69:
70: }
|