All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.security.config.BaseSecurityInfo Maven / Gradle / Ivy

There is a newer version: 5.1.0.Final
Show newest version
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2007, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.security.config;

import java.util.ArrayList;
import java.util.List;

import javax.security.auth.AuthPermission;

/**
 * Base Class of the security info
 * 
 * @author [email protected]
 * @since Sep 27, 2007
 * @version $Revision$
 * @param 
 */
public abstract class BaseSecurityInfo
{
   public static final AuthPermission GET_CONFIG_ENTRY_PERM = new AuthPermission("getLoginConfiguration");

   public static final AuthPermission SET_CONFIG_ENTRY_PERM = new AuthPermission("setLoginConfiguration");

   protected String name;

   protected ArrayList moduleEntries = new ArrayList();
   
   /**
    * Name of the JBoss Module that can be optionally configured for
    * custom login modules etc
    */
   protected String jbossModuleName;

   public BaseSecurityInfo()
   {
   }

   public BaseSecurityInfo(String name)
   {
      this.name = name;
   }

   public void add(T ame)
   {
      moduleEntries.add(ame);
   }

   public void add(List moduleEntries)
   {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null)
         sm.checkPermission(SET_CONFIG_ENTRY_PERM);
      this.moduleEntries.addAll(moduleEntries);
   }

   public List getModuleEntries()
   {
      SecurityManager sm = System.getSecurityManager();
      if (sm != null)
         sm.checkPermission(GET_CONFIG_ENTRY_PERM);
      return this.moduleEntries;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
	   this.name = name;
   }

   /**
    * Get the name of the JBoss Module
    * @return
    */
   public String getJBossModuleName() 
   {
	   return jbossModuleName;
   }

   /**
    * Set the name of the JBoss Module
    * @param jbossModuleName
    */
   public void setJBossModuleName(String jbossModuleName) 
   {
	   this.jbossModuleName = jbossModuleName;
   }

   protected abstract BaseSecurityInfo create(String name);

   public BaseSecurityInfo merge(BaseSecurityInfo bi)
   {
      if (bi == null)
         return this;
      List al = new ArrayList();
      al.addAll(bi.getModuleEntries());
      al.addAll(this.moduleEntries);
      BaseSecurityInfo mergedBAI = create(name);
      mergedBAI.add(al);
      return mergedBAI;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy