View Javadoc
1   /*
2    * Copyright (c) 2002-2025, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.business.securityheader;
35  
36  import javax.validation.constraints.NotEmpty;
37  import javax.validation.constraints.Size;
38  
39  /**
40   * 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 
41   * 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)
42   * the header must be applied. The different categories are all pages, Back Office admin authenticated pages, Back Office logout page, Front 
43   * Office admin authenticated pages and Front Office logout page 
44   */
45  public class SecurityHeader 
46  {
47  	// Variables declarations
48  	private int _nId;
49  	
50  	@NotEmpty( message = "portal.securityheader.validation.securityheader.Name.notEmpty" )
51  	@Size( max = 60 , message = "portal.securityheader.validation.securityheader.Name.size" )
52  	private String _strName;
53  	
54  	@NotEmpty( message = "portal.securityheader.validation.securityheader.Value.notEmpty" )
55  	@Size( max = 1024 , message = "portal.securityheader.validation.securityheader.Value.size" )
56  	private String _strValue;
57  	
58  	@Size( max = 1024 , message = "portal.securityheader.validation.securityheader.Description.size" )
59  	private String _strDescription;
60  	
61  	@NotEmpty( message = "portal.securityheader.validation.securityheader.Type.notEmpty" )
62  	@Size( max = 10 , message = "portal.securityheader.validation.securityheader.Type.size" )
63  	private String _strType;
64  	
65  	@Size( max = 25 , message = "portal.securityheader.validation.securityheader.PageCategory.size" )
66  	private String _strPageCategory;	
67  	
68  	private boolean _bIsActive;
69  
70  	/**
71       * Returns the Id
72       *
73       * @return The Id
74       */
75  	public int getId( ) 
76  	{
77  		return _nId;
78  	}
79  
80  	/**
81       * Sets the Id
82       *
83       * @param nId
84       *            The Id
85       */
86  	public void setId( int nId ) 
87  	{
88  		this._nId = nId;
89  	}
90  	
91  	/**
92       * Returns the name of the security header
93       *
94       * @return the security header name as a String
95       */
96      public String getName( )
97      {
98          return _strName;
99      }
100 
101     /**
102      * Sets the name of the security header
103      *
104      * @param strName
105      *            The security header name
106      */
107     public void setName( String strName )
108     {
109         _strName = strName;
110     }
111     
112     /**
113      * Returns the value of the security header
114      *
115      * @return the security header value as a String
116      */
117     public String getValue( )
118     {
119         return _strValue;
120     }
121 
122     /**
123      * Sets the value of the security header
124      *
125      * @param strValue
126      *            The security header value
127      */
128     public void setValue( String strValue )
129     {
130         _strValue = strValue;
131     }
132     
133     /**
134      * Returns the description of the security header
135      *
136      * @return the security header description as a String
137      */
138     public String getDescription( ) 
139     {
140 		return _strDescription;
141 	}
142 
143     /**
144      * Sets the description of the security header
145      *
146      * @param strDescription
147      *            The security header description
148      */
149 	public void setDescription( String strDescription ) 
150 	{
151 		this._strDescription = strDescription;
152 	}
153     
154 	/**
155      * Returns the type of the security header
156      *
157      * @return the security header type as a String
158      */
159     public String getType( ) 
160     {
161 		return _strType;
162 	}
163 
164     /**
165      * Sets the type of the security header
166      *
167      * @param strType
168      *            The security header type
169      */
170 	public void setType( String strType ) 
171 	{
172 		this._strType = strType;
173 	}
174 
175 	/**
176      * Returns the page category of the security header
177      *
178      * @return the security header page category as a String
179      */
180 	public String getPageCategory( ) 
181 	{
182 		return _strPageCategory;
183 	}
184 
185 	/**
186      * Sets the page category of the security header
187      *
188      * @param strPageCategory
189      *            The security header page category
190      */
191 	public void setPageCategory( String strPageCategory ) 
192 	{
193 		this._strPageCategory = strPageCategory;
194 	}
195 	
196 	/**
197      * Indicates if the security is active or not
198      *
199      * @return true if the security header is active, false otherwise
200      */
201 	public boolean isActive( )
202 	{
203 		return _bIsActive;
204 	}
205 
206 	/**
207      * Activate or deactivate the security header
208      *
209      * @param isActive
210      *            true if the security header is active, false otherwise
211      */
212 	public void setActive( boolean isActive )
213 	{
214 		this._bIsActive = isActive;
215 	}
216 }