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

Redirect INSPIRE schemas from HTTP to HTTPS #1131

Merged
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 @@ -60,6 +60,8 @@ public class RedirectingEntityResolver implements XMLEntityResolver {

private static final String SCHEMAS_OPENGIS_NET_URL = "http://schemas.opengis.net/";

public static final String INSPIRE_SCHEMAS_URL = "http://inspire.ec.europa.eu/schemas";

private static final String ROOT = "/META-INF/SCHEMAS_OPENGIS_NET/";

private static final URL baseURL;
Expand Down Expand Up @@ -88,6 +90,8 @@ public String redirect( String systemId ) {
LOG.debug( "Local hit: " + systemId );
return u.toString();
}
} else if ( systemId.startsWith( INSPIRE_SCHEMAS_URL ) ) {
return systemId.replaceFirst( "http://", "https://" );
} else if ( systemId.equals( "http://www.w3.org/2001/xml.xsd" ) ) {
// workaround for schemas that include the xml base schema...
return RedirectingEntityResolver.class.getResource( "/w3c/xml.xsd" ).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.deegree.commons.xml.schema;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author <a href="mailto:goltz@lat-lon.de">Lyn Goltz </a>
*/
public class RedirectingEntityResolverTest {

private RedirectingEntityResolver redirectingEntityResolver = new RedirectingEntityResolver();

@Test
public void test_redirect_schemasOpengisNet_to_local() {
String systemId = "http://schemas.opengis.net/csw/2.0.2/record.xsd";
String redirected = redirectingEntityResolver.redirect(systemId);

assertThat(redirected, endsWith("/META-INF/SCHEMAS_OPENGIS_NET/csw/2.0.2/record.xsd"));
}

@Test
public void test_redirect_inspire_http_to_https() {
String systemId = "http://inspire.ec.europa.eu/schemas/base/3.3/BaseTypes.xsd";
String redirected = redirectingEntityResolver.redirect(systemId);

assertThat(redirected, is("https://inspire.ec.europa.eu/schemas/base/3.3/BaseTypes.xsd"));
}

}