Merge pull request #207 from stianst/master

Fixes
This commit is contained in:
Stian Thorgersen 2017-10-02 15:24:20 +02:00 committed by GitHub
commit f28537370e
7 changed files with 25 additions and 13 deletions

View file

@ -13,8 +13,8 @@ WARNING: The only supported version of Fuse is {fuseVersion}. If you use earlier
Security for the following items is supported for Fuse:
* Classic WAR applications deployed on Fuse with https://ops4j1.jira.com/wiki/display/ops4j/Pax+Web+Extender+-+War[Pax Web War Extender]
* Servlets deployed on Fuse as OSGI services with https://ops4j1.jira.com/wiki/display/ops4j/Pax+Web+Extender+-+Whiteboard[Pax Web Whiteboard Extender]
* Classic WAR applications deployed on Fuse with Pax Web War Extender
* Servlets deployed on Fuse as OSGI services with Pax Web Whiteboard Extender
* http://camel.apache.org/[Apache Camel] Jetty endpoints running with the http://camel.apache.org/jetty.html[Camel Jetty] component
* http://cxf.apache.org/[Apache CXF] endpoints running on their own separate http://cxf.apache.org/docs/jetty-configuration.html[Jetty engine]
* http://cxf.apache.org/[Apache CXF] endpoints running on the default engine provided by the CXF servlet

View file

@ -2,7 +2,7 @@
[[_fuse_adapter_servlet_whiteboard]]
===== Securing a Servlet Deployed as an OSGI Service
You can use this method if you have a servlet class inside your OSGI bundled project that is not deployed as a classic WAR application. Fuse uses https://ops4j1.jira.com/wiki/display/ops4j/Pax+Web+Extender+-+Whiteboard[Pax Web Whiteboard Extender] to deploy such servlets as web applications.
You can use this method if you have a servlet class inside your OSGI bundled project that is not deployed as a classic WAR application. Fuse uses Pax Web Whiteboard Extender to deploy such servlets as web applications.
To secure your servlet with {project_name}, complete the following steps:

View file

@ -13,7 +13,7 @@ NOTE: You cannot continue to receive upgrades to EAP 7.0 RPMs but stop receiving
.Prerequisites
. Ensure that your Red Hat Enterprise Linux system is registered to your account using Red Hat Subscription Manager. For more information see the link:https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html-single/Quick_Registration_for_RHEL/index.html[Red Hat Subscription Management documentation].
. Ensure that your Red Hat Enterprise Linux system is registered to your account using Red Hat Subscription Manager. For more information see the link:https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html-single/quick_registration_for_rhel/index[Red Hat Subscription Management documentation].
. If you are already subscribed to another JBoss EAP repository, you must unsubscribe from that repository first.
@ -25,7 +25,7 @@ Using Red Hat Subscription Manager, subscribe to the JBoss EAP 7.0 repository us
.Prerequisites
. Ensure that your Red Hat Enterprise Linux system is registered to your account using Red Hat Subscription Manager. For more information see the link:https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html-single/Quick_Registration_for_RHEL/index.html[Red Hat Subscription Management documentation].
. Ensure that your Red Hat Enterprise Linux system is registered to your account using Red Hat Subscription Manager. For more information see the link:https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html-single/quick_registration_for_rhel/index[Red Hat Subscription Management documentation].
. Ensure that you have already subscribed to the JBoss EAP 7.0 repository. For more information see xref:subscribing_EAP_repo[Subscribing to the JBoss EAP 7.0 repository].
To subscribe to the RH-SSO 7.1 repository and install RH-SSO 7.1, complete the following steps:

View file

@ -23,18 +23,18 @@ public abstract class AbstractDocsTest {
protected File guideDir;
protected static String body;
protected String guideUrl;
@Before
public void before() throws IOException {
guideDir = config.getGuideDir(getGuideDirName());
guideUrl = config.getGuideBaseUrl() + "/" + config.getGuideUrlFragment(getGuideDirName()) + "/";
if (body == null) {
if (config.isLoadFromFiles()) {
File htmlFile = config.getGuideHtmlFile(getGuideDirName());
body = utils.readBody(htmlFile);
} else {
String guideUrl = config.getGuideBaseUrl() + "/" + config.getGuideUrlFragment(getGuideDirName());
log.info("Loading guide from '" + guideUrl);
body = utils.readBody(new URL(guideUrl));
}
@ -69,7 +69,7 @@ public abstract class AbstractDocsTest {
@Test
public void checkImages() {
List<String> failures = linkUtils.findInvalidImages(body, guideDir);
List<String> failures = linkUtils.findInvalidImages(body, guideDir, guideUrl);
checkFailures("Images not found", failures);
}

View file

@ -5,8 +5,8 @@ import java.util.concurrent.TimeUnit;
public class Constants {
public static final int HTTP_RETRY = 3;
public static final int HTTP_CONNECTION_TIMEOUT = 5000;
public static final int HTTP_READ_TIMEOUT = 10000;
public static final int HTTP_CONNECTION_TIMEOUT = 30000;
public static final int HTTP_READ_TIMEOUT = 300000;
public static final long LINK_CHECK_EXPIRATION = TimeUnit.DAYS.toMillis(1);
}

View file

@ -27,10 +27,16 @@ public class DocUtils {
public String readBody(URL url) throws IOException {
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(Constants.HTTP_CONNECTION_TIMEOUT);
connection.setReadTimeout(Constants.HTTP_READ_TIMEOUT);
if (connection.getResponseCode() != 200) {
throw new IOException("Invalid status code returned " + connection.getResponseCode());
}
StringWriter w = new StringWriter();
IOUtils.copy(connection.getInputStream(), w, "utf-8");
String s = w.toString();
@ -43,7 +49,9 @@ public class DocUtils {
}
Matcher m = p.matcher(s);
m.find();
if (!m.find()) {
throw new RuntimeException("Couldn't find body");
}
return m.group(1);
} finally {
@ -53,7 +61,7 @@ public class DocUtils {
public List<String> findMissingVariables(String body, List<String> ignoredVariables) {
List<String> missingVariables = new LinkedList<>();
Pattern p = Pattern.compile("[^$/=\\s]\\{([^ }]*)}");
Pattern p = Pattern.compile("[^$/=\\s]\\{([^ }\"]*)}");
Matcher m = p.matcher(body);
while (m.find()) {
String key = m.group(1);

View file

@ -102,7 +102,7 @@ public class LinkUtils {
return invalidLinks;
}
public List<String> findInvalidImages(String body, File guideDir) {
public List<String> findInvalidImages(String body, File guideDir, String guideUrl) {
List<String> missingImages = new LinkedList<>();
Pattern p = Pattern.compile("<img src=\"([^ \"]*)[^>]*\"");
Matcher m = p.matcher(body);
@ -114,6 +114,10 @@ public class LinkUtils {
missingImages.add(image);
}
} else {
if (image.startsWith("./")) {
image = guideUrl + image;
}
if (!verifiedLinks.containsKey(image)) {
boolean valid = http.isValid(image);
if (valid) {