KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > networkplaces > NetworkPlacesAccessEvent


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.networkplaces;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import com.sslexplorer.boot.Util;
25 import com.sslexplorer.core.CoreAttributeConstants;
26 import com.sslexplorer.core.CoreEvent;
27 import com.sslexplorer.policyframework.Policy;
28 import com.sslexplorer.policyframework.Resource;
29 import com.sslexplorer.policyframework.ResourceAccessEvent;
30 import com.sslexplorer.security.SessionInfo;
31
32 /**
33  * Extension of a {@link com.sslexplorer.policyframework.ResourceAccessEvent} that should be used
34  * when a {@link NetworkPlace} is accessed in some way.
35  *
36  * @author James Robinson <a HREF="mailto: james@3sp.com">&lt;james@3sp.com&gt;</a>
37  */

38 public class NetworkPlacesAccessEvent extends ResourceAccessEvent {
39
40     /**
41      * Constructor for {@link CoreEvent#STATE_UNSUCCESSFUL} that also takes the
42      * message from an exception and adds it as an attribute
43      *
44      * @param source source of event
45      * @param id event ID
46      * @param session session that fired the event
47      * @param exception exception
48      */

49     public NetworkPlacesAccessEvent(Object JavaDoc source, int id, SessionInfo session, Throwable JavaDoc exception) {
50         super(source, id, session, exception);
51     }
52
53     /**
54      * Constructor for {@link CoreEvent#STATE_UNSUCCESSFUL} that also takes the
55      * message from an exception and adds it as an attribute
56      *
57      * @param source source of event
58      * @param id event ID
59      * @param resource resource accessed
60      * @param policy the policy resource access was attempted under
61      * @param session session that fired the event
62      * @param exception exception
63      * @param request request
64      * @param path path
65      * @param uri uri
66      */

67     public NetworkPlacesAccessEvent(Object JavaDoc source, int id, Resource resource, Policy policy, SessionInfo session, Throwable JavaDoc exception, HttpServletRequest JavaDoc request, String JavaDoc path, String JavaDoc uri) {
68         this(source, id, resource, policy, session, STATE_UNSUCCESSFUL, request, path, uri);
69         if(exception != null) {
70             String JavaDoc exceptionMessageChain = Util.getExceptionMessageChain(exception);
71             String JavaDoc maskedExceptionMessage = maskSensitiveArguments(exceptionMessageChain);
72             addAttribute(CoreAttributeConstants.EVENT_ATTR_EXCEPTION_MESSAGE, maskedExceptionMessage);
73         }
74     }
75     
76     public static String JavaDoc maskSensitiveArguments(String JavaDoc toMask) {
77         return toMask.replaceAll("([a-z]*\\://.*:)(.*)(@.*)", "$1********$3");
78     }
79
80     /**
81      * Constructor
82      *
83      * @param source source of event
84      * @param id event ID
85      * @param resource resource accessed
86      * @param policy the policy resource access was attempted under
87      * @param session session that fired the event
88      * @param state event state
89      * @param request request
90      * @param path path
91      * @param uri uri
92      */

93     public NetworkPlacesAccessEvent(Object JavaDoc source, int id, Resource resource, Policy policy, SessionInfo session, int state, HttpServletRequest JavaDoc request, String JavaDoc path, String JavaDoc uri) {
94         this(source, id, resource, policy, session, state, request);
95         if(uri != null)
96             addAttribute(NetworkPlacesEventConstants.EVENT_ATTR_VFS_URI, uri);
97         if(path != null)
98             addAttribute(NetworkPlacesEventConstants.EVENT_ATTR_VFS_PATH, path);
99     }
100
101
102     /**
103      * Constructor
104      *
105      * @param source source of event
106      * @param id event ID
107      * @param resource resource accessed
108      * @param policy the policy resource access was attempted under
109      * @param session session that fired the event
110      * @param state event state
111      * @param request request
112      */

113     public NetworkPlacesAccessEvent(Object JavaDoc source, int id, Resource resource, Policy policy, SessionInfo session, int state, HttpServletRequest JavaDoc request) {
114         super(source, id, resource, policy, session, state);
115         if(request != null)
116             addAttribute(NetworkPlacesEventConstants.EVENT_ATTR_VFS_USER_AGENT, request.getHeader("User-Agent"));
117     }
118
119 }
120
Popular Tags