本文整理汇总了Java中sun.security.provider.PolicyParser.GrantEntry类的典型用法代码示例。如果您正苦于以下问题:Java GrantEntry类的具体用法?Java GrantEntry怎么用?Java GrantEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GrantEntry类属于sun.security.provider.PolicyParser包,在下文中一共展示了GrantEntry类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import sun.security.provider.PolicyParser.GrantEntry; //导入依赖的package包/类
/**
* Reads a policy configuration into the Policy object using a
* Reader object.
*
* @param policyFile the policy Reader object.
*/
private void init(URL policy) {
PolicyParser pp = new PolicyParser(expandProperties);
try (InputStreamReader isr
= new InputStreamReader(PolicyUtil.getInputStream(policy))) {
pp.read(isr);
KeyStore keyStore = initKeyStore(policy, pp.getKeyStoreUrl(),
pp.getKeyStoreType());
Enumeration<GrantEntry> enum_ = pp.grantElements();
while (enum_.hasMoreElements()) {
GrantEntry ge = enum_.nextElement();
addGrantEntry(ge, keyStore);
}
} catch (PolicyParser.ParsingException pe) {
System.err.println(AUTH_POLICY +
rb.getString(".error.parsing.") + policy);
System.err.println(AUTH_POLICY + rb.getString("COLON") +
pe.getMessage());
if (debug != null) {
pe.printStackTrace();
}
} catch (Exception e) {
if (debug != null) {
debug.println("error parsing " + policy);
debug.println(e.toString());
e.printStackTrace();
}
}
}
示例2: getCodeSource
import sun.security.provider.PolicyParser.GrantEntry; //导入依赖的package包/类
/**
* Given a PermissionEntry, create a codeSource.
*
* @return null if signedBy alias is not recognized
*/
CodeSource getCodeSource(GrantEntry ge, KeyStore keyStore)
throws java.net.MalformedURLException
{
Certificate[] certs = null;
if (ge.signedBy != null) {
certs = getCertificates(keyStore, ge.signedBy);
if (certs == null) {
// we don't have a key for this alias,
// just return
if (debug != null) {
debug.println(" no certs for alias " +
ge.signedBy + ", ignoring.");
}
return null;
}
}
URL location;
if (ge.codeBase != null) {
location = new URL(ge.codeBase);
} else {
location = null;
}
if (ge.principals == null || ge.principals.size() == 0) {
return (canonicalizeCodebase
(new CodeSource(location, certs),
false));
} else {
return (canonicalizeCodebase
(new SubjectCodeSource(null, ge.principals, location, certs),
false));
}
}