001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.csp; 018 019import org.apache.wicket.request.cycle.RequestCycle; 020 021/** 022 * {@code CSPRenderable} describes a directive that is part of a Content-Security-Policy (CSP in 023 * short). Most directives are predefined in enums. 024 * 025 * @author papegaaij 026 * @see CSPDirectiveSrcValue 027 * @see CSPDirectiveSandboxValue 028 * @see FixedCSPValue 029 */ 030public interface CSPRenderable 031{ 032 /** 033 * Renders the value that should be put in the CSP header. 034 * 035 * @param settings 036 * The {@link ContentSecurityPolicySettings} that renders this value. 037 * @param cycle 038 * The current {@link RequestCycle}. 039 * @return The rendered value. 040 */ 041 String render(ContentSecurityPolicySettings settings, RequestCycle cycle); 042 043 /** 044 * Checks if the {@code CSPRenderable} represents a valid value for a {@code -src} directive. By 045 * default no checks are performed. 046 * 047 * @throws IllegalStateException 048 * when this {@code CSPRenderable} represents an invalid value. 049 */ 050 default void checkValidityForSrc() 051 { 052 } 053}