01: /* $Id: StripSessionCFIDs.java 4655 2006-09-25 20:27:35Z paul_jack $
02: *
03: * Created on September 1st, 2006
04: *
05: * Copyright (C) 2006 Internet Archive.
06: *
07: * This file is part of the Heritrix web crawler (crawler.archive.org).
08: *
09: * Heritrix is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU Lesser Public License as published by
11: * the Free Software Foundation; either version 2.1 of the License, or
12: * any later version.
13: *
14: * Heritrix is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: * GNU Lesser Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser Public License
20: * along with Heritrix; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: package org.archive.crawler.url.canonicalize;
24:
25: import java.util.regex.Pattern;
26:
27: /**
28: * Strip cold fusion session ids.
29: * @author stack
30: * @version $Date: 2006-09-25 20:27:35 +0000 (Mon, 25 Sep 2006) $, $Revision: 4655 $
31: */
32: public class StripSessionCFIDs extends BaseRule {
33:
34: private static final long serialVersionUID = 9122689291157731293L;
35:
36: private static final String REGEX = "^(.+)"
37: + "(?:cfid=[^&]+&cftoken=[^&]+(?:jsession=[^&]+)?)(?:&(.*))?$";
38:
39: private static final String DESCRIPTION = "Strip ColdFusion session IDs. "
40: + "Use this rule to remove sessionids that look like the following: "
41: + "CFID=12412453&CFTOKEN=15501799 or "
42: + "CFID=3304324&CFTOKEN=57491900&jsessionid=a63098d96360$B0$D9$A "
43: + "using the following case-insensitive regex: " + REGEX;
44:
45: /**
46: * Examples:
47: * <pre>
48: * Examples:
49: * boo?CFID=1169580&CFTOKEN=48630702&dtstamp=22%2F08%2F2006%7C06%3A58%3A11
50: * boo?CFID=12412453&CFTOKEN=15501799&dt=19_08_2006_22_39_28
51: * boo?CFID=14475712&CFTOKEN=2D89F5AF-3048-2957-DA4EE4B6B13661AB&r=468710288378&m=forgotten
52: * boo?CFID=16603925&CFTOKEN=2AE13EEE-3048-85B0-56CEDAAB0ACA44B8&r=501652357733&l1=home
53: * boo?CFID=3304324&CFTOKEN=57491900&jsessionid=a63098d96360$B0$D9$A
54: * </pre>
55: */
56: private static final Pattern COLDFUSION_PATTERN = Pattern.compile(
57: REGEX, Pattern.CASE_INSENSITIVE);
58:
59: public StripSessionCFIDs(String name) {
60: super (name, DESCRIPTION);
61: }
62:
63: public String canonicalize(String url, Object context) {
64: return doStripRegexMatch(url, COLDFUSION_PATTERN.matcher(url));
65: }
66: }
|