Package javax.security.auth.login

Examples of javax.security.auth.login.Configuration


                @SuppressWarnings("unchecked")
                Class<Configuration> sunConfigFile = (Class<Configuration>)
                        Class.forName("com.sun.security.auth.login.ConfigFile");
                Constructor<Configuration> constructor =
                        sunConfigFile.getConstructor(URI.class);
                Configuration config = constructor.newInstance(uri);
                this.jaasConfiguration = config;
                this.jaasConfigurationLoaded = true;
                return this.jaasConfiguration;
            }
        } catch (URISyntaxException ex) {
View Full Code Here


     * @return all JAAS-Login Modules for this application or null if none
     */
    private AppConfigurationEntry[] getJAASConfig() {

        // check if jaas-loginModule or fallback is configured
        Configuration logins = null;
        try {
            logins = Configuration.getConfiguration();
        } catch (Exception e) {
            // means no JAAS configuration file OR no permission to read it
        }
        if (logins != null) {
            try {
                return logins.getAppConfigurationEntry(appName);
            } catch (Exception e) {
                // WLP 9.2.0 throws IllegalArgumentException for unknown appName
            }
        }
        return null;
View Full Code Here

     */
    @Nonnull
    @Override
    public LoginContextProvider getLoginContextProvider(ContentRepository contentRepository) {
        String appName = config.getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
        Configuration loginConfig = null;
        try {
            loginConfig = Configuration.getConfiguration();
            // FIXME: workaround for Java7 behavior. needs clean up (see OAK-497)
            if (loginConfig.getAppConfigurationEntry(appName) == null) {
                loginConfig = null;
            }
        } catch (SecurityException e) {
            log.info("Failed to retrieve login configuration: using default. " + e);
        }
View Full Code Here

*/
public class GuestDefaultLoginModuleTest extends AbstractSecurityTest {

    @Override
    protected Configuration getConfiguration() {
        return new Configuration() {
            @Override
            public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
                AppConfigurationEntry guestEntry = new AppConfigurationEntry(
                        GuestLoginModule.class.getName(),
                        AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL,
View Full Code Here

@Ignore //ignore for the moment because "mvn test" runs into PermGen memory issues
public class LdapLoginStandaloneTest extends LdapLoginTestBase {

    @Override
    protected Configuration getConfiguration() {
        return new Configuration() {
            @Override
            public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
                return new AppConfigurationEntry[]{
                        new AppConfigurationEntry(
                                LdapLoginModule.class.getName(),
View Full Code Here

@Ignore //ignore for the moment because "mvn test" runs into PermGen memory issues
public class LdapLoginWithRepoLoginTest extends LdapLoginTestBase {

    @Override
    protected Configuration getConfiguration() {
        return new Configuration() {
            @Override
            public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
                return new AppConfigurationEntry[]{
                        new AppConfigurationEntry(
                                LoginModuleImpl.class.getName(),
View Full Code Here

          Thread.currentThread().setContextClassLoader(
                  this.getClass().getClassLoader());
        }

        try {
            Configuration config = getConfig();
            loginContext = new LoginContext(
                    appName, null, callbackHandler, config);
        } catch (Throwable e) {
            ExceptionUtils.handleThrowable(e);
            log.error(sm.getString("jaasRealm.unexpectedError"), e);
View Full Code Here

                @SuppressWarnings("unchecked")
                Class<Configuration> sunConfigFile = (Class<Configuration>)
                        Class.forName("com.sun.security.auth.login.ConfigFile");
                Constructor<Configuration> constructor =
                        sunConfigFile.getConstructor(URI.class);
                Configuration config = constructor.newInstance(uri);
                this.jaasConfiguration = config;
                this.jaasConfigurationLoaded = true;
                return this.jaasConfiguration;
            }
        } catch (URISyntaxException ex) {
View Full Code Here

      Configuration.setConfiguration(config);
   }

   public void testPropertyReplacement() throws Exception
   {
      Configuration config = Configuration.getConfiguration();
      AppConfigurationEntry[] entries = config.getAppConfigurationEntry("testPropertyReplacement");
      assertTrue("entries.length == 1", entries.length == 1);
      AppConfigurationEntry entry = entries[0];
      LoginModuleControlFlag flag = entry.getControlFlag();
      assertTrue("flag == required", flag == LoginModuleControlFlag.REQUIRED);
      Map options = entry.getOptions();
View Full Code Here

      Configuration.setConfiguration(config);
   }

   public void testSecurityDomainLoginModuleOption() throws Exception
   {
      Configuration config = Configuration.getConfiguration();
      String validSecurityDomain = "testUsersRoles";
      String invalidSecurityDomain = "doesNotExist";

      getLog().info("testSecurityDomainLoginModuleOption");

      //get the app configuration for a valid security domain...
      AppConfigurationEntry[] entries = config.getAppConfigurationEntry(validSecurityDomain);
      assertTrue("Entries not null",entries != null);

      //for each login module configured in domain, check that the option is set as expected.
      for (int i=0;i<entries.length;i++)
      {
   String loginModuleClass = entries[i].getLoginModuleName();
         String flag = entries[i].getControlFlag().toString();
   Map options = entries[i].getOptions();

   getLog().info(loginModuleClass + " is " + flag + "\nWith options...\n" + options);
  
   String option = (String)options.get(SecurityConstants.SECURITY_DOMAIN_OPTION);
   assertTrue("Security domain option has value \"" + option +
        "\", it should be \"" + validSecurityDomain + "\"",
        option.equals(validSecurityDomain));
      }

      //now get the app configuration for a domain that does not exist.
      entries = config.getAppConfigurationEntry(invalidSecurityDomain);
      assertTrue("Entries not null", entries != null);

      //for each login module config'ed in domain, check that the option is set as "other"
      for (int i=0;i<entries.length;i++)
      {
View Full Code Here

TOP

Related Classes of javax.security.auth.login.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.