gluu
公開メンバ関数 | 公開変数類 | 非公開メンバ関数 | 全メンバ一覧
org.xdi.oxauth.model.util.URLPatternList.URLPattern クラス
org.xdi.oxauth.model.util.URLPatternList.URLPattern 連携図
Collaboration graph

公開メンバ関数

 URLPattern (String scheme, String host, String port, String path) throws MalformedURLException
 
boolean matches (URI uri)
 

公開変数類

Pattern scheme
 
Pattern host
 
Integer port
 
Pattern path
 

非公開メンバ関数

String regexFromPattern (String pattern, boolean allowWildcards)
 

詳解

構築子と解体子

◆ URLPattern()

org.xdi.oxauth.model.util.URLPatternList.URLPattern.URLPattern ( String  scheme,
String  host,
String  port,
String  path 
) throws MalformedURLException
inline
88  {
89  try {
90  if (scheme == null || "*".equals(scheme)) {
91  this.scheme = null;
92  } else {
93  this.scheme = Pattern.compile(regexFromPattern(scheme, false), Pattern.CASE_INSENSITIVE);
94  }
95  if ("*".equals(host)) {
96  this.host = null;
97  } else if (host.startsWith("*.")) {
98  this.host = Pattern.compile("([a-z0-9.-]*\\.)?" + regexFromPattern(host.substring(2), false), Pattern.CASE_INSENSITIVE);
99  } else {
100  this.host = Pattern.compile(regexFromPattern(host, false), Pattern.CASE_INSENSITIVE);
101  }
102  if (port == null || "*".equals(port)) {
103  this.port = null;
104  } else {
105  this.port = Integer.parseInt(port, 10);
106  }
107  if (path == null || "/*".equals(path)) {
108  this.path = null;
109  } else {
110  this.path = Pattern.compile(regexFromPattern(path, true));
111  }
112  } catch (NumberFormatException e) {
113  throw new MalformedURLException("Port must be a number");
114  }
115  }
Pattern path
Definition: URLPatternList.java:86
Pattern host
Definition: URLPatternList.java:84
Pattern scheme
Definition: URLPatternList.java:83
String regexFromPattern(String pattern, boolean allowWildcards)
Definition: URLPatternList.java:129
Integer port
Definition: URLPatternList.java:85

関数詳解

◆ matches()

boolean org.xdi.oxauth.model.util.URLPatternList.URLPattern.matches ( URI  uri)
inline
117  {
118  try {
119  return ((scheme == null || scheme.matcher(uri.getScheme()).matches()) &&
120  (host == null || host.matcher(uri.getHost()).matches()) &&
121  (port == null || port.equals(uri.getPort())) &&
122  (path == null || path.matcher(uri.getPath()).matches()));
123  } catch (Exception e) {
124  LOG.debug(e.toString());
125  return false;
126  }
127  }
Pattern path
Definition: URLPatternList.java:86
Pattern host
Definition: URLPatternList.java:84
Pattern scheme
Definition: URLPatternList.java:83
boolean matches(URI uri)
Definition: URLPatternList.java:117
static final Logger LOG
Definition: URLPatternList.java:18
Integer port
Definition: URLPatternList.java:85

◆ regexFromPattern()

String org.xdi.oxauth.model.util.URLPatternList.URLPattern.regexFromPattern ( String  pattern,
boolean  allowWildcards 
)
inlineprivate
129  {
130  final String toReplace = "\\.[]{}()^$?+|";
131  StringBuilder regex = new StringBuilder();
132  for (int i = 0; i < pattern.length(); i++) {
133  char c = pattern.charAt(i);
134  if (c == '*' && allowWildcards) {
135  regex.append(".");
136  } else if (toReplace.indexOf(c) > -1) {
137  regex.append('\\');
138  }
139  regex.append(c);
140  }
141  return regex.toString();
142  }

メンバ詳解

◆ host

Pattern org.xdi.oxauth.model.util.URLPatternList.URLPattern.host

◆ path

Pattern org.xdi.oxauth.model.util.URLPatternList.URLPattern.path

◆ port

Integer org.xdi.oxauth.model.util.URLPatternList.URLPattern.port

◆ scheme

Pattern org.xdi.oxauth.model.util.URLPatternList.URLPattern.scheme

このクラス詳解は次のファイルから抽出されました: