javax.security.auth.login.Configuration.getInstance()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(180)

本文整理了Java中javax.security.auth.login.Configuration.getInstance()方法的一些代码示例,展示了Configuration.getInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getInstance()方法的具体详情如下:
包路径:javax.security.auth.login.Configuration
类名称:Configuration
方法名:getInstance

Configuration.getInstance介绍

暂无

代码示例

代码示例来源:origin: apache/storm

/**
 * Construct a JAAS configuration object per storm configuration file
 *
 * @param topoConf Storm configuration
 * @return JAAS configuration object
 */
public static Configuration getConfiguration(Map<String, Object> topoConf) {
  Configuration login_conf = null;
  //find login file configuration from Storm configuration
  String loginConfigurationFile = (String) topoConf.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;
}

代码示例来源:origin: alibaba/jstorm

/**
 * 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;
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
String path = Configuration.getInstance().getAppFolder();
String cmd = "java -XX:+ForceTimeHighResolution  -cp "+path+"\\"+jarName+" "+ mainClassWithPackageName;
System.out.println("invoking... \n"+cmd);
Process p;
try {
    P = Runtime.getRuntime().exec(cmd);
    p.waitFor();
    System.out.println("Script executed successfully");
} catch (Exception e) {
  e.printStackTrace();
}

代码示例来源:origin: stackoverflow.com

Configurable config = Configuration.getInstance();  
String host = config.getStringValue("host");   
String port = config.getIntValue("port"); 
new Connection(host, port);

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

/**
 * 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;
}

代码示例来源:origin: apache/felix

@Override
public LoginContext createLoginContext(String realm, Subject subject,
  CallbackHandler handler) throws LoginException
{
  final Thread currentThread = Thread.currentThread();
  final ClassLoader cl = currentThread.getContextClassLoader();
  try
  {
    currentThread.setContextClassLoader(ProxyLoginModule.class.getClassLoader());
    Configuration config = Configuration.getInstance("JavaLoginConfig", null,
      jaasConfigProviderName);
    return new LoginContext(realm, subject, handler, config);
  }
  catch (NoSuchProviderException e)
  {
    throw new LoginException(e.getMessage());
  }
  catch (NoSuchAlgorithmException e)
  {
    throw new LoginException(e.getMessage());
  }
  finally
  {
    currentThread.setContextClassLoader(cl);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * 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;
}

代码示例来源:origin: com.n3twork.storm/storm-core

/**
 * 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;
}

代码示例来源:origin: org.apache.felix/org.apache.felix.jaas

@Override
public LoginContext createLoginContext(String realm, Subject subject,
  CallbackHandler handler) throws LoginException
{
  final Thread currentThread = Thread.currentThread();
  final ClassLoader cl = currentThread.getContextClassLoader();
  try
  {
    currentThread.setContextClassLoader(ProxyLoginModule.class.getClassLoader());
    Configuration config = Configuration.getInstance("JavaLoginConfig", null,
      jaasConfigProviderName);
    return new LoginContext(realm, subject, handler, config);
  }
  catch (NoSuchProviderException e)
  {
    throw new LoginException(e.getMessage());
  }
  catch (NoSuchAlgorithmException e)
  {
    throw new LoginException(e.getMessage());
  }
  finally
  {
    currentThread.setContextClassLoader(cl);
  }
}

代码示例来源:origin: org.apereo.cas/cas-server-core-authentication-api

/**
 * Gets login context.
 *
 * @param credential the credential
 * @return the login context
 * @throws GeneralSecurityException the general security exception
 */
protected LoginContext getLoginContext(final UsernamePasswordCredential credential) throws GeneralSecurityException {
  val callbackHandler = new UsernamePasswordCallbackHandler(credential.getUsername(), credential.getPassword());
  if (this.loginConfigurationFile != null && StringUtils.isNotBlank(this.loginConfigType)
    && this.loginConfigurationFile.exists() && this.loginConfigurationFile.canRead()) {
    final Configuration.Parameters parameters = new URIParameter(loginConfigurationFile.toURI());
    val loginConfig = Configuration.getInstance(this.loginConfigType, parameters);
    return new LoginContext(this.realm, null, callbackHandler, loginConfig);
  }
  return new LoginContext(this.realm, callbackHandler);
}

代码示例来源:origin: stackoverflow.com

final int MAX_POOL_SIZE = Configuration.getInstance().DB_MAX_CONNECTIONS;
Configuration config = Configuration.getInstance();
try {
 Class.forName(config.DB_DRIVER);

代码示例来源:origin: org.springframework.data/spring-data-hadoop-core

javax.security.auth.login.Configuration.getInstance(null, null, (String) null);
} catch (Exception ex) {

代码示例来源:origin: apache/jackrabbit-oak

loginConfig = Configuration.getInstance(
    "JavaLoginConfig",
    null,

代码示例来源:origin: org.apache.jackrabbit/oak-core

loginConfig = Configuration.getInstance(
    "JavaLoginConfig",
    null,

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

loginConfig = Configuration.getInstance(
    "JavaLoginConfig",
    null,

代码示例来源:origin: fbacchella/LogHub

URIParameter cp = new URIParameter(Paths.get(jaasConfigFilePath).toUri());
try {
  jc = javax.security.auth.login.Configuration.getInstance("JavaLoginConfig", cp);
} catch (NoSuchAlgorithmException e) {
  throw new RuntimeException("JavaLoginConfig unavailable", e);

代码示例来源:origin: net.shibboleth.idp/idp-authn-impl

/**
 * Create a JAAS configuration and attempt a login with it.
 * 
 * @param loginConfigName the application name to use
 * 
 * @throws LoginException if the JAAS login process fails
 * @throws NoSuchAlgorithmException if a JAAS configuration cannot be created
 */
private void authenticate(@Nonnull @NotEmpty final String loginConfigName)
    throws LoginException, NoSuchAlgorithmException {
  
  final javax.security.auth.login.LoginContext jaasLoginCtx;
  
  if (getLoginConfigType() != null) {
    log.debug("{} Using custom JAAS configuration type {} with parameters of type {}", getLogPrefix(),
        getLoginConfigType(), getLoginConfigParameters().getClass().getName());
    final Configuration loginConfig =
        Configuration.getInstance(getLoginConfigType(), getLoginConfigParameters());
    jaasLoginCtx = new javax.security.auth.login.LoginContext(loginConfigName, getSubject(),
        new SimpleCallbackHandler(), loginConfig);
  } else {
    log.debug("{} Using system JAAS configuration", getLogPrefix());
    jaasLoginCtx = new javax.security.auth.login.LoginContext(loginConfigName, getSubject(),
        new SimpleCallbackHandler());
  }
  jaasLoginCtx.login();
}

代码示例来源:origin: stackoverflow.com

config = Configuration.getInstance();

代码示例来源:origin: stackoverflow.com

boolean demo =Configuration.getInstance().isDemo();
if (demo ==true)
  return;
if ( Configuration.getInstance().isDemo())
if ( Configuration.getInstance().isDemo())

代码示例来源:origin: stackoverflow.com

boolean demo =Configuration.getInstance().isDemo();
if (demo ==true)
  return;
if ( Configuration.getInstance().isDemo())
if ( Configuration.getInstance().isDemo())

相关文章