You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/05/07 22:34:23 UTC
cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager WebDescriptorUtilities.java FileSystemPAM.java
taylor 2004/05/07 13:34:23
Modified: portal/src/java/org/apache/jetspeed/tools/pamanager
FileSystemPAM.java
Added: portal/src/java/org/apache/jetspeed/tools/pamanager
WebDescriptorUtilities.java
Log:
Patch from Ate Douma to support web application security constraints
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.25 +15 -11 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java
Index: FileSystemPAM.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- FileSystemPAM.java 10 Mar 2004 17:17:01 -0000 1.24
+++ FileSystemPAM.java 7 May 2004 20:34:23 -0000 1.25
@@ -366,17 +366,21 @@
{
app.setApplicationType(MutablePortletApplication.WEBAPP);
}
- // // create the web application
- MutableWebApplication webapp = new WebApplicationDefinitionImpl();
- if (paName.startsWith("/"))
- {
- webapp.setContextRoot(paName);
+
+ String contextRoot;
+ String webXMLPath = portletAppDir + "/WEB-INF/web.xml";
+
+ if (paName.startsWith("/")) {
+ contextRoot = paName;
+ } else {
+ contextRoot = "/" + paName;
}
- else
- {
- webapp.setContextRoot("/" + paName);
- }
- webapp.addDisplayName(Jetspeed.getDefaultLocale(), paName);
+
+ // load the web.xml
+ log.info("Loading "+webXMLPath + " into memory....");
+ MutableWebApplication webapp = (MutableWebApplication) WebDescriptorUtilities.loadDescriptor(webXMLPath, contextRoot, Jetspeed
+ .getDefaultLocale(), paName);
+
app.setWebApplicationDefinition(webapp);
try
1.1 jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/WebDescriptorUtilities.java
Index: WebDescriptorUtilities.java
===================================================================
/*
* Copyright 2000-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
package org.apache.jetspeed.tools.pamanager;
import java.io.FileReader;
import java.util.Locale;
import org.apache.commons.digester.Digester;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
import org.apache.jetspeed.om.servlet.impl.SecurityRoleImpl;
import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
/**
* Utilities for manipulating the web.xml deployment descriptor
*
* @author <a href="mailto:ate@douma.nu">Ate Douma </a>*
* @version $Id: WebDescriptorUtilities.java,v 1.1 2004/05/07 20:34:23 taylor Exp $
*/
public class WebDescriptorUtilities {
protected final static Log log = LogFactory.getLog(WebDescriptorUtilities.class);
/**
* Load a web.xml file into a Web Application tree
*
* @param pathWebXML
* The path to the web.xml file
* @param contexRoot
* The context root of the web application
* @param locale
* The locale of the display name of the web application
* @param displayName
* The display name of the web application
* @return The Java object tree representing web.xml
*/
public static MutableWebApplication loadDescriptor(String pathWebXML, String contextRoot, Locale locale, String displayName)
throws PortletApplicationException {
try {
FileReader reader = new java.io.FileReader(pathWebXML);
// TODO move config to digester-rules.xml. Example:
// http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=3
Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("web-app", WebApplicationDefinitionImpl.class);
digester.addObjectCreate("web-app/security-role", SecurityRoleImpl.class);
digester.addBeanPropertySetter("web-app/security-role/description", "description");
digester.addBeanPropertySetter("web-app/security-role/role-name", "roleName");
digester.addSetNext("web-app/security-role", "addSecurityRole");
WebApplicationDefinitionImpl wd = (WebApplicationDefinitionImpl) digester.parse(reader);
wd.setContextRoot(contextRoot);
wd.addDescription(locale, displayName);
return wd;
} catch (Throwable t) {
t.printStackTrace();
String msg = "Could not digest \"" + pathWebXML + "\". " + t.toString();
log.error(msg, t);
throw new PortletApplicationException(msg, t);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org