SecurityHeader.java

  1. package fr.paris.lutece.portal.business.securityheader;

  2. import javax.validation.constraints.NotEmpty;
  3. import javax.validation.constraints.Size;

  4. /**
  5.  * This class represents a HTTP security header. It is mainly defined by a name and a value. The type is the resource on which the security
  6.  * is added to the HTTP request (html page or rest api). When the type is equals to page, it is mandatory to specify on which page (category)
  7.  * the header must be applied. The different categories are all pages, Back Office admin authenticated pages, Back Office logout page, Front
  8.  * Office admin authenticated pages and Front Office logout page
  9.  */
  10. public class SecurityHeader
  11. {
  12.     // Variables declarations
  13.     private int _nId;
  14.    
  15.     @NotEmpty( message = "portal.securityheader.validation.securityheader.Name.notEmpty" )
  16.     @Size( max = 60 , message = "portal.securityheader.validation.securityheader.Name.size" )
  17.     private String _strName;
  18.    
  19.     @NotEmpty( message = "portal.securityheader.validation.securityheader.Value.notEmpty" )
  20.     @Size( max = 1024 , message = "portal.securityheader.validation.securityheader.Value.size" )
  21.     private String _strValue;
  22.    
  23.     @Size( max = 1024 , message = "portal.securityheader.validation.securityheader.Description.size" )
  24.     private String _strDescription;
  25.    
  26.     @NotEmpty( message = "portal.securityheader.validation.securityheader.Type.notEmpty" )
  27.     @Size( max = 10 , message = "portal.securityheader.validation.securityheader.Type.size" )
  28.     private String _strType;
  29.    
  30.     @Size( max = 25 , message = "portal.securityheader.validation.securityheader.PageCategory.size" )
  31.     private String _strPageCategory;    
  32.    
  33.     private boolean _bIsActive;

  34.     /**
  35.      * Returns the Id
  36.      *
  37.      * @return The Id
  38.      */
  39.     public int getId( )
  40.     {
  41.         return _nId;
  42.     }

  43.     /**
  44.      * Sets the Id
  45.      *
  46.      * @param nId
  47.      *            The Id
  48.      */
  49.     public void setId( int nId )
  50.     {
  51.         this._nId = nId;
  52.     }
  53.    
  54.     /**
  55.      * Returns the name of the security header
  56.      *
  57.      * @return the security header name as a String
  58.      */
  59.     public String getName( )
  60.     {
  61.         return _strName;
  62.     }

  63.     /**
  64.      * Sets the name of the security header
  65.      *
  66.      * @param strName
  67.      *            The security header name
  68.      */
  69.     public void setName( String strName )
  70.     {
  71.         _strName = strName;
  72.     }
  73.    
  74.     /**
  75.      * Returns the value of the security header
  76.      *
  77.      * @return the security header value as a String
  78.      */
  79.     public String getValue( )
  80.     {
  81.         return _strValue;
  82.     }

  83.     /**
  84.      * Sets the value of the security header
  85.      *
  86.      * @param strValue
  87.      *            The security header value
  88.      */
  89.     public void setValue( String strValue )
  90.     {
  91.         _strValue = strValue;
  92.     }
  93.    
  94.     /**
  95.      * Returns the description of the security header
  96.      *
  97.      * @return the security header description as a String
  98.      */
  99.     public String getDescription( )
  100.     {
  101.         return _strDescription;
  102.     }

  103.     /**
  104.      * Sets the description of the security header
  105.      *
  106.      * @param strDescription
  107.      *            The security header description
  108.      */
  109.     public void setDescription( String strDescription )
  110.     {
  111.         this._strDescription = strDescription;
  112.     }
  113.    
  114.     /**
  115.      * Returns the type of the security header
  116.      *
  117.      * @return the security header type as a String
  118.      */
  119.     public String getType( )
  120.     {
  121.         return _strType;
  122.     }

  123.     /**
  124.      * Sets the type of the security header
  125.      *
  126.      * @param strType
  127.      *            The security header type
  128.      */
  129.     public void setType( String strType )
  130.     {
  131.         this._strType = strType;
  132.     }

  133.     /**
  134.      * Returns the page category of the security header
  135.      *
  136.      * @return the security header page category as a String
  137.      */
  138.     public String getPageCategory( )
  139.     {
  140.         return _strPageCategory;
  141.     }

  142.     /**
  143.      * Sets the page category of the security header
  144.      *
  145.      * @param strPageCategory
  146.      *            The security header page category
  147.      */
  148.     public void setPageCategory( String strPageCategory )
  149.     {
  150.         this._strPageCategory = strPageCategory;
  151.     }
  152.    
  153.     /**
  154.      * Indicates if the security is active or not
  155.      *
  156.      * @return true if the security header is active, false otherwise
  157.      */
  158.     public boolean isActive( )
  159.     {
  160.         return _bIsActive;
  161.     }

  162.     /**
  163.      * Activate or deactivate the security header
  164.      *
  165.      * @param isActive
  166.      *            true if the security header is active, false otherwise
  167.      */
  168.     public void setActive( boolean isActive )
  169.     {
  170.         this._bIsActive = isActive;
  171.     }
  172. }