Package javax.security.auth.login

Examples of javax.security.auth.login.Configuration


      private Object target;
      private LoginContext loginContext;

      public JaasSecurityHandler(Object target, final String username, final String password) {
          this.target = target;               
          Configuration jaasConfig = new JBossConfiguration();
          try {
              this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, null, new CallbackHandler() {
         
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
View Full Code Here


      throws MBeanException, ReflectionException
   {
      Object value = null;
      if( method.equals("getConfiguration") )
      {
         Configuration currentConfig = (Configuration) args[0];
         value = this.getConfiguration(currentConfig);
      }
      return value;
   }
View Full Code Here

    *
    * @param loginConfig a reference to the {@code XMLLoginConfig} instance.
    */
   public synchronized void pushLoginConfig(XMLLoginConfig loginConfig)
   {
      Configuration prevConfig = null;
      if (!this.loginConfigStack.empty())
         prevConfig = this.loginConfigStack.peek();
      Configuration configuration = loginConfig.getConfiguration(prevConfig);
      Configuration.setConfiguration(configuration);
      this.loginConfigStack.push(configuration);
      log.debug("Installed JAAS configuration: " + configuration);
   }
View Full Code Here

         params={@ManagementParameter(name="objectName", description="The identifier of the MBean that contains the Configuration")},
         impact = Impact.WriteOnly)
   public synchronized void pushLoginConfig(String objectName) throws JMException, MalformedObjectNameException
   {
      ObjectName name = new ObjectName(objectName);
      Configuration prevConfig = null;
      if (!this.loginConfigStack.empty())
         prevConfig = this.loginConfigStack.peek();

      this.loginConfigStack.push(installConfig(name, prevConfig));
   }
View Full Code Here

            super.log.debug("Unable to pop configuration: configuration stack is empty");
         return;
      }
     
      // remove the current configuration from the stack.
      Configuration currentConfig = this.loginConfigStack.pop();
      if (!this.loginConfigStack.empty())
      {
         // if there is a previous configuration, install it as the current instance.
         Configuration previousConfig = this.loginConfigStack.peek();
         if (super.log.isDebugEnabled())
            super.log.debug("Installing previous configuration " + previousConfig.getClass().getName());
         Configuration.setConfiguration(previousConfig);
      }
      else
      {
         if(super.log.isDebugEnabled())
View Full Code Here

    */
   private Configuration installConfig(ObjectName name, Configuration prevConfig) throws JMException
   {
      Object[] args = {prevConfig};
      String[] signature = {"javax.security.auth.login.Configuration"};
      Configuration config = (Configuration) this.getMbeanServer().invoke(name, "getConfiguration", args, signature);
      Configuration.setConfiguration(config);
      log.debug("Installed JAAS Configuration service=" + name + ", config=" + config);
      return config;
   }
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

            username = principal.toString();
         }
   
         UsernamePasswordHandler handler = new UsernamePasswordHandler(username,
            credentials);
         Configuration conf = getConfiguration();
         // Do the JAAS login
         LoginContext lc = new LoginContext(protocol, null, handler, conf);
         lc.login();
      }
      catch(LoginException e)
View Full Code Here

    * Either call Configuration.getConfiguration() like LoginContext does, or if that fails due to no
    * auth.conf or whatever config file, then return DummyConfiguration which does what we expect for
    * UsernamePasswordHandler.
    */
   private Configuration getConfiguration() {
      Configuration conf = null;
      try {
        conf = Configuration.getConfiguration();
      } catch (Exception e) {
        if(e.getCause() instanceof IOException) { //no auth.conf or whatever so we make our own dummy
            conf = new DummyConfiguration();
View Full Code Here

*/
public class SecurityTest extends AbstractSeamTest
{    
   private Configuration createMockJAASConfiguration()
   {
      return new Configuration()
      {
         private AppConfigurationEntry[] aces = { new AppConfigurationEntry(
               MockLoginModule.class.getName(),
               LoginModuleControlFlag.REQUIRED,
               new HashMap<String,String>()
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.