Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2005, 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.Map;
 
 
 // $Id: ApplicationPolicy.java 79647 2008-10-17 15:28:20Z anil.saldhana@jboss.com $
 
Application Policy Information Holder - Authentication - Authorization - Audit - Mapping

Author(s):
Anil Saldhana
Version:
$Revision: 79647 $
Since:
Jun 9, 2006
 
 public class ApplicationPolicy
 {
    private final String name;
 
 
    private ACLInfo aclInfo;
 
 
    private AuditInfo auditInfo;
 
    private final Map<StringMappingInfomappingInfos = new HashMap<StringMappingInfo>();
 
 
    // Base application policy (if any)
 
    // Parent PolicyConfig
    private PolicyConfig policyConfig;
 
    public ApplicationPolicy(String theName)
    {
       if (theName == null)
          throw new IllegalArgumentException("name is null");
       this. = theName;
    }
 
    public ApplicationPolicy(String theNameBaseAuthenticationInfo info)
    {
       this(theName);
        = info;
    }
 
    public ApplicationPolicy(String theNameAuthorizationInfo info)
    {
       this(theName);
        = info;
    }
 
    public ApplicationPolicy(String theNameBaseAuthenticationInfo infoAuthorizationInfo info2)
    {
       this(theName);
        = info;
        = info2;
    }
 
    public ACLInfo getAclInfo()
    {
       ACLInfo info = null;
       ApplicationPolicy basePolicy = this.getBaseApplicationPolicy();
       if (basePolicy != null)
          info = basePolicy.getAclInfo();
       if (info != null && this. == null)
          return info;
       else if (info != null)
          return (ACLInfothis..merge(info);
       else
          return ;
   }
   public void setAclInfo(ACLInfo aclInfo)
   {
      this. = aclInfo;
   }
   {
      BaseAuthenticationInfo bai = null;
      if (ap != null)
         bai = ap.getAuthenticationInfo();
      if (bai != null &&  == null)
         return bai;
      else if (bai != null)
         return (BaseAuthenticationInfo.merge(bai);
      else
         return ;
   }
   public void setAuthenticationInfo(BaseAuthenticationInfo authenticationInfo)
   {
      this. = authenticationInfo;
   }
   {
      AuthorizationInfo bai = null;
      if (ap != null)
         bai = ap.getAuthorizationInfo();
      if (bai != null &&  == null)
         return bai;
      else if (bai != null)
         return (AuthorizationInfo.merge(bai);
      else
         return ;
   }
   public void setAuthorizationInfo(AuthorizationInfo authorizationInfo)
   {
      this. = authorizationInfo;
   }

   

Gets the MappingInfo object that contains the entries that will be used to map roles.

Deprecated:
use ApplicationPolicy.getMappingInfo("role") instead.
Returns:
the MappingInfo that must be used when mapping roles.
   {
      return this.getMappingInfo("role");
   }

   

Sets the MappingInfo object that must be used when mapping roles.

Deprecated:
use ApplicationPolicy.setMappingInfo("role", MappingInfo) instead.
Parameters:
roleMappingInfo the MappingInfo instance to be set.
   public void setRoleMappingInfo(MappingInfo roleMappingInfo)
   {
      this.setMappingInfo("role"roleMappingInfo);
   }

   

Gets the MappingInfo object that contains the entries that will be used to map principals.

Deprecated:
use ApplicationPolicy.getMappingInfo("principal") instead.
Returns:
the MappingInfo that must be used when mapping principals.
   {
      return this.getMappingInfo("principal");
   }

   

Sets the MappingInfo object that must be used when mapping principals.

Deprecated:
use ApplicationPolicy.setMappingInfo("principal", MappingInfo) instead.
Parameters:
roleMappingInfo the MappingInfo instance to be set.
   public void setPrincipalMappingInfo(MappingInfo principalMappingInfo)
   {
      this.setMappingInfo("principal"principalMappingInfo);
   }

   

Gets the MappingInfo instance that can map objects of the specified class.

Deprecated:
use getMappingInfo(java.lang.String) instead.
Parameters:
t the class of the objects that are to be mapped.
Returns:
the MappingInfo instance that must be used to map objects of the specified class.
   public <T> MappingInfo getMappingInfo(Class<T> t)
   {
      if (t == RoleGroup.class)
         return this.getRoleMappingInfo();
      if (t == Principal.class)
         return this.getPrincipalMappingInfo();
      throw new IllegalStateException("No mapping information available for type:" + t);
   }

   

Gets the MappingInfo instance that can perform the mappings of the specified type.

Parameters:
mappingType a String representing the type of the mappings that are to be performed. This String must match the value of the type attribute of the mapping-module that has been configured in the application policy. For example, consider the following mapping policy:
 <application-policy name="test">
    <authentication>
    ...
    </authentication>
    <mapping>
       <mapping-module code = "org.jboss.test.mapping.MappingModule1" type="role">
          <module-option name = "option1">value1</module-option>
       </mapping-module>
       <mapping-module code = "org.jboss.test.mapping.MappingModule2" type="principal">
          <module-option name = "option2">value2</module-option>
       </mapping-module>
    </mapping> while a
 </application-policy>
 
Executing this method with "role" as parameter would return a MappingInfo that is capable of mapping roles using the MappingModule1. Likewise, executing this method with "principal" as parameter would return a MappingInfo that can map principals using the MappingModule2.
Returns:
the MappingInfo instance that can perform the mappings of the specified type, or null if no suitable MappingInfo can be found.
   public MappingInfo getMappingInfo(String mappingType)
   {
      mappingType = mappingType.toLowerCase();
      MappingInfo bai = null;
      if (ap != null)
         bai = ap.getMappingInfo(mappingType);
      MappingInfo mappings = this..get(mappingType);
      if (bai != null && mappings == null)
         return bai;
      else if (bai != null)
         return (MappingInfomappings.merge(bai);
      else
         return mappings;
   }

   

Sets the MappingInfo that must be used to perform the mappings of the specified type.

Parameters:
mappingType the type of mappings that can be performed by the MappingInfo.
info a reference to the MappingInfo instance to be set.
   public void setMappingInfo(String mappingTypeMappingInfo info)
   {
      // if there is a registered info for the specified type, merge the modules.
      if(this..containsKey(mappingType))
         this..get(mappingType).add(info.getModuleEntries());
      else
         this..put(mappingTypeinfo);
   }
   public AuditInfo getAuditInfo()
   {
      AuditInfo bai = null;
      if (ap != null)
         bai = ap.getAuditInfo();
      if (bai != null &&  == null)
         return bai;
      else if (bai != null)
         return (AuditInfo.merge(bai);
      else
         return ;
   }
   public void setAuditInfo(AuditInfo auditInfo)
   {
      this. = auditInfo;
   }
   {
      IdentityTrustInfo bai = null;
      if (ap != null)
         bai = ap.getIdentityTrustInfo();
      if (bai != null &&  == null)
         return bai;
      else if (bai != null)
         return (IdentityTrustInfo.merge(bai);
      else
         return ;
   }
   public void setIdentityTrustInfo(IdentityTrustInfo identityTrustInfo)
   {
      this. = identityTrustInfo;
   }
   {
      return ;
   }
   public void setBaseApplicationPolicyName(String baseApplicationPolicy)
   {
      this. = baseApplicationPolicy;
   }
   public String getName()
   {
      return ;
   }
   {
      return ;
   }
   public void setPolicyConfig(PolicyConfig policyConfig)
   {
      this. = policyConfig;
   }
   {
      ApplicationPolicy ap = null;
      if (this. != null)
      {
         ap = this..get(this.);
         // The base application policy may exist in a different location
         if (ap == null)
            ap = SecurityConfiguration.getApplicationPolicy(this.);
      }
      return ap;
   }
New to GrepCode? Check out our FAQ X