⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 policypermission.java

📁 aglet的部分源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public boolean equalsActions(String actions) {		if (_actions == null || actions == null) {			return false;		} 		return _actions.equals(actions);	}	public boolean equalsClassName(String className) {		if (className == null) {			return false;		} 		// return _className.equals(convertClassName(className));		return _className.equals(className);	}	public boolean equalsSigners(Vector signers) {		return equalsSigners(signers, _signers);	}	public static boolean equalsSigners(Vector signersA, Vector signersB) {		return includesSigners(signersA, signersB) 			   && includesSigners(signersB, signersA);	}	public boolean equalsTargetName(String target) {		if (_targetName == null || target == null) {			return false;		} 		return _targetName.equals(target);	}	private static final String escapeBackslash(String str) {		return escapeChar(str, CHAR_BACKSLASH);	}	private static final String escapeChar(String str, char c) {		if (str == null) {			return null;		} 		StringBuffer buf = new StringBuffer(str);		int len = buf.length();		int idx = 0;		while (idx < len) {			if (buf.charAt(idx) == c) {				buf.insert(idx, CHAR_ESCAPE);				idx++;				len = buf.length();			} 			idx++;		} 		return buf.toString();	}	public String getActions() {		return _actions;	}	public String getClassName() {		return _className;	}	private PolicyFileParsingException getParsingException(String msg) {		if (_reader != null) {			return _reader.getParsingException(msg);		} else {			return new PolicyFileParsingException(msg);		} 	}	public Permission getPermission() {		return _permission;	}	public String getSignerNames() {		return _signerNames;	}	public Enumeration getSigners() {		if (_signers != null) {			return _signers.elements();		} 		return null;	}	public String getTargetName() {		return _targetName;	}	private String getType() {		String type = null;		switch (_type) {		case TYPE_PERMISSION:			type = PolicyFileReader.WORD_PERMISSION;			break;		case TYPE_PROTECTION:			type = PolicyFileReader.WORD_PROTECTION;			break;		// #     case TYPE_ALLOWANCE:		// #       type = PolicyFileReader.WORD_ALLOWANCE;		// #       break;		}		return type;	}	private static String getType(String className) {		if (className == null) {			return null;		} 		String type = null;		if (className.equals(CLASSNAME_PERMISSION) 				|| className.equals(CLASSNAME_BASIC_PERMISSION) 				|| className.equals(CLASSNAME_FILE_PERMISSION) 				|| className.equals(CLASSNAME_SOCKET_PERMISSION) 				|| className.equals(CLASSNAME_AWT_PERMISSION) 				|| className.equals(CLASSNAME_NET_PERMISSION) 				|| className.equals(CLASSNAME_PROPERTY_PERMISSION) 				|| className.equals(CLASSNAME_REFLECT_PERMISSION) 				|| className.equals(CLASSNAME_RUNTIME_PERMISSION) 				|| className.equals(CLASSNAME_SECURITY_PERMISSION) 				|| className.equals(CLASSNAME_SERIALIZABLE_PERMISSION) 				|| className.equals(CLASSNAME_UNRESOLVED_PERMISSION) 				|| className.equals(CLASSNAME_ALL_PERMISSION) 				|| className.equals(CLASSNAME_AGLET_PERMISSION) 				|| className.equals(CLASSNAME_MESSAGE_PERMISSION) 				|| className.equals(CLASSNAME_CONTEXT_PERMISSION)		// -      || className.equals(CLASSNAME_THREAD_PERMISSION)		) {			type = PolicyFileReader.WORD_PERMISSION;		} else if (className.equals(CLASSNAME_AGLET_PROTECTION) 				   || className.equals(CLASSNAME_MESSAGE_PROTECTION)) {			type = PolicyFileReader.WORD_PROTECTION;			// #     } else if(className.equals(CLASSNAME_ACTIVITY_PERMISSION)) {			// #       type = PolicyFileReader.WORD_ALLOWANCE;		} 		return type;	}	protected static boolean includesSigners(Vector names, Vector signers) {		if (names == null) {			// nobody			return true;		} 		if (signers == null) {			// empty			return false;		} 		final int num = names.size();		int i;		for (i = 0; i < num; i++) {			Object obj = names.elementAt(i);			if (obj instanceof String) {				String name = (String)obj;				if (!isSigner(name, signers)) {					return false;				} 			} 		} 		return true;	}	protected boolean isSignedBy(String signer) {		// verify the permission class is signed by the signer.		if (signer.equals("*")) {			// regard as anybody			return true;		} 		// tentative		return true;	}	protected boolean isSignedBy(Vector signers) {		// verify the permission class is signed by signers.		if (signers == null) {			// regard as anybody			return true;		} 		final int num = signers.size();		int i;		for (i = 0; i < num; i++) {			Object obj = signers.elementAt(i);			if (obj instanceof String) {				String signer = (String)obj;				if (!isSignedBy(signer)) {					return false;				} 			} 		} 		return true;	}	protected static boolean isSigner(String name, Vector signers) {		if (name == null) {			// nobody			return true;		} 		if (signers == null) {			// empty			return false;		} 		final int num = signers.size();		int i;		for (i = 0; i < num; i++) {			Object obj = signers.elementAt(i);			if (obj instanceof String) {				String signer = (String)obj;				if (name.equals(signer)) {					return true;				} 			} 		} 		return false;	}	public void setActions(String actions) {		_actions = actions;	}	protected void setClassName(String name) throws ClassNotFoundException {		// final String className = convertClassName(name);		final String className = name;		_class = Class.forName(className);		_originalClassName = name;		_className = className;	}	public void setSignerNames(String signerNames) throws SecurityException {		Vector signers = null;		if (signerNames != null) {			signers = new Vector();			StringTokenizer st = new StringTokenizer(signerNames, 													 NAME_SEPARATOR);			while (st.hasMoreTokens()) {				signers.addElement(st.nextToken().trim());			} 		} 		checkSigners(signers);		_signers = signers;		_signerNames = signerNames;	}	public void setTargetName(String targetName) {		_targetName = targetName;	}	private void setType(String type) {		if (type == null) {			_type = NO_TYPE;			return;		} 		if (type.equals(PolicyFileReader.WORD_PERMISSION)) {			_type = TYPE_PERMISSION;		} else if (type.equals(PolicyFileReader.WORD_PROTECTION)) {			_type = TYPE_PROTECTION;			// #     } else if(type.equals(PolicyFileReader.WORD_ALLOWANCE)) {			// #       _type = TYPE_ALLOWANCE;		} else {			_type = NO_TYPE;		} 	}	public String toString() {		String str = getType();		if (_class != null) {			// str += " "+_class.getName();			str += " " + _originalClassName;		} 		if (_targetName != null) {			str += " " + QUOTE + escapeBackslash(_targetName) + QUOTE;		} 		if (_actions != null) {			str += COMMA + " " + QUOTE + escapeBackslash(_actions) + QUOTE;		} 		if (_signers != null) {			final int num = _signers.size();			if (num > 0) {				String names = QUOTE;				int i;				for (i = 0; i < num; i++) {					if (i > 0) {						names += NAME_SEPARATOR;					} 					names += _signers.elementAt(i).toString();				} 				names += QUOTE;				str += COMMA + " " + PolicyFileReader.WORD_SIGNEDBY + " " 					   + names;			} 		} 		str += TERMINATOR;		return str;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -