Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced configuration to hide version reference in header #1442

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.common.SOAP11Factory;
import org.apache.axiom.soap.impl.common.SOAP12Factory;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
Expand Down Expand Up @@ -194,6 +192,8 @@ public class OGCFrontController extends HttpServlet {

private transient String version;

private boolean addDeegreeVersionToHeader = false;

/**
* Returns the only instance of this class.
*
Expand Down Expand Up @@ -295,11 +295,13 @@ public static Collection<ModuleInfo> getModulesInfo() {
return getInstance().modulesInfo;
}

private static void addHeaders( HttpServletResponse response ) {
private void addHeaders( HttpServletResponse response ) {
// add cache control headers
response.addHeader( "Cache-Control", "no-cache, no-store" );
// add deegree header
response.addHeader( "deegree-version", getInstance().version );
if ( addDeegreeVersionToHeader ) {
response.addHeader( "deegree-version", getInstance().version );
}
}

/**
Expand Down Expand Up @@ -1110,6 +1112,9 @@ private void initWorkspace()
serviceConfiguration = workspace.getNewWorkspace().getResourceManager( OwsManager.class );
OwsGlobalConfigLoader loader = workspace.getNewWorkspace().getInitializable( OwsGlobalConfigLoader.class );
mainConfig = loader.getMainConfig();
if ( mainConfig != null && mainConfig.isAddDeegreeVersionToHeader() != null ) {
this.addDeegreeVersionToHeader = mainConfig.isAddDeegreeVersionToHeader();
}
if ( mainConfig != null ) {
initHardcodedUrls( mainConfig );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<xs:element name="ReportedUrls" type="controller:ReportedUrlsType" minOccurs="0" />
<xs:element name="DCP" type="controller:DCPType" minOccurs="0" />
</xs:choice>
<xs:element name="AddDeegreeVersionToHeader" type="xs:boolean" minOccurs="0" default="false" />
<xs:element name="PreventClassloaderLeaks" type="xs:boolean" minOccurs="0" default="true" />
<xs:element name="RequestLogging" minOccurs="0">
<xs:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,8 @@ specifiying them, their order must be respected.
|ReportedUrls |0..1 |Complex |Hardcode reported URLs in service
responses

|AddDeegreeVersionToHeader |0..1 |Boolean |Add header "deegree-version" to each response, default: false

|PreventClassloaderLeaks |0..1 |Boolean |TODO

|RequestLogging |0..1 |Complex |TODO
Expand Down