01: /*
02: * (C) Copyright 2000 - 2005 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: package com.nabhinc.ws.interceptor.security;
20:
21: import java.io.IOException;
22:
23: import com.nabhinc.ws.core.WebServiceException;
24: import com.nabhinc.ws.server.Current;
25: import com.nabhinc.ws.server.Interceptor;
26: import com.nabhinc.ws.server.InterceptorChain;
27: import com.nabhinc.ws.server.RequestInfo;
28: import com.nabhinc.ws.server.ServerObjectImpl;
29:
30: /**
31: * A simple interceptor that redirects the request to the configured
32: * URL if the user is not logged in. The redirect URL is configured
33: * via "redirectURL" configuration property.
34: *
35: * @author Padmanabh Dabke
36: * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
37: */
38: public class UnloggedUserRedirector extends ServerObjectImpl implements
39: Interceptor {
40: private String faRedirectURL = null;
41:
42: public void setRedirectURL(String url) {
43: faRedirectURL = url;
44: }
45:
46: public void intercept(RequestInfo reqInfo, InterceptorChain chain)
47: throws WebServiceException, IOException {
48: if (reqInfo.webServiceRequest.getRemoteUser() == null) {
49: reqInfo.redirect = faRedirectURL;
50: // Force creation of session
51: Current.getRequestContext().getWebServiceRequest()
52: .getSession();
53: } else {
54: chain.doIntercept(reqInfo);
55: }
56: }
57:
58: }
|