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/09/27 12:36:58 UTC
svn commit: r579969 - in
/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache:
lenya/ac/shibboleth/ShibbolethModule.java
shibboleth/impl/AssertionConsumerServiceImpl.java
Author: andreas
Date: Thu Sep 27 03:36:50 2007
New Revision: 579969
URL: http://svn.apache.org/viewvc?rev=579969&view=rev
Log:
Code cleanup, made methods more generic
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/shibboleth/impl/AssertionConsumerServiceImpl.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=579969&r1=579968&r2=579969&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 Thu Sep 27 03:36:50 2007
@@ -7,19 +7,10 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
-import org.apache.lenya.ac.AccessControllerResolver;
-import org.apache.lenya.ac.Policy;
-import org.apache.lenya.ac.PolicyManager;
-import org.apache.lenya.ac.impl.DefaultAccessController;
import org.apache.lenya.cms.cocoon.components.modules.input.AbstractPageEnvelopeModule;
-import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.PageEnvelope;
-import org.apache.lenya.cms.publication.Proxy;
-import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.util.OutgoingLinkRewriter;
import org.apache.lenya.util.ServletHelper;
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/AssertionConsumerServiceImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/AssertionConsumerServiceImpl.java?rev=579969&r1=579968&r2=579969&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/AssertionConsumerServiceImpl.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/AssertionConsumerServiceImpl.java Thu Sep 27 03:36:50 2007
@@ -27,12 +27,15 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.environment.http.HttpEnvironment;
-import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.shibboleth.AssertionConsumerService;
import org.apache.shibboleth.ShibbolethManager;
import org.apache.shibboleth.ShibbolethModule;
@@ -51,7 +54,9 @@
* Assertion consumer service.
*/
public class AssertionConsumerServiceImpl extends AbstractLogEnabled implements
- AssertionConsumerService, Serviceable {
+ AssertionConsumerService, Serviceable, Contextualizable {
+
+ protected static final String CHARSET = "UTF-8";
/**
* Authentication Assertion requests identifier.
@@ -64,10 +69,9 @@
private static final String SHIB_ATTR_TIME = "time";
private ShibbolethModule shibbolethModule;
-
private ServiceManager manager;
-
private ShibbolethManager shibManager;
+ private Context context;
protected ShibbolethModule getShibbolethModule() {
if (this.shibbolethModule == null) {
@@ -109,9 +113,8 @@
*/
protected String getCompleteUrl(HttpServletRequest req) {
String queryString = req.getQueryString();
- String url = req.getRequestURL().toString()
- + (queryString.length() == 0 ? "" : "?" + queryString);
- return url;
+ String reqUrl = req.getRequestURL().toString();
+ return reqUrl + (queryString.length() == 0 ? "" : "?" + queryString);
}
private BrowserProfileRequest getBrowserProfileRequest(HttpServletRequest req) {
@@ -225,23 +228,23 @@
}
}
- buffer.append(SHIB_ATTR_TARGET).append("=olat");
+ buffer.append(SHIB_ATTR_TARGET).append("=").append(
+ URLEncoder.encode(getTarget(), CHARSET));
// shire
buffer.append("&" + SHIB_ATTR_SHIRE + "=");
- buffer.append(URLEncoder.encode(getShireUrl(), "UTF-8"));
+ buffer.append(URLEncoder.encode(getShireUrl(), CHARSET));
// providerId (if any)
String providerId = getShibbolethModule().getProviderId();
if (providerId != null) {
buffer.append("&" + SHIB_ATTR_PROVIDERID + "=");
- buffer.append(URLEncoder.encode(providerId, "UTF-8"));
+ buffer.append(URLEncoder.encode(providerId, CHARSET));
}
// time
buffer.append("&" + SHIB_ATTR_TIME + "=");
buffer.append(new Long(new Date().getTime() / 1000).toString()); // Unix
- // Time
// send redirect
return buffer.toString();
@@ -263,29 +266,27 @@
* new RedirectMediaResource(getRequestString)); }
*/
+ protected String getTarget() {
+ return getShireUrl();
+ }
+
/**
* Return the URL to the SHIRE (that's us)
* @param shibbolethPath The shibboleth path.
* @return The complete SHIRE URL
*/
- private String getShireUrl() {
- ContextUtility ctxUtil = null;
- try {
- ctxUtil = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
- Map objectModel = ctxUtil.getObjectModel();
- HttpServletRequest req = (HttpServletRequest) objectModel
- .get(HttpEnvironment.HTTP_REQUEST_OBJECT);
- return getCompleteUrl(req);
- } catch (ServiceException e) {
- throw new RuntimeException(e);
- } finally {
- if (ctxUtil != null) {
- this.manager.release(ctxUtil);
- }
- }
+ protected String getShireUrl() {
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ HttpServletRequest req = (HttpServletRequest) objectModel
+ .get(HttpEnvironment.HTTP_REQUEST_OBJECT);
+ return getCompleteUrl(req);
}
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
+ }
+
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org