Java 类java.security.URIParameter 实例源码

项目:OpenJSharp    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jdk8u-jdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:openjdk-jdk10    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:openjdk-jdk10    文件:DefaultPolicy.java   
public static void main(String[] args) throws Exception {

        // Check policy with no java.security.policy property set
        Policy p = Policy.getPolicy();
        checkPolicy(p);

        // Check policy with java.security.policy '=' option
        System.setProperty("java.security.policy", "Extra.policy");
        p.refresh();
        checkPolicy(p);

        // Check policy with java.security.policy override '==' option
        System.setProperty("java.security.policy", "=Extra.policy");
        p.refresh();
        checkPolicy(p);

        // Check Policy.getInstance
        URI policyURI = Paths.get(System.getProperty("test.src"),
                                  "Extra.policy").toUri();
        p = Policy.getInstance("JavaPolicy", new URIParameter(policyURI));
        checkPolicy(p);
    }
项目:openjdk9    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jdk8u_jdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jstorm-0.9.6.3-    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file 
 * @param storm_conf Storm configuration 
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    //find login file configuration from Storm configuration  
    String loginConfigurationFile = (String)storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length()>0)) { 
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "+loginConfigurationFile+" could not be found");
            else throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:icedtea-web    文件:SecurityDesc.java   
/**
 * Returns a Policy object that represents a custom policy to use instead
 * of granting {@link AllPermission} to a {@link CodeSource}
 *
 * @return a {@link Policy} object to delegate to. May be null, which
 * indicates that no policy exists and AllPermissions should be granted
 * instead.
 */
private Policy getCustomTrustedPolicy() {
    String key = DeploymentConfiguration.KEY_SECURITY_TRUSTED_POLICY;
    String policyLocation = JNLPRuntime.getConfiguration().getProperty(key);

    Policy policy = null;
    if (policyLocation != null) {
        try {
            URI policyUri = new URI("file://" + policyLocation);
            policy = Policy.getInstance("JavaPolicy", new URIParameter(policyUri));
        } catch (Exception e) {
            OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
        }
    }
    // return the appropriate policy, or null
    return policy;
}
项目:learn_jstorm    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file
 * 
 * @param storm_conf
 *            Storm configuration
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    // find login file configuration from Storm configuration
    String loginConfigurationFile = (String) storm_conf
            .get("java.security.auth.login.config");
    if ((loginConfigurationFile != null)
            && (loginConfigurationFile.length() > 0)) {
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig",
                    new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "
                        + loginConfigurationFile + " could not be found");
            else
                throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:learn_jstorm    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file 
 * @param storm_conf Storm configuration 
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    //find login file configuration from Storm configuration  
    String loginConfigurationFile = (String)storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length()>0)) { 
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "+loginConfigurationFile+" could not be found");
            else throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:jstrom    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file
 * 
 * @param storm_conf Storm configuration
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    // find login file configuration from Storm configuration
    String loginConfigurationFile = (String) storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length() > 0)) {
        File config_file = new File(loginConfigurationFile);
        if (!config_file.canRead()) {
            throw new RuntimeException("File " + loginConfigurationFile + " cannot be read.");
        }
        try {
            URI config_uri = config_file.toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    return login_conf;
}
项目:jstrom    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file 
 * @param storm_conf Storm configuration 
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    //find login file configuration from Storm configuration  
    String loginConfigurationFile = (String)storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length()>0)) { 
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "+loginConfigurationFile+" could not be found");
            else throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:Tstream    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file
 * 
 * @param storm_conf
 *            Storm configuration
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    // find login file configuration from Storm configuration
    String loginConfigurationFile = (String) storm_conf
            .get("java.security.auth.login.config");
    if ((loginConfigurationFile != null)
            && (loginConfigurationFile.length() > 0)) {
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig",
                    new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "
                        + loginConfigurationFile + " could not be found");
            else
                throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:infobip-open-jdk-8    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jdk8u-dev-jdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jdk7-jdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:openjdk-source-code-learn    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:OLD-OpenJDK8    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:incubator-storm    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file 
 * @param storm_conf Storm configuration 
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    //find login file configuration from Storm configuration  
    String loginConfigurationFile = (String)storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length()>0)) { 
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "+loginConfigurationFile+" could not be found");
            else throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:storm-resa    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file 
 * @param storm_conf Storm configuration 
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    //find login file configuration from Storm configuration  
    String loginConfigurationFile = (String)storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length()>0)) { 
        try {
            URI config_uri = new File(loginConfigurationFile).toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (NoSuchAlgorithmException ex1) {
            if (ex1.getCause() instanceof FileNotFoundException)
                throw new RuntimeException("configuration file "+loginConfigurationFile+" could not be found");
            else throw new RuntimeException(ex1);
        } catch (Exception ex2) {
            throw new RuntimeException(ex2);
        }
    }

    return login_conf;
}
项目:openjdk-jdk7u-jdk    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:openjdk-icedtea7    文件:PolicySpiFile.java   
public PolicySpiFile(Policy.Parameters params) {

        if (params == null) {
            pf = new PolicyFile();
        } else {
            if (!(params instanceof URIParameter)) {
                throw new IllegalArgumentException
                        ("Unrecognized policy parameter: " + params);
            }
            URIParameter uriParam = (URIParameter)params;
            try {
                pf = new PolicyFile(uriParam.getURI().toURL());
            } catch (MalformedURLException mue) {
                throw new IllegalArgumentException("Invalid URIParameter", mue);
            }
        }
    }
项目:jstorm    文件:AuthUtils.java   
/**
 * Construct a JAAS configuration object per storm configuration file
 * 
 * @param storm_conf Storm configuration
 * @return JAAS configuration object
 */
public static Configuration GetConfiguration(Map storm_conf) {
    Configuration login_conf = null;

    // find login file configuration from Storm configuration
    String loginConfigurationFile = (String) storm_conf.get("java.security.auth.login.config");
    if ((loginConfigurationFile != null) && (loginConfigurationFile.length() > 0)) {
        File config_file = new File(loginConfigurationFile);
        if (!config_file.canRead()) {
            throw new RuntimeException("File " + loginConfigurationFile + " cannot be read.");
        }
        try {
            URI config_uri = config_file.toURI();
            login_conf = Configuration.getInstance("JavaLoginConfig", new URIParameter(config_uri));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    return login_conf;
}
项目:OpenJSharp    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
项目:jdk8u-jdk    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
项目:jdk8u-jdk    文件:ConfigFileWithBlank.java   
public static void main(String[] args) throws Exception {
    File f = new File("a b c");
    FileOutputStream fos = new FileOutputStream(f);
    fos.write("".getBytes());
    fos.close();
    System.err.println(f.toURI());
    try {
        Configuration.getInstance("JavaLoginConfig", new URIParameter(f.toURI()));
    } finally {
        f.delete();
    }
}
项目:openjdk-jdk10    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
项目:openjdk-jdk10    文件:DefineClass.java   
public static void main(String[] args) throws Exception {

        Security.addProvider(new TestProvider());

        MySecureClassLoader scl = new MySecureClassLoader();

        File policyFile = new File(System.getProperty("test.src", "."),
                                   "DefineClass.policy");
        Policy p = Policy.getInstance("JavaPolicy",
                                      new URIParameter(policyFile.toURI()));
        Policy.setPolicy(p);

        System.setSecurityManager(new SecurityManager());
        ArrayList<Permission> perms1 = getPermissions(scl, p,
                                                      "http://localhost/",
                                                      "foo.Foo", FOO_CLASS,
                                                      null);
        checkPerms(perms1, GRANTED_PERMS);
        ArrayList<Permission> perms2 = getPermissions(scl, p,
                                                      "http://127.0.0.1/",
                                                      "bar.Bar", BAR_CLASS,
                                                      null);
        checkPerms(perms2, GRANTED_PERMS);
        assert(perms1.equals(perms2));

        // check that class signed by baz is granted an additional permission
        Certificate[] chain = new Certificate[] {getCert(BAZ_CERT)};
        ArrayList<Permission> perms3 = getPermissions(scl, p,
                                                      "http://localhost/",
                                                      "baz.Baz", BAZ_CLASS,
                                                      chain);
        List<Permission> perms = new ArrayList<>(Arrays.asList(GRANTED_PERMS));
        perms.add(new PropertyPermission("user.dir", "read"));
        checkPerms(perms3, perms.toArray(new Permission[0]));
    }
项目:openjdk-jdk10    文件:BadPolicyFile.java   
public static void main(String[] args) throws Exception {
    URI uri = new File(System.getProperty("test.src", "."),
                       "BadPolicyFile.policy").toURI();
    Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(uri)));
    System.setSecurityManager(new SecurityManager());
    try {
        String javahome = System.getProperty("java.home");
        throw new Exception("Expected AccessControlException");
    } catch (AccessControlException ace) {
        System.out.println("Test PASSED");
    }
}
项目:openjdk-jdk10    文件:TrustManagerTest.java   
public static void main(String[] args) throws Exception {
    if (initSecmod() == false) {
        return;
    }

    if ("sparc".equals(System.getProperty("os.arch")) == false) {
        // we have not updated other platforms with the proper NSS libraries yet
        System.out.println("Test currently works only on solaris-sparc, skipping");
        return;
    }

    String configName = BASE + SEP + "fips.cfg";
    Provider p = getSunPKCS11(configName);

    System.out.println(p);
    Security.addProvider(p);

    Security.removeProvider("SunJSSE");
    Provider jsse = new com.sun.net.ssl.internal.ssl.Provider(p);
    Security.addProvider(jsse);
    System.out.println(jsse.getInfo());

    KeyStore ks = KeyStore.getInstance("PKCS11", p);
    ks.load(null, "test12".toCharArray());

    X509Certificate server = loadCertificate("certs/server.cer");
    X509Certificate ca = loadCertificate("certs/ca.cer");
    X509Certificate anchor = loadCertificate("certs/anchor.cer");

    if (args.length > 1 && "sm".equals(args[0])) {
        Policy.setPolicy(Policy.getInstance("JavaPolicy",
                new URIParameter(new File(BASE, args[1]).toURI())));
        System.setSecurityManager(new SecurityManager());
    }

    KeyStore trustStore = KeyStore.getInstance("JKS");
    trustStore.load(null, null);
    trustStore.setCertificateEntry("anchor", anchor);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
    tmf.init(trustStore);

    X509TrustManager tm = (X509TrustManager)tmf.getTrustManagers()[0];

    X509Certificate[] chain = {server, ca, anchor};

    tm.checkServerTrusted(chain, "RSA");

    System.out.println("OK");
}
项目:openjdk-jdk10    文件:GetInstance.java   
private int testURIParam(int testnum) throws Exception {
    // get an instance of JavaLoginConfig
    // from SUN and have it read from the URI

    File file = new File(System.getProperty("test.src", "."),
                            "GetInstance.configURI");
    URI uri = file.toURI();
    URIParameter uriParam = new URIParameter(uri);
    Configuration c = Configuration.getInstance(JAVA_CONFIG, uriParam);
    doTestURI(c, uriParam, testnum++);

    return testnum;
}
项目:openjdk-jdk10    文件:ConfigFileWithBlank.java   
public static void main(String[] args) throws Exception {
    File f = new File("a b c");
    FileOutputStream fos = new FileOutputStream(f);
    fos.write("".getBytes());
    fos.close();
    System.err.println(f.toURI());
    try {
        Configuration.getInstance("JavaLoginConfig", new URIParameter(f.toURI()));
    } finally {
        f.delete();
    }
}
项目:openjdk9    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
项目:openjdk9    文件:DefineClass.java   
public static void main(String[] args) throws Exception {

        Security.addProvider(new TestProvider());

        MySecureClassLoader scl = new MySecureClassLoader();

        File policyFile = new File(System.getProperty("test.src", "."),
                                   "DefineClass.policy");
        Policy p = Policy.getInstance("JavaPolicy",
                                      new URIParameter(policyFile.toURI()));
        Policy.setPolicy(p);

        System.setSecurityManager(new SecurityManager());
        ArrayList<Permission> perms1 = getPermissions(scl, p,
                                                      "http://localhost/",
                                                      "foo.Foo", FOO_CLASS,
                                                      null);
        checkPerms(perms1, GRANTED_PERMS);
        ArrayList<Permission> perms2 = getPermissions(scl, p,
                                                      "http://127.0.0.1/",
                                                      "bar.Bar", BAR_CLASS,
                                                      null);
        checkPerms(perms2, GRANTED_PERMS);
        assert(perms1.equals(perms2));

        // check that class signed by baz is granted an additional permission
        Certificate[] chain = new Certificate[] {getCert(BAZ_CERT)};
        ArrayList<Permission> perms3 = getPermissions(scl, p,
                                                      "http://localhost/",
                                                      "baz.Baz", BAZ_CLASS,
                                                      chain);
        List<Permission> perms = new ArrayList<>(Arrays.asList(GRANTED_PERMS));
        perms.add(new PropertyPermission("user.dir", "read"));
        checkPerms(perms3, perms.toArray(new Permission[0]));
    }
项目:openjdk9    文件:BadPolicyFile.java   
public static void main(String[] args) throws Exception {
    URI uri = new File(System.getProperty("test.src", "."),
                       "BadPolicyFile.policy").toURI();
    Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(uri)));
    System.setSecurityManager(new SecurityManager());
    try {
        String javahome = System.getProperty("java.home");
        throw new Exception("Expected AccessControlException");
    } catch (AccessControlException ace) {
        System.out.println("Test PASSED");
    }
}
项目:openjdk9    文件:ConfigFileWithBlank.java   
public static void main(String[] args) throws Exception {
    File f = new File("a b c");
    FileOutputStream fos = new FileOutputStream(f);
    fos.write("".getBytes());
    fos.close();
    System.err.println(f.toURI());
    try {
        Configuration.getInstance("JavaLoginConfig", new URIParameter(f.toURI()));
    } finally {
        f.delete();
    }
}
项目:jdk8u_jdk    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
项目:jdk8u_jdk    文件:ConfigFileWithBlank.java   
public static void main(String[] args) throws Exception {
    File f = new File("a b c");
    FileOutputStream fos = new FileOutputStream(f);
    fos.write("".getBytes());
    fos.close();
    System.err.println(f.toURI());
    try {
        Configuration.getInstance("JavaLoginConfig", new URIParameter(f.toURI()));
    } finally {
        f.delete();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ConfigFile.java   
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }