01: /*
02: * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19:
20: package com.nabhinc.portal.spi.impl.jaas;
21:
22: import java.io.IOException;
23: import java.util.Map;
24:
25: import javax.security.auth.callback.Callback;
26: import javax.security.auth.callback.NameCallback;
27: import javax.security.auth.callback.PasswordCallback;
28: import javax.security.auth.callback.UnsupportedCallbackException;
29:
30: /**
31: *
32: *
33: * @author Padmanabh Dabke
34: * (c) 2003 Nabh Information Systems, Inc. All Rights Reserved.
35: */
36: public class StringbeansCallbackHandlerImpl implements
37: StringbeansCallbackHandler {
38:
39: private String schiUserName = null;
40: private String schiPassword = null;
41:
42: // private Map schiParamMap = null;
43: /* (non-Javadoc)
44: * @see com.nabhinc.portal.auth.StringbeansCallbackHandler#setRequest(javax.servlet.http.HttpServletRequest)
45: */
46: public void setUserName(String userName) {
47: schiUserName = userName;
48: }
49:
50: public void setPassword(String password) {
51: schiPassword = password;
52: }
53:
54: public void setParameterMap(Map paramMap) {
55: // schiParamMap = paramMap;
56: }
57:
58: /* (non-Javadoc)
59: * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
60: */
61: public void handle(Callback[] callbacks) throws IOException,
62: UnsupportedCallbackException {
63: for (int i = 0; i < callbacks.length; i++) {
64: if (callbacks[i] instanceof NameCallback) {
65: NameCallback nc = (NameCallback) callbacks[i];
66: nc.setName(schiUserName);
67:
68: } else if (callbacks[i] instanceof PasswordCallback) {
69: PasswordCallback pc = (PasswordCallback) callbacks[i];
70: pc.setPassword(schiPassword.toCharArray());
71:
72: } else {
73: throw (new UnsupportedCallbackException(callbacks[i],
74: "Callback handler not support"));
75: }
76: }
77:
78: }
79:
80: }
|