Author: andreas
Date: Wed May 14 01:45:36 2008
New Revision: 656157
URL: http://svn.apache.org/viewvc?rev=656157&view=rev
Log:
Send all requests to Shibboleth-protected pages to via https.
Modified:
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethModule.java
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethUtil.java
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/publication/util/OutgoingLinkRewriter.java
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethModule.java?rev=656157&r1=656156&r2=656157&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethModule.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethModule.java Wed May 14 01:45:36 2008
@@ -91,7 +91,7 @@
String webappUrl = ServletHelper.getWebappURI(req);
OutgoingLinkRewriter rewriter = new OutgoingLinkRewriter(this.manager, getLogger());
- String outgoingUrl = rewriter.rewrite(webappUrl);
+ String outgoingUrl = rewriter.rewrite(webappUrl, true);
if (outgoingUrl.startsWith("/")) {
int port = req.getServerPort();
String portSuffix = ShibbolethUtil.getPortSuffix(port);
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethUtil.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethUtil.java?rev=656157&r1=656156&r2=656157&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethUtil.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethUtil.java Wed May 14 01:45:36 2008
@@ -86,7 +86,7 @@
Publication pub = PublicationFactory.getPublication(pubId,
servletContextPath);
- Proxy proxy = pub.getProxy(area, isSslProtected(webappUrl));
+ Proxy proxy = pub.getProxy(area, true);
if (proxy != null) {
String proxyUrl = proxy.getUrl();
if (containsAuthority(proxyUrl)) {
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/publication/util/OutgoingLinkRewriter.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/publication/util/OutgoingLinkRewriter.java?rev=656157&r1=656156&r2=656157&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/publication/util/OutgoingLinkRewriter.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/publication/util/OutgoingLinkRewriter.java Wed May 14 01:45:36 2008
@@ -55,11 +55,31 @@
* @return A URL.
*/
public String rewrite(String webappUrl) {
+ return rewrite(webappUrl, true, false);
+ }
+
+ /**
+ * @param webappUrl The web application URL to rewrite.
+ * @param useSsl If the SSL proxy should be used.
+ * @return A URL.
+ */
+ public String rewrite(String webappUrl, boolean useSsl) {
+ return rewrite(webappUrl, false, useSsl);
+ }
+
+
+ /**
+ * @param webappUrl The web application URL to rewrite.
+ * @param checkSsl If the method should check if the request is SSL protected.
+ * @param useSsl If the SSL proxy should be used (ignored if checkSsl is true).
+ * @return A URL.
+ */
+ protected String rewrite(String webappUrl, boolean checkSsl, boolean useSsl) {
URLInformation info = new URLInformation(webappUrl);
String pubId = info.getPublicationId();
String area = info.getArea();
-
+
String proxyUrl = null;
if (pubId != null && area != null) {
@@ -71,10 +91,12 @@
String servletContextPath = context.getRealPath("");
Publication pub = PublicationFactory.getPublication(pubId, servletContextPath);
- Proxy proxy = pub.getProxy(area, isSslProtected(webappUrl));
+ boolean chooseSslProxy = checkSsl ? request.isSecure() : useSsl;
+
+ Proxy proxy = pub.getProxy(area, chooseSslProxy);
if (proxy != null) {
- String prefix = "/" + pubId + "/" + info.getCompleteArea();
- String areaUrl = webappUrl.substring(prefix.length());
+ String prefix = "/" + pubId + "/" + info.getCompleteArea();
+ String areaUrl = webappUrl.substring(prefix.length());
proxyUrl = proxy.getUrl() + areaUrl;
} else {
webappUrl = request.getContextPath() + webappUrl;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.