Author: andreas
Date: Fri Feb 6 18:32:12 2009
New Revision: 741666
URL: http://svn.apache.org/viewvc?rev=741666&view=rev
Log:
Continue springification.
Added:
lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/
lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-components.xml
lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-inputModules.xml
Modified:
lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/BypassableAccessController.java
lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ComposableAccessControllerResolver.java
lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ConfigurableAccessControllerResolver.java
lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/SslRedirectAction.java
lenya/trunk/org.apache.lenya.welcome/src/main/resources/COB-INF/sitemap.xmap
Modified: lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/BypassableAccessController.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/BypassableAccessController.java?rev=741666&r1=741665&r2=741666&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/BypassableAccessController.java (original)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/BypassableAccessController.java Fri Feb 6 18:32:12 2009
@@ -23,8 +23,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.sitemap.PatternException;
import org.apache.lenya.ac.AccessControlException;
@@ -47,44 +45,20 @@
private List publicMatchers = new ArrayList();
private List publicExtensions = new ArrayList();
-
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration conf) throws ConfigurationException {
- super.configure(conf);
-
- getLogger().debug("Configuring bypass patterns");
-
- Configuration[] publics = conf.getChildren("public");
-
- for (int i = 0; i < publics.length; i++) {
- String publicHref = publics[i].getValue(null);
-
- try {
- this.publicMatchers.add(preparePattern(publicHref));
- } catch (PatternException pe) {
- throw new ConfigurationException("invalid pattern for public hrefs", pe);
- }
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("CONFIGURATION: public: " + publicHref);
+
+ public void setPublicExtensions(String extensions) {
+ String[] extensionArray = extensions.split(",");
+ for (int e = 0; e < extensionArray.length; e++) {
+ String ext = extensionArray[e].trim();
+ if (!ext.startsWith(".")) {
+ ext = "." + ext;
}
+ this.publicExtensions.add(ext);
}
-
- Configuration[] extensionConfigs = conf.getChildren("public-extensions");
- for (int i = 0; i < extensionConfigs.length; i++) {
- String extensionString = extensionConfigs[i].getValue();
- String[] extensions = extensionString.split(",");
- for (int e = 0; e < extensions.length; e++) {
- String ext = extensions[e].trim();
- if (!ext.startsWith(".")) {
- ext = "." + ext;
- }
- this.publicExtensions.add(ext);
- }
- }
-
+ }
+
+ public void setPublicPatterns(String patterns) throws PatternException {
+ this.publicMatchers.add(preparePattern(patterns));
}
/**
Modified: lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ComposableAccessControllerResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ComposableAccessControllerResolver.java?rev=741666&r1=741665&r2=741666&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ComposableAccessControllerResolver.java (original)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ComposableAccessControllerResolver.java Fri Feb 6 18:32:12 2009
@@ -18,12 +18,12 @@
package org.apache.lenya.ac.impl;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccessController;
import org.apache.lenya.ac.AccessControllerResolver;
@@ -43,18 +43,12 @@
AccessController controller = null;
- String[] types = getResolverTypes();
- int i = 0;
- while (controller == null && i < types.length) {
-
- getLogger().debug("Trying to resolve AC resolver for type [" + types[i] + "]");
- AccessControllerResolver resolver = (AccessControllerResolver) WebAppContextUtils
- .getCurrentWebApplicationContext().getBean(
- AccessControllerResolver.ROLE + "/" + types[i]);
+ Iterator i = this.resolvers.iterator();
+ while (controller == null && i.hasNext()) {
+ AccessControllerResolver resolver = (AccessControllerResolver) i.next();
controller = resolver.resolveAccessController(url);
setResolver(controller, resolver);
getLogger().debug("Resolved access controller [" + controller + "]");
- i++;
}
return controller;
@@ -94,25 +88,10 @@
protected static final String RESOLVER_ELEMENT = "resolver";
protected static final String TYPE_ATTRIBUTE = "type";
- private String[] resolverTypes;
-
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration configuration) throws ConfigurationException {
- Configuration[] accessControllerConfigs = configuration.getChildren(RESOLVER_ELEMENT);
- this.resolverTypes = new String[accessControllerConfigs.length];
- for (int i = 0; i < accessControllerConfigs.length; i++) {
- this.resolverTypes[i] = accessControllerConfigs[i].getAttribute(TYPE_ATTRIBUTE);
- }
- }
-
- /**
- * Returns the access controller types.
- * @return A string array.
- */
- protected String[] getResolverTypes() {
- return this.resolverTypes;
+ private List resolvers = new ArrayList();
+
+ public void setResolvers(List resolvers) {
+ this.resolvers = resolvers;
}
}
Modified: lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ConfigurableAccessControllerResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ConfigurableAccessControllerResolver.java?rev=741666&r1=741665&r2=741666&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ConfigurableAccessControllerResolver.java (original)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/ac/impl/ConfigurableAccessControllerResolver.java Fri Feb 6 18:32:12 2009
@@ -20,7 +20,6 @@
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccessController;
@@ -29,8 +28,7 @@
* Configurable access controller resolver.
* @version $Id$
*/
-public class ConfigurableAccessControllerResolver extends AbstractAccessControllerResolver
- implements Configurable {
+public class ConfigurableAccessControllerResolver extends AbstractAccessControllerResolver {
/**
* @see org.apache.lenya.ac.impl.AbstractAccessControllerResolver#doResolveAccessController(java.lang.String)
@@ -61,12 +59,12 @@
private Configuration accessControllerConfiguration;
- /**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(Configuration configuration) throws ConfigurationException {
- this.accessControllerConfiguration = configuration.getChild(ACCESS_CONTROLLER_ELEMENT);
- this.accessControllerType = this.accessControllerConfiguration.getAttribute(TYPE_ATTRIBUTE);
+ public void setAccessControllerType(String accessControllerType) {
+ this.accessControllerType = accessControllerType;
+ }
+
+ public void setAccessControllerConfiguration(Configuration accessControllerConfiguration) {
+ this.accessControllerConfiguration = accessControllerConfiguration;
}
}
Modified: lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/SslRedirectAction.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/SslRedirectAction.java?rev=741666&r1=741665&r2=741666&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/SslRedirectAction.java (original)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/java/org/apache/lenya/cms/cocoon/acting/SslRedirectAction.java Fri Feb 6 18:32:12 2009
@@ -21,12 +21,12 @@
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.cocoon.acting.ConfigurableServiceableAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.lenya.ac.AccessController;
import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.Policy;
@@ -39,10 +39,10 @@
import org.apache.lenya.util.ServletHelper;
/**
- * Returns a map if the current request needs a redirect to the <code>https://</code> protocol.
- * This is the case if the policy requires SSL protection and the current request is not secure. The
- * map contains the redirect URI as value for the key <em>redirectUri</em>. Otherwise,
- * <code>null</code> is returned.
+ * Returns a map if the current request needs a redirect to the <code>https://</code> protocol. This
+ * is the case if the policy requires SSL protection and the current request is not secure. The map
+ * contains the redirect URI as value for the key <em>redirectUri</em>. Otherwise, <code>null</code>
+ * is returned.
*/
public class SslRedirectAction extends ConfigurableServiceableAction {
@@ -50,53 +50,40 @@
* The key to obtain the redirect URI from the returned map.
*/
public static final String KEY_REDIRECT_URI = "redirectUri";
-
+
private RepositoryManager repositoryManager;
public Map act(Redirector redirector, SourceResolver sourceResolver, Map objectModel,
String source, Parameters parameters) throws Exception {
- ServiceSelector selector = null;
AccessControllerResolver resolver = null;
AccessController accessController = null;
Request request = ObjectModelHelper.getRequest(objectModel);
-
+
if (!request.isSecure()) {
- try {
- selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
- + "Selector");
-
- resolver = (AccessControllerResolver) selector
- .select(AccessControllerResolver.DEFAULT_RESOLVER);
-
- String url = ServletHelper.getWebappURI(request);
- accessController = resolver.resolveAccessController(url);
-
- if (accessController != null) {
- PolicyManager policyManager = accessController.getPolicyManager();
- Policy policy = policyManager.getPolicy(accessController.getAccreditableManager(),
- url);
- if (policy.isSSLProtected()) {
- Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
- LinkRewriter rewriter = new OutgoingLinkRewriter(session, url,
- false, true, false);
- String sslUri = rewriter.rewrite(url);
- return Collections.singletonMap(KEY_REDIRECT_URI, sslUri);
- }
- }
-
- } finally {
- if (selector != null) {
- if (resolver != null) {
- if (accessController != null) {
- resolver.release(accessController);
- }
- selector.release(resolver);
- }
- this.manager.release(selector);
+
+ resolver = (AccessControllerResolver) WebAppContextUtils
+ .getCurrentWebApplicationContext().getBean(
+ AccessControllerResolver.ROLE + "/"
+ + AccessControllerResolver.DEFAULT_RESOLVER);
+
+ String url = ServletHelper.getWebappURI(request);
+ accessController = resolver.resolveAccessController(url);
+
+ if (accessController != null) {
+ PolicyManager policyManager = accessController.getPolicyManager();
+ Policy policy = policyManager.getPolicy(accessController.getAccreditableManager(),
+ url);
+ if (policy.isSSLProtected()) {
+ Session session = RepositoryUtil.getSession(getRepositoryManager(), request);
+ LinkRewriter rewriter = new OutgoingLinkRewriter(session, url, false, true,
+ false);
+ String sslUri = rewriter.rewrite(url);
+ return Collections.singletonMap(KEY_REDIRECT_URI, sslUri);
}
}
+
}
return null;
}
Added: lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-components.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-components.xml?rev=741666&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-components.xml (added)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-components.xml Fri Feb 6 18:32:12 2009
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <!-- Resolvers -->
+ <bean name="org.apache.lenya.cms.ac.AccessControllerResolver/publication"
+ class="org.apache.lenya.cms.ac.PublicationAccessControllerResolver"/>
+ <bean name="org.apache.lenya.cms.ac.AccessControllerResolver/global"
+ class="org.apache.lenya.ac.impl.ConfigurableAccessControllerResolver">
+ <property name="accessControllerType" value="global"/>
+ </bean>
+ <bean name="org.apache.lenya.cms.ac.AccessControllerResolver/composable"
+ class="org.apache.lenya.ac.impl.ComposableAccessControllerResolver">
+ <property name="resolvers">
+ <list>
+ <ref bean="org.apache.lenya.cms.ac.AccessControllerResolver/publication"/>
+ </list>
+ </property>
+ </bean>
+
+ <!-- Authenticators -->
+ <bean name="org.apache.lenya.ac.Authenticator"
+ class="org.apache.lenya.ac.impl.UserAuthenticator"/>
+
+ <!--
+ Enable this authenticator and disable the UserAuthenticator for anonymous authentication (useful for client certs, for instance)
+ <bean name="org.apache.lenya.ac.Authenticator"
+ class="org.apache.lenya.ac.impl.AnonymousAuthenticator"/>
+ -->
+
+ <!-- Access Controllers -->
+ <bean name="org.apache.lenya.ac.AccessController/bypassable"
+ class="org.apache.lenya.ac.impl.BypassableAccessController">
+ <property name="publicExtensions" value="css,jpg,gif,png,rng,xsl"/>
+ <!-- bad performance, use only for complex patterns
+ <public>.*[.]css|.*[.]jpg|.*[.]gif|.*[.]png|.*[.]rng|.*[.]xsl</public>
+ -->
+ </bean>
+
+ <!-- Policy Managers -->
+ <bean name="org.apache.lenya.ac.PolicyManager/document"
+ class="org.apache.lenya.cms.ac.DocumentPolicyManagerWrapper"/>
+ <bean name="org.apache.lenya.ac.PolicyManager/file"
+ class="org.apache.lenya.ac.file.FilePolicyManager"/>
+ <bean name="org.apache.lenya.ac.PolicyManager/sitemap"
+ class="org.apache.lenya.cms.ac.SitemapPolicyManager"/>
+
+ <!-- Accreditable Managers -->
+ <bean name="org.apache.lenya.ac.AccreditableManagerFactory"
+ class="org.apache.lenya.ac.file.FileAccreditableManagerFactory"/>
+
+</beans>
Added: lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-inputModules.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-inputModules.xml?rev=741666&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-inputModules.xml (added)
+++ lenya/trunk/org.apache.lenya.core.ac/src/main/resources/META-INF/cocoon/spring/lenya-core-ac-inputModules.xml Fri Feb 6 18:32:12 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ <bean name="org.apache.cocoon.components.modules.input.InputModule/access-control"
+ class="org.apache.lenya.cms.cocoon.components.modules.input.AccessControlModule"/>
+</beans>
Modified: lenya/trunk/org.apache.lenya.welcome/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.welcome/src/main/resources/COB-INF/sitemap.xmap?rev=741666&r1=741665&r2=741666&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.welcome/src/main/resources/COB-INF/sitemap.xmap (original)
+++ lenya/trunk/org.apache.lenya.welcome/src/main/resources/COB-INF/sitemap.xmap Fri Feb 6 18:32:12 2009
@@ -108,9 +108,11 @@
</map:pipeline>
<!-- this is the default error handler -->
+ <!--
<map:handle-errors>
<map:mount src="{fallback:error.xmap}" check-reload="true" reload-method="synchron" uri-prefix=""/>
- </map:handle-errors>
+ </map:handle-errors>
+ -->
</map:pipelines>
</map:sitemap>
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.