Search in sources :

Example 6 with URIParameter

use of java.security.URIParameter in project jstorm by alibaba.

the class AuthUtils method GetConfiguration.

/**
     * 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;
}
Also used : URIParameter(java.security.URIParameter) Configuration(javax.security.auth.login.Configuration) File(java.io.File) URI(java.net.URI) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 7 with URIParameter

use of java.security.URIParameter in project jdk8u_jdk by JetBrains.

the class ConfigFileWithBlank method main.

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();
    }
}
Also used : URIParameter(java.security.URIParameter) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Aggregations

URIParameter (java.security.URIParameter)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 File (java.io.File)4 IOException (java.io.IOException)4 URI (java.net.URI)4 FileNotFoundException (java.io.FileNotFoundException)3 Configuration (javax.security.auth.login.Configuration)3 FileOutputStream (java.io.FileOutputStream)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Permission (java.security.Permission)1 PermissionCollection (java.security.PermissionCollection)1 Permissions (java.security.Permissions)1 Policy (java.security.Policy)1 UnresolvedPermission (java.security.UnresolvedPermission)1 SuppressForbidden (org.elasticsearch.common.SuppressForbidden)1 LoginConfigImpl (sun.security.jgss.LoginConfigImpl)1