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 Boolean setNosniffHeader;
49    private List<ThemeImpl> themeDefinitions;
50    private URL url;
51    private String sanitizerClass;
52    private Properties sanitizerProperties;
53    private Map<String, String> mimeTypes;
54  
55    public TobagoConfigFragment() {
56      before = new ArrayList<String>();
57      after = new ArrayList<String>();
58      supportedThemeNames = new ArrayList<String>();
59      themeDefinitions = new ArrayList<ThemeImpl>();
60      mimeTypes = new HashMap<String, String>();
61    }
62  
63    public void addSupportedThemeName(final String name) {
64      supportedThemeNames.add(name);
65    }
66  
67    public List<String> getSupportedThemeNames() {
68      return supportedThemeNames;
69    }
70  
71    public String getDefaultThemeName() {
72      return defaultThemeName;
73    }
74  
75    public void setDefaultThemeName(final String defaultThemeName) {
76      this.defaultThemeName = defaultThemeName;
77    }
78  
79    public RenderersConfig getRenderersConfig() {
80      return renderersConfig;
81    }
82  
83    public void setRenderersConfig(final RenderersConfig renderersConfig) {
84      this.renderersConfig = renderersConfig;
85    }
86  
87    public String getName() {
88      return name;
89    }
90  
91    public void setName(final String name) {
92      this.name = name;
93    }
94  
95    public List<String> getBefore() {
96      return before;
97    }
98  
99    public void addBefore(final String name) {
100     before.add(name);
101   }
102 
103   public List<String> getAfter() {
104     return after;
105   }
106 
107   public void addAfter(final String name) {
108     after.add(name);
109   }
110 
111   public void addThemeDefinition(final ThemeImpl theme) {
112     themeDefinitions.add(theme);
113   }
114 
115   public List<ThemeImpl> getThemeDefinitions() {
116     return themeDefinitions;
117   }
118 
119   public Boolean getCreateSessionSecret() {
120     return createSessionSecret;
121   }
122 
123   public void setCreateSessionSecret(final String createSessionSecret) {
124     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
125   }
126 
127   public Boolean getCheckSessionSecret() {
128     return checkSessionSecret;
129   }
130 
131   public void setCheckSessionSecret(final String checkSessionSecret) {
132     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
133   }
134 
135   public Boolean getPreventFrameAttacks() {
136     return preventFrameAttacks;
137   }
138 
139   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
140     this.preventFrameAttacks = preventFrameAttacks;
141   }
142 
143   public ContentSecurityPolicy getContentSecurityPolicy() {
144     return contentSecurityPolicy;
145   }
146 
147   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
148     this.contentSecurityPolicy = contentSecurityPolicy;
149   }
150 
151   public Boolean getSetNosniffHeader() {
152     return setNosniffHeader;
153   }
154 
155   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
156     this.setNosniffHeader = setNosniffHeader;
157   }
158 
159   public URL getUrl() {
160     return url;
161   }
162 
163   public void setUrl(final URL url) {
164     this.url = url;
165   }
166 
167   public String getSanitizerClass() {
168     return sanitizerClass;
169   }
170 
171   public void setSanitizerClass(String sanitizerClass) {
172     this.sanitizerClass = sanitizerClass;
173   }
174 
175   public Properties getSanitizerProperties() {
176     return sanitizerProperties;
177   }
178 
179   public void setSanitizerProperties(Properties sanitizerProperties) {
180     this.sanitizerProperties = sanitizerProperties;
181   }
182 
183   public void addMimeType(String extension, String type) {
184     this.mimeTypes.put(extension, type);
185   }
186 
187   public Map<String, String> getMimeTypes() {
188     return mimeTypes;
189   }
190 
191   @Override
192   public String toString() {
193     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
194   }
195 }