java.security.URIParameter Java Examples

The following examples show how to use java.security.URIParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicySpiFile.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #2
Source File: AuthUtils.java    From jstorm with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: PolicySpiFile.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #4
Source File: PolicySpiFile.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #5
Source File: PolicySpiFile.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #6
Source File: PolicySpiFile.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #7
Source File: PolicySpiFile.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #8
Source File: PolicySpiFile.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #9
Source File: PolicySpiFile.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #10
Source File: DefaultPolicy.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
 
Example #11
Source File: PolicySpiFile.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #12
Source File: PolicySpiFile.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #13
Source File: PolicySpiFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #14
Source File: PolicySpiFile.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #15
Source File: PolicySpiFile.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #16
Source File: JAASAuthenticationModule.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private Configuration getJAASConfig() {
	try {
		URI jaasConfigFileUri = jaasConfigFile.toURI();
		Configuration cfg =
			Configuration.getInstance("JavaLoginConfig", new URIParameter(jaasConfigFileUri));
		AppConfigurationEntry[] authEntry = cfg.getAppConfigurationEntry(loginContextName);
		if (authEntry == null) {
			throw new IllegalArgumentException("Missing '" + loginContextName +
				"' entry in JAAS config file: " + jaasConfigFile);
		}
		return cfg;
	}
	catch (NoSuchAlgorithmException e) {
		throw new RuntimeException("JAAS config error", e);
	}
}
 
Example #17
Source File: PolicySpiFile.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
            }
        }
    }
 
Example #18
Source File: PrivilegedSocketOperationsBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Setup
public void setup() throws IOException, NoSuchAlgorithmException, URISyntaxException {
    final URI policyFile = PrivilegedSocketOperationsBenchmark.class.getResource("/jmh-security.policy")
            .toURI();
    Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(policyFile)));
    System.setSecurityManager(new SecurityManager());
}
 
Example #19
Source File: ConfigFileWithBlank.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example #20
Source File: ConfigFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #21
Source File: ConfigFile.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #22
Source File: ConfigFileWithBlank.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example #23
Source File: ConfigFile.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #24
Source File: ConfigFile.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #25
Source File: ConfigFileWithBlank.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example #26
Source File: ConfigFile.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #27
Source File: ConfigFileWithBlank.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example #28
Source File: ConfigFileWithBlank.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example #29
Source File: ConfigFile.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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.
        }
 
Example #30
Source File: ConfigFileWithBlank.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}