01: /*
02:
03: */
04:
05: package com.sun.portal.rproxy.connectionhandler;
06:
07: import java.net.MalformedURLException;
08: import java.net.URL;
09: import java.util.List;
10:
11: import com.sun.portal.rproxy.configservlet.client.GatewayProfile;
12:
13: public class MatchHttps {
14: private boolean _isReady = false;
15:
16: private List _useHttps;
17:
18: /**
19: * Constructor, tracks if the instance has been properly initialized.
20: * Initialize it if it has not been initialize.
21: */
22: public MatchHttps(String config_file) {
23: _useHttps = GatewayProfile.getLowerCaseStringList(config_file);
24: if (_useHttps == null)
25: _isReady = false;
26: else
27: _isReady = true;
28: }
29:
30: public boolean hasMatch(String matchkey) {
31: if (_isReady) {
32: return _useHttps.contains(matchkey.toLowerCase());
33: } else {
34: return (false);
35: }
36: }
37:
38: public String getIP(String s) {
39: return "";
40: }
41:
42: public void add(String url) {
43: _useHttps.add(url.toLowerCase());
44: }
45:
46: public boolean hasMatchPattern(String matchkey) {
47: String patternuri = "";
48: if (_isReady) {
49: for (int i = 0; i < _useHttps.size(); i++) {
50: patternuri = (String) _useHttps.get(i);
51: if (matchkey.toLowerCase().indexOf(
52: patternuri.toLowerCase()) > -1) {
53: try {
54: URL pattern = new URL(patternuri);
55: URL key = new URL(matchkey.substring(0,
56: patternuri.length()));
57: if (pattern.equals(key)) {
58: return true;
59: }
60: } catch (MalformedURLException mfe) {
61: // ignore
62: }
63: }
64: }
65: // return _useHttps.contains( matchkey.toLowerCase() );
66: } else {
67: return (false);
68: }
69: return false;
70: }
71:
72: }
|