01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rproxy.rewriter.util;
06:
07: import java.util.List;
08:
09: import com.sun.portal.rewriter.util.ConfigManager;
10: import com.sun.portal.rewriter.util.collections.ListMap;
11: import com.sun.portal.rewriter.util.re.Pattern;
12: import com.sun.portal.rewriter.util.re.RegExp;
13: import com.sun.portal.rewriter.util.uri.DecoratedURI;
14: import com.sun.portal.rewriter.util.uri.PageSpec;
15: import com.sun.portal.rproxy.rewriter.services.SRAPProcessedProfile;
16: import com.sun.portal.util.DomainWebProxyConfig;
17:
18: public final class SRAPConfigManager {
19: private static final String PROPERTY_REWRITE_SRC_NAME = "IS_COMPULSORY_REWRITE_SRC";
20:
21: private static final boolean rewriteSRCValue = ConfigManager
22: .getBoolean(PROPERTY_REWRITE_SRC_NAME, true);
23:
24: public static String selectRuleSet4URI(final PageSpec aPageSpec) {
25: return SRAPProcessedProfile.getURI2RuleSetMap()
26: .selectRuleset4Page(aPageSpec);
27: }// selectRuleSet4URI()
28:
29: public static String selectParser4MIME(final String aMIME) {
30: Object mappedMIME = SRAPProcessedProfile.getMIME2ParserMap()
31: .get(aMIME);
32:
33: if (mappedMIME == null) {
34: return null;
35: }
36:
37: return mappedMIME.toString();
38: }// selectParser4MIME()
39:
40: public static boolean isMIMEGuessingEnabled() {
41: return SRAPProcessedProfile.isMIMEGuessingEnabled();
42: }// isMIMEGuessingEnabled()
43:
44: public static String selectParser4URI(final PageSpec aPageSpec) {
45: String lURI = aPageSpec.getBaseURI().getFullFileURI();
46: ListMap lListMap = SRAPProcessedProfile.getURI2ParserMAP();
47: List lKeys = lListMap.keyList();
48: for (int i = 0; i < lKeys.size(); i++) {
49: Pattern key = (Pattern) lKeys.get(i);
50: if (RegExp.match(key, lURI)) {
51: return lListMap.get(key).toString();
52: }
53: }
54:
55: return null;
56: }// selectParser4URI()
57:
58: public static boolean isIntranet(final String aLowerCaseHost) {
59: return DomainWebProxyConfig.containHost(aLowerCaseHost);
60: }// isIntranetURL()
61:
62: public static boolean isNot2RewriteURI(final DecoratedURI aURI) {
63: return RegExp.match(SRAPProcessedProfile
64: .getNot2RewriteURIPatterns(), aURI.getInputString())
65: || RegExp.match(SRAPProcessedProfile
66: .getNot2RewriteURIPatterns(), aURI
67: .toExternalForm());
68: }// isNot2RewriteURI()
69:
70: public static boolean isRewriteSRCValue() {
71: return rewriteSRCValue;
72: }// isRewriteSRCValue()
73:
74: public static boolean isObscureURIs() {
75: return SRAPProcessedProfile.isObscureURIs();
76: }// isObscureURIs()
77:
78: public static boolean isNot2ObscureURI(final String aURI) {
79: return RegExp.match(SRAPProcessedProfile
80: .getNot2ObscureURIPatterns(), aURI);
81: }// isNot2ObscureURI()
82:
83: public static boolean isUseConsistantProtocol4Gateway() {
84: return SRAPProcessedProfile.isUseConsistantProtocol4Gateway();
85: }// isUseConsistantProtocol4Gateway()
86:
87: public static String getHTTPPort() {
88: return SRAPProcessedProfile.getHTTPPort();
89: }// getHTTPPort()
90:
91: public static String getHTTPSPort() {
92: return SRAPProcessedProfile.getHTTPSPort();
93: }// getHTTPSPort()
94:
95: }// class SRAPConfigManager
|