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 2008/04/01 14:41:00 UTC
svn commit: r643378 - in
/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache:
lenya/ac/shibboleth/ shibboleth/ shibboleth/impl/
Author: andreas
Date: Tue Apr 1 05:40:30 2008
New Revision: 643378
URL: http://svn.apache.org/viewvc?rev=643378&view=rev
Log:
Change ShibbolethUtil.getBaseUrl() to getHostUrl(), treat proxy-based and non-proxy URLs the same way.
Modified:
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java
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/shibboleth/ShibbolethModule.java
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java?rev=643378&r1=643377&r2=643378&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java Tue Apr 1 05:40:30 2008
@@ -129,7 +129,7 @@
.lookup(AttributeRequestService.ROLE);
ShibbolethUtil util = new ShibbolethUtil(this.manager);
- String host = util.getBaseUrl();
+ String host = util.getHostUrl();
BrowserProfileResponse bpResponse = consumerService.processRequest(req, host);
Map attributesMap = attrReqService.requestAttributes(bpResponse);
logAttributesMap(attributesMap);
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=643378&r1=643377&r2=643378&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 Tue Apr 1 05:40:30 2008
@@ -57,7 +57,7 @@
throws ConfigurationException {
ShibbolethUtil util = new ShibbolethUtil(this.manager);
- String host = util.getBaseUrl();
+ String host = util.getHostUrl();
// attributes to get from the org.apache.shibboleth.ShibbolethModule
String[] shibModuleAttrs = { ATTR_WAYF_SERVER, ATTR_PROVIDER_ID, ATTR_SHIRE };
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=643378&r1=643377&r2=643378&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 Tue Apr 1 05:40:30 2008
@@ -17,6 +17,9 @@
*/
package org.apache.lenya.ac.shibboleth;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.cocoon.environment.Context;
@@ -49,20 +52,20 @@
/**
* <p>
- * This method computes the base URL of the web application:
+ * This method computes the host URL of the web application (<code>{protocol}://{host}[:{port}]</code>).
+ * The port suffix is omitted for the ports 80 and 443.
* </p>
* <ul>
* <li>
- * If a proxy is declared for the current area, the URL of the proxy is returned.
+ * If a proxy is declared for the current area, the host URL of the proxy is returned.
* </li>
* <li>
- * If no proxy is declared, <code>{protocol}://{host}[:{port}]</code> is returned. The port suffix is omitted
- * for the ports 80 and 443.
+ * If no proxy is declared, the host URL of the current request is returned.
* </li>
* </ul>
* @return A string.
*/
- public String getBaseUrl() {
+ public String getHostUrl() {
String baseUrl = null;
ContextUtility contextUtil = null;
@@ -85,7 +88,10 @@
Proxy proxy = pub.getProxy(area, isSslProtected(webappUrl));
if (proxy != null) {
- baseUrl = proxy.getUrl();
+ String proxyUrl = proxy.getUrl();
+ if (containsAuthority(proxyUrl)) {
+ baseUrl = getHostUrl(proxyUrl);
+ }
}
}
@@ -106,6 +112,34 @@
return baseUrl;
}
+
+ public String getHostUrl(String url) {
+ StringBuffer hostUrl = new StringBuffer();
+ if (!containsAuthority(url)) {
+ throw new IllegalArgumentException("The URL [" + url + "] doesn't contain the authority.");
+ }
+ URL urlObj = toUrl(url);
+ hostUrl.append(urlObj.getProtocol());
+ hostUrl.append("://");
+ hostUrl.append(urlObj.getAuthority());
+ return hostUrl.toString();
+ }
+
+ protected URL toUrl(String urlString) {
+ URL url;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ return url;
+ }
+
+ protected boolean containsAuthority(String url) {
+ return url.startsWith("http://") || url.startsWith("https://");
+ }
+
+
/**
* @param port The port.
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java?rev=643378&r1=643377&r2=643378&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java Tue Apr 1 05:40:30 2008
@@ -97,12 +97,10 @@
String getWayfServerUrl();
/**
- * @param baseUrl The URL to append the shire URL to. If the shire URL
- * starts with a slash, only the authority part
- * (protocol://host[:port]) is used.
+ * @param hostUrl The host URL to append the shire URL to.
* @return The shire URL.
*/
- String getShireUrl(String baseUrl);
+ String getShireUrl(String hostUrl);
/**
* @param targetUrl the target URL the user is send to after authentication.
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java?rev=643378&r1=643377&r2=643378&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java Tue Apr 1 05:40:30 2008
@@ -364,36 +364,8 @@
return this.wayfServerUrl;
}
- public String getShireUrl(String baseUrl) {
- StringBuffer shireUrl = new StringBuffer();
- if (this.shire.startsWith("/") && containsAuthority(baseUrl)) {
- URL url = toUrl(baseUrl);
- shireUrl.append(url.getProtocol());
- shireUrl.append("://");
- shireUrl.append(url.getAuthority());
- }
- else {
- shireUrl.append(baseUrl);
- if (!baseUrl.endsWith("/")) {
- shireUrl.append("/");
- }
- }
- shireUrl.append(this.shire);
- return shireUrl.toString();
- }
-
- protected URL toUrl(String urlString) {
- URL url;
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- return url;
- }
-
- protected boolean containsAuthority(String url) {
- return url.startsWith("http://") || url.startsWith("https://");
+ public String getShireUrl(String hostUrl) {
+ return hostUrl + this.shire;
}
public String getTargetBaseUrl(String targetUrl){
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org