📄 rule.java
字号:
/*
* jRevProxy, an opensource Java reverse proxy server
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
* $Id: Rule.java,v 2.6 2003/04/23 21:16:53 fnoe Exp $
*/
package cx.noe.jrevproxy;
import java.util.Vector;
import java.util.Enumeration;
import java.net.URL;
/**
* Rule
*
* @author <a href="mailto:frederik@noe.cx">Frederik Noe</a>
* @version <tt>$Revision: 2.6 $</tt>
*/
public class Rule {
private String name = null;
private Vector users = null;
private String vdir = null;
private URL junction = null;
/** Creates a new instance of Rule */
public Rule() {
users = new Vector();
}
public void addUser(String subjectdn) {
users.addElement(subjectdn);
}
public void setVirtualDir(String vdir) {
this.vdir = vdir;
}
public void setJunction(String junction) throws Exception {
try {
URL tmp = new URL(junction);
int port = (tmp.getPort() == -1)?80:tmp.getPort();
this.junction = new URL(tmp.getProtocol(),tmp.getHost(),port,tmp.getFile());
}
catch(java.net.MalformedURLException e) {
throw new Exception("Junction value does not have the right syntax");
}
}
public void setName(String name) {
this.name = name;
}
public String toString() {
String newline = System.getProperty( "line.separator" );
StringBuffer buf = new StringBuffer();
buf.append("Name: ").append(name).append(newline);
buf.append("Virtual Directory: ").append(vdir).append(newline);
buf.append("Junction: ").append(junction).append(newline);
buf.append( "--Users--" ).append(newline);
for( int i=0; i<users.size(); i++ ){
buf.append("\t").append(users.elementAt(i)).append(newline);
}
return buf.toString();
}
public boolean isApplicable(String virtualdir) {
if(virtualdir == null || vdir == null)
return false;
if(vdir.compareToIgnoreCase(virtualdir) == 0)
return true;
return false;
}
public boolean isAuthorized(String subjectdn){
Enumeration enum = users.elements();
String user = null;
while(enum.hasMoreElements()) {
user = (String) enum.nextElement();
if(user.compareToIgnoreCase(subjectdn) == 0)
return true;
}
return false;
}
public URL getJunction() {
return junction;
}
public String getName() {
return name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -