当前位置: 首页>>代码示例>>Java>>正文


Java GrantEntry类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:AuthPolicyFile.java

示例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));
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:40,代码来源:AuthPolicyFile.java


注:本文中的sun.security.provider.PolicyParser.GrantEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。