You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/06/26 18:47:54 UTC
svn commit: r550851 - in
/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms:
cocoon/components/modules/input/ProxyModule.java
cocoon/transformation/ProxyTransformer.java linking/OutgoingLinkRewriter.java
Author: andreas
Date: Tue Jun 26 09:47:54 2007
New Revision: 550851
URL: http://svn.apache.org/viewvc?view=rev&rev=550851
Log:
Consider current request security (SSL or not) when building links. All items on an SSL-encrypted page will be requested using SSL.
Modified:
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java
Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java?view=diff&rev=550851&r1=550850&r2=550851
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java Tue Jun 26 09:47:54 2007
@@ -83,7 +83,7 @@
ConfigurationException {
Session session = RepositoryUtil.getSession(this.manager, request);
LinkRewriter rewriter = new OutgoingLinkRewriter(this.manager, session, request
- .getRequestURI(), false);
+ .getRequestURI(), request.isSecure(), false);
if (!rewriter.matches(url)) {
throw new ConfigurationException("The URL [" + url + "] can't be rewritten!");
}
Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java?view=diff&rev=550851&r1=550850&r2=550851
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/transformation/ProxyTransformer.java Tue Jun 26 09:47:54 2007
@@ -42,16 +42,16 @@
* either configure this when declaring the transformer:
* </p>
* <code><pre>
- * <map:transformer ... >
- * <urls type="relative"/>
- * ...
- * </map:transformer>
+ * <map:transformer ... >
+ * <urls type="relative"/>
+ * ...
+ * </map:transformer>
* </pre></code>
* <p>
* or pass a parameter:
* </p>
* <code><pre>
- * <map:parameter name="urls" value="relative"/>
+ * <map:parameter name="urls" value="relative"/>
* </pre></code>
* @see OutgoingLinkRewriter
*/
@@ -74,8 +74,9 @@
setUrlType(_parameters.getParameter(PARAMETER_URLS));
}
Session session = RepositoryUtil.getSession(this.manager, _request);
+ boolean ssl = request.getScheme().equals("https");
this.rewriter = new OutgoingLinkRewriter(this.manager, session, _request
- .getRequestURI(), this.relativeUrls);
+ .getRequestURI(), ssl, this.relativeUrls);
} catch (final Exception e) {
throw new RuntimeException(e);
}
Modified: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java?view=diff&rev=550851&r1=550850&r2=550851
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/linking/OutgoingLinkRewriter.java Tue Jun 26 09:47:54 2007
@@ -39,7 +39,8 @@
/**
* <p>
* Converts web application links to links which will be sent to the browser by
- * using the publication's proxy settings.
+ * using the publication's proxy settings. If the current request is SSL-encrypted,
+ * all link URLs will use the SSL proxy.
* </p>
* <p>
* Objects of this class are not thread-safe.
@@ -54,19 +55,22 @@
private AccreditableManager accreditableManager;
private DocumentFactory factory;
private Publication publication;
+ private boolean ssl;
/**
* @param manager The service manager to use.
* @param session The current session.
* @param requestUrl The request URL where the links should be rewritten.
+ * @param ssl If the current page is SSL-encrypted.
* @param relativeUrls If relative URLs should be created.
*/
public OutgoingLinkRewriter(ServiceManager manager, Session session, String requestUrl,
- boolean relativeUrls) {
-
+ boolean ssl, boolean relativeUrls) {
+
super(manager);
this.requestUrl = requestUrl;
this.relativeUrls = relativeUrls;
+ this.ssl = ssl;
ServiceSelector serviceSelector = null;
AccessControllerResolver acResolver = null;
@@ -78,7 +82,7 @@
if (pubId != null && isPublication(pubId)) {
this.publication = this.factory.getPublication(pubId);
}
-
+
serviceSelector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ "Selector");
acResolver = (AccessControllerResolver) serviceSelector
@@ -112,10 +116,10 @@
if (this.relativeUrls) {
rewrittenUrl = getRelativeUrlTo(url);
} else {
- boolean ssl = false;
- if (this.policyManager != null) {
+ boolean useSsl = this.ssl;
+ if (!useSsl && this.policyManager != null) {
Policy policy = this.policyManager.getPolicy(this.accreditableManager, url);
- ssl = policy.isSSLProtected();
+ useSsl = policy.isSSLProtected();
}
URLInformation info = new URLInformation(url);
@@ -124,13 +128,13 @@
// link points to publication
if (pubId != null && isPublication(pubId)) {
Publication pub = this.factory.getPublication(pubId);
- rewrittenUrl = rewriteLink(url, pub, ssl);
+ rewrittenUrl = rewriteLink(url, pub, useSsl);
}
// link doesn't point to publication -> use own publication if
// exists
else if (this.publication != null) {
- rewrittenUrl = rewriteLink(url, this.publication, ssl);
+ rewrittenUrl = rewriteLink(url, this.publication, useSsl);
}
// link doesn't point to publication, no own publication
@@ -145,7 +149,7 @@
}
private String requestUrl;
-
+
/**
* @param linkUrl The original link URL.
* @param pub The publication to use for proxy resolving.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org