/*
 * JBoss, Home of Professional Open Source
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss.security.auth.login;

import javax.xml.namespace.QName;
import javax.security.auth.login.AppConfigurationEntry;

import org.jboss.xb.binding.GenericValueContainer;

/**
 * A container for creating AuthenticationInfo during jbxb parse.
 * 
 * @author Scott.Stark@jboss.org
 * @version $Revision: 1.1 $
 */
public class AuthenticationInfoContainer
   implements GenericValueContainer
{
   AuthenticationInfo info;

   public void addChild(QName name, Object value)
   {
      if("name".equals(name.getLocalPart()))
      {
         String infoName = (String)value;
         info = new AuthenticationInfo(infoName);
      }
      else if( value instanceof AppConfigurationEntryHolder )
      {
         AppConfigurationEntryHolder ace = (AppConfigurationEntryHolder) value;
         info.addAppConfigurationEntry(ace.getEntry());
      }
      else if( value instanceof AppConfigurationEntry )
      {
         AppConfigurationEntry ace = (AppConfigurationEntry) value;
         info.addAppConfigurationEntry(ace);
      }
   }

   public Object instantiate()
   {
      return info;
   }

}
