View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.config;
21  
22  import org.apache.myfaces.tobago.context.ThemeImpl;
23  import org.slf4j.Logger;
24  import org.slf4j.LoggerFactory;
25  
26  import java.net.URL;
27  import java.util.ArrayList;
28  import java.util.HashMap;
29  import java.util.List;
30  import java.util.Map;
31  import java.util.Properties;
32  
33  public class TobagoConfigFragment {
34  
35    private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigFragment.class);
36  
37    private String name;
38    private List<String> before;
39    private List<String> after;
40  
41    private List<String> supportedThemeNames;
42    private String defaultThemeName;
43    private RenderersConfig renderersConfig;
44    private Boolean createSessionSecret;
45    private Boolean checkSessionSecret;
46    private Boolean preventFrameAttacks;
47    private ContentSecurityPolicy contentSecurityPolicy;
48    private SecurityAnnotation securityAnnotation;
49    private Boolean setNosniffHeader;
50    private List<ThemeImpl> themeDefinitions;
51    private URL url;
52    private String sanitizerClass;
53    private Boolean decodeLineFeed;
54    private Properties sanitizerProperties;
55    private Map<String, String> mimeTypes;
56  
57    public TobagoConfigFragment() {
58      before = new ArrayList<String>();
59      after = new ArrayList<String>();
60      supportedThemeNames = new ArrayList<String>();
61      themeDefinitions = new ArrayList<ThemeImpl>();
62      mimeTypes = new HashMap<String, String>();
63    }
64  
65    public void addSupportedThemeName(final String name) {
66      supportedThemeNames.add(name);
67    }
68  
69    public List<String> getSupportedThemeNames() {
70      return supportedThemeNames;
71    }
72  
73    public String getDefaultThemeName() {
74      return defaultThemeName;
75    }
76  
77    public void setDefaultThemeName(final String defaultThemeName) {
78      this.defaultThemeName = defaultThemeName;
79    }
80  
81    public RenderersConfig getRenderersConfig() {
82      return renderersConfig;
83    }
84  
85    public void setRenderersConfig(final RenderersConfig renderersConfig) {
86      this.renderersConfig = renderersConfig;
87    }
88  
89    public String getName() {
90      return name;
91    }
92  
93    public void setName(final String name) {
94      this.name = name;
95    }
96  
97    public List<String> getBefore() {
98      return before;
99    }
100 
101   public void addBefore(final String name) {
102     before.add(name);
103   }
104 
105   public List<String> getAfter() {
106     return after;
107   }
108 
109   public void addAfter(final String name) {
110     after.add(name);
111   }
112 
113   public void addThemeDefinition(final ThemeImpl theme) {
114     themeDefinitions.add(theme);
115   }
116 
117   public List<ThemeImpl> getThemeDefinitions() {
118     return themeDefinitions;
119   }
120 
121   public Boolean getCreateSessionSecret() {
122     return createSessionSecret;
123   }
124 
125   public void setCreateSessionSecret(final String createSessionSecret) {
126     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
127   }
128 
129   public Boolean getCheckSessionSecret() {
130     return checkSessionSecret;
131   }
132 
133   public void setCheckSessionSecret(final String checkSessionSecret) {
134     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
135   }
136 
137   public Boolean getPreventFrameAttacks() {
138     return preventFrameAttacks;
139   }
140 
141   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
142     this.preventFrameAttacks = preventFrameAttacks;
143   }
144 
145   public ContentSecurityPolicy getContentSecurityPolicy() {
146     return contentSecurityPolicy;
147   }
148 
149   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
150     this.contentSecurityPolicy = contentSecurityPolicy;
151   }
152 
153   public SecurityAnnotation getSecurityAnnotation() {
154     return securityAnnotation;
155   }
156 
157   public void setSecurityAnnotation(final SecurityAnnotation securityAnnotation) {
158     this.securityAnnotation = securityAnnotation;
159   }
160 
161   public Boolean getSetNosniffHeader() {
162     return setNosniffHeader;
163   }
164 
165   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
166     this.setNosniffHeader = setNosniffHeader;
167   }
168 
169   public URL getUrl() {
170     return url;
171   }
172 
173   public void setUrl(final URL url) {
174     this.url = url;
175   }
176 
177   public String getSanitizerClass() {
178     return sanitizerClass;
179   }
180 
181   public void setSanitizerClass(String sanitizerClass) {
182     this.sanitizerClass = sanitizerClass;
183   }
184 
185   public Properties getSanitizerProperties() {
186     return sanitizerProperties;
187   }
188 
189   public void setSanitizerProperties(Properties sanitizerProperties) {
190     this.sanitizerProperties = sanitizerProperties;
191   }
192 
193   public Boolean getDecodeLineFeed() {
194     return decodeLineFeed;
195   }
196 
197   public void setDecodeLineFeed(Boolean decodeLineFeed) {
198     this.decodeLineFeed = decodeLineFeed;
199   }
200 
201   public void addMimeType(String extension, String type) {
202     this.mimeTypes.put(extension, type);
203   }
204 
205   public Map<String, String> getMimeTypes() {
206     return mimeTypes;
207   }
208 
209   @Override
210   public String toString() {
211     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
212   }
213 }