01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21: package org.josso.gateway;
22:
23: import org.apache.axis.AxisFault;
24: import org.apache.axis.MessageContext;
25: import org.apache.axis.handlers.BasicHandler;
26: import org.apache.commons.logging.Log;
27: import org.apache.commons.logging.LogFactory;
28:
29: /**
30: * Axis Client-side Handler that identifies the SOAP message for authentication
31: * purposes.
32: *
33: * @author <a href="mailto:gbrigand@josso.org">Gianluca Brigandi</a>
34: * @version CVS $Id: WebserviceClientAuthentication.java 508 2008-02-18 13:32:29Z sgonzalez $
35: */
36:
37: public class WebserviceClientAuthentication extends BasicHandler {
38: private static final Log logger = LogFactory
39: .getLog(WebserviceClientAuthentication.class);
40:
41: private static String _username;
42: private static String _password;
43:
44: public static void setUsername(String username) {
45: if (_username == null)
46: _username = username;
47: }
48:
49: public static void setPassword(String password) {
50: if (_password == null)
51: _password = password;
52: }
53:
54: public void invoke(MessageContext msgContext) throws AxisFault {
55:
56: try {
57:
58: if (_username != null && _password != null) {
59: logger
60: .debug("Injecting identity to SOAP request, username='"
61: + _username
62: + "' "
63: + "password='"
64: + _password + "'");
65:
66: msgContext.setUsername(_username);
67: msgContext.setPassword(_password);
68: }
69:
70: } catch (Exception e) {
71: throw AxisFault.makeFault(e);
72: }
73: }
74:
75: public void onFault(MessageContext msgContext) {
76: try {
77: // probably needs to fault.
78: } catch (Exception e) {
79: logger.error(e);
80: }
81: }
82: }
|