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/12/06 14:59:35 UTC
svn commit: r601737 - in /lenya/branches/branch_1_2_x_shibboleth/src:
java/org/apache/lenya/ac/ java/org/apache/lenya/ac/impl/
java/org/apache/lenya/cms/cocoon/acting/ webapp/
Author: andreas
Date: Thu Dec 6 05:59:34 2007
New Revision: 601737
URL: http://svn.apache.org/viewvc?rev=601737&view=rev
Log:
Introduce target URI to allow redirecting to a protected resource after the authentication. This is necessary because the Shibboleth authentication URL has to be the same for all resources.
Modified:
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/Authenticator.java
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java
lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthenticatorAction.java
lenya/branches/branch_1_2_x_shibboleth/src/webapp/sitemap.xmap
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/Authenticator.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/Authenticator.java?rev=601737&r1=601736&r2=601737&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/Authenticator.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/Authenticator.java Thu Dec 6 05:59:34 2007
@@ -50,4 +50,11 @@
* @return A string.
*/
String getLoginUri(Request request);
+
+ /**
+ * The target URI, i.e. the URI to redirect to after a successful authentication.
+ * @param request The request containing the authentication data.
+ * @return A string.
+ */
+ String getTargetUri(Request request);
}
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java?rev=601737&r1=601736&r2=601737&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/impl/UserAuthenticator.java Thu Dec 6 05:59:34 2007
@@ -132,4 +132,8 @@
this.manager = manager;
}
+ public String getTargetUri(Request request) {
+ return request.getRequestURI();
+ }
+
}
Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthenticatorAction.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthenticatorAction.java?rev=601737&r1=601736&r2=601737&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthenticatorAction.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/cms/cocoon/acting/DelegatingAuthenticatorAction.java Thu Dec 6 05:59:34 2007
@@ -31,43 +31,53 @@
import org.apache.cocoon.environment.SourceResolver;
import org.apache.lenya.ac.ErrorHandler;
import org.apache.lenya.ac.SimpleErrorHandler;
+import org.apache.lenya.ac.impl.DefaultAccessController;
/**
- * Authenticator action that delegates the authentication to an access controller.
+ * Authenticator action that delegates the authentication to an access
+ * controller.
*/
public class DelegatingAuthenticatorAction extends AccessControlAction {
-
+
/**
* Session attribute name for authentication errors.
*/
public static final String ERRORS = DelegatingAuthenticatorAction.class.getName() + ".Errors";
/**
- * @see org.apache.lenya.cms.cocoon.acting.AccessControlAction#doAct(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ * @see org.apache.lenya.ac.Authenticator#getTargetUri(Request);
*/
- protected Map doAct(
- Redirector redirector,
- SourceResolver resolver,
- Map objectModel,
- String source,
- Parameters parameters)
- throws Exception {
+ public static final String TARGET_URI = "targetUri";
- getLogger().debug("Authenticating request");
+ /**
+ * @see org.apache.lenya.cms.cocoon.acting.AccessControlAction#doAct(org.apache.cocoon.environment.Redirector,
+ * org.apache.cocoon.environment.SourceResolver, java.util.Map,
+ * java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+ */
+ protected Map doAct(Redirector redirector, SourceResolver resolver, Map objectModel,
+ String source, Parameters parameters) throws Exception {
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Authenticating request");
+ }
Request request = ObjectModelHelper.getRequest(objectModel);
Map result = null;
ErrorHandler handler = new SimpleErrorHandler();
if (getAccessController().authenticate(request, handler)) {
- getLogger().debug("Authentication successful.");
- result = Collections.EMPTY_MAP;
- }
- else {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Authentication successful.");
+ }
+ String targetUri = ((DefaultAccessController) getAccessController()).getAuthenticator()
+ .getTargetUri(request);
+ result = Collections.singletonMap(TARGET_URI, targetUri);
+ } else {
Session session = request.getSession(true);
session.setAttribute(ERRORS, handler.getErrors());
- getLogger().debug("Authentication failed.");
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Authentication failed.");
+ }
}
return result;
}
-
}
Modified: lenya/branches/branch_1_2_x_shibboleth/src/webapp/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/webapp/sitemap.xmap?rev=601737&r1=601736&r2=601737&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/webapp/sitemap.xmap (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/webapp/sitemap.xmap Thu Dec 6 05:59:34 2007
@@ -492,7 +492,7 @@
<map:match type="step" pattern="login">
<map:act type="authenticator">
- <map:redirect-to uri="{request:requestURI}" session="true"/>
+ <map:redirect-to uri="{targetUri}" session="true"/>
</map:act>
<map:redirect-to uri="{request:requestURI}?lenya.usecase=login&lenya.step=showscreen&status=failed" session="true"/>
</map:match>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org