You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/08/03 14:15:58 UTC
svn commit: r682143 [2/2] - in
/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki:
attachment/ auth/ auth/acl/
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SecurityVerifier.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SecurityVerifier.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SecurityVerifier.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SecurityVerifier.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
/*
- JSPWiki - a JSP-based WikiWiki clone.
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth;
@@ -24,13 +25,11 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.security.*;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
@@ -46,7 +45,6 @@
import com.ecyrd.jspwiki.auth.permissions.GroupPermission;
import com.ecyrd.jspwiki.auth.permissions.PermissionFactory;
import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
-import com.ecyrd.jspwiki.auth.user.DefaultUserProfile;
import com.ecyrd.jspwiki.auth.user.UserDatabase;
import com.ecyrd.jspwiki.auth.user.UserProfile;
@@ -62,10 +60,6 @@
private WikiEngine m_engine;
- private File m_jaasConfig = null;
-
- private boolean m_isJaasConfigured = false;
-
private boolean m_isSecurityPolicyConfigured = false;
private Principal[] m_policyPrincipals = new Principal[0];
@@ -227,47 +221,45 @@
s.append( " <tr>\n" );
for( int i = 0; i < roles.length; i++ )
{
- for( int j = 0; j < pageActions.length; j++ )
+ for( String pageAction : pageActions )
{
- String action = pageActions[j].substring( 0, 1 );
- s.append( " <th title=\"" + pageActions[j] + "\">" + action + "</th>\n" );
+ String action = pageAction.substring( 0, 1 );
+ s.append( " <th title=\"" + pageAction + "\">" + action + "</th>\n" );
}
}
s.append( " </tr>\n" );
// Write page permission tests first
- for( int i = 0; i < pages.length; i++ )
+ for( String page : pages )
{
- String page = pages[i];
s.append( " <tr>\n" );
s.append( " <td>PagePermission \"" + wiki + ":" + page + "\"</td>\n" );
- for( int j = 0; j < roles.length; j++ )
+ for( Principal role : roles )
{
- for( int k = 0; k < pageActions.length; k++ )
+ for( String pageAction : pageActions )
{
- Permission permission = PermissionFactory.getPagePermission( wiki + ":" + page, pageActions[k] );
- s.append( printPermissionTest( permission, roles[j], 1 ) );
+ Permission permission = PermissionFactory.getPagePermission( wiki + ":" + page, pageAction );
+ s.append( printPermissionTest( permission, role, 1 ) );
}
}
s.append( " </tr>\n" );
}
// Now do the group tests
- for( int i = 0; i < groups.length; i++ )
+ for( String group : groups )
{
- String group = groups[i];
s.append( " <tr>\n" );
s.append( " <td>GroupPermission \"" + wiki + ":" + group + "\"</td>\n" );
- for( int j = 0; j < roles.length; j++ )
+ for( Principal role : roles )
{
- for( int k = 0; k < groupActions.length; k++ )
+ for( String groupAction : groupActions )
{
Permission permission = null;
- if ( groupActions[k] != null)
+ if ( groupAction != null)
{
- permission = new GroupPermission( wiki + ":" + group, groupActions[k] );
+ permission = new GroupPermission( wiki + ":" + group, groupAction );
}
- s.append( printPermissionTest( permission, roles[j], 1 ) );
+ s.append( printPermissionTest( permission, role, 1 ) );
}
}
s.append( " </tr>\n" );
@@ -277,14 +269,14 @@
// Now check the wiki-wide permissions
String[] wikiPerms = new String[]
{ "createGroups", "createPages", "login", "editPreferences", "editProfile" };
- for( int i = 0; i < wikiPerms.length; i++ )
+ for( String wikiPerm : wikiPerms )
{
s.append( " <tr>\n" );
- s.append( " <td>WikiPermission \"" + wiki + "\",\"" + wikiPerms[i] + "\"</td>\n" );
- for( int j = 0; j < roles.length; j++ )
+ s.append( " <td>WikiPermission \"" + wiki + "\",\"" + wikiPerm + "\"</td>\n" );
+ for( Principal role : roles )
{
- Permission permission = new WikiPermission( wiki, wikiPerms[i] );
- s.append( printPermissionTest( permission, roles[j], pageActions.length ) );
+ Permission permission = new WikiPermission( wiki, wikiPerm );
+ s.append( printPermissionTest( permission, role, pageActions.length ) );
}
s.append( " </tr>\n" );
}
@@ -292,10 +284,10 @@
// Lastly, check for AllPermission
s.append( " <tr>\n" );
s.append( " <td>AllPermission \"" + wiki + "\"</td>\n" );
- for( int j = 0; j < roles.length; j++ )
+ for( Principal role : roles )
{
Permission permission = new AllPermission( wiki );
- s.append( printPermissionTest( permission, roles[j], pageActions.length ) );
+ s.append( printPermissionTest( permission, role, pageActions.length ) );
}
s.append( " </tr>\n" );
@@ -378,9 +370,9 @@
s.append( " </tr>\n" );
s.append( " <tr>\n" );
s.append( " <th>Anonymous</th>\n" );
- for( int i = 0; i < roles.length; i++ )
+ for( Principal role : roles )
{
- s.append( " <th>" + roles[i].getName() + "</th>\n" );
+ s.append( " <th>" + role.getName() + "</th>\n" );
}
s.append( "</tr>\n" );
s.append( "</thead>\n" );
@@ -406,10 +398,9 @@
s.append( "\"" );
s.append( allowsAnonymous ? BG_GREEN + ">" : BG_RED + ">" );
s.append( " </td>\n" );
- for( int j = 0; j < roles.length; j++ )
+ for( Principal role : roles )
{
- Role role = (Role) roles[j];
- boolean allowed = allowsAnonymous || wca.isConstrained( jsp, role );
+ boolean allowed = allowsAnonymous || wca.isConstrained( jsp, (Role)role );
s.append( " <td title=\"" );
s.append( allowed ? "ALLOW: " : "DENY: " );
s.append( jsp );
@@ -439,50 +430,6 @@
}
/**
- * Returns <code>true</code> if JAAS is configured correctly.
- * @return the result of the configuration check
- */
- public final boolean isJaasConfigured()
- {
- return m_isJaasConfigured;
- }
-
- /**
- * Returns <code>true</code> if the JAAS login configuration was already
- * set when JSPWiki started up. We determine this value by consulting a
- * protected member field of {@link AuthenticationManager}, which was set
- * at in initialization by {@link PolicyLoader}.
- * @return <code>true</code> if {@link PolicyLoader} successfully set the
- * policy, or <code>false</code> for any other reason.
- */
- public final boolean isJaasConfiguredAtStartup()
- {
- return m_engine.getAuthenticationManager().m_isJaasConfiguredAtStartup;
- }
-
- /**
- * Returns <code>true</code> if JSPWiki can locate a named JAAS login
- * configuration.
- * @param config the name of the application (e.g.,
- * <code>JSPWiki-container</code>).
- * @return <code>true</code> if found; <code>false</code> otherwise
- */
- protected final boolean isJaasConfigurationAvailable( String config )
- {
- try
- {
- m_session.addMessage( INFO_JAAS, "We found the '" + config + "' login configuration." );
- new LoginContext( config );
- return true;
- }
- catch( Exception e )
- {
- m_session.addMessage( ERROR_JAAS, "We could not find the '" + config + "' login configuration.</p>" );
- return false;
- }
- }
-
- /**
* Returns <code>true</code> if the Java security policy is configured
* correctly, and it verifies as valid.
* @return the result of the configuration check
@@ -518,9 +465,8 @@
Authorizer authorizer = m_engine.getAuthorizationManager().getAuthorizer();
Principal[] containerRoles = authorizer.getRoles();
boolean missing = false;
- for( int i = 0; i < m_policyPrincipals.length; i++ )
+ for( Principal principal : m_policyPrincipals )
{
- Principal principal = m_policyPrincipals[i];
if ( principal instanceof Role )
{
Role role = (Role) principal;
@@ -657,17 +603,6 @@
"be reliable as a result. You should set this to 'jaas' " +
"so that security works properly." );
}
-
- // Validate the property is set correctly
- m_jaasConfig = getFileFromProperty( "java.security.auth.login.config" );
-
- // Look for the JSPWiki-container config
- boolean foundJaasContainerConfig = isJaasConfigurationAvailable( "JSPWiki-container" );
-
- // Look for the JSPWiki-custom config
- boolean foundJaasCustomConfig = isJaasConfigurationAvailable( "JSPWiki-custom" );
-
- m_isJaasConfigured = m_jaasConfig != null && foundJaasContainerConfig && foundJaasCustomConfig;
}
/**
@@ -739,6 +674,7 @@
* resolves to an existing file, and the policy file contained therein
* represents a valid policy.
*/
+ @SuppressWarnings("unchecked")
protected final void verifyPolicy()
{
// Look up the policy file and set the status text.
@@ -772,12 +708,11 @@
// Verify the file
policy.read();
- List errors = policy.getMessages();
+ List<Exception> errors = policy.getMessages();
if ( errors.size() > 0 )
{
- for( Iterator it = errors.iterator(); it.hasNext(); )
+ for( Exception e : errors )
{
- Exception e = (Exception) it.next();
m_session.addMessage( ERROR_POLICY, e.getMessage() );
}
}
@@ -789,21 +724,20 @@
// Stash the unique principals mentioned in the file,
// plus our standard roles.
- Set principals = new LinkedHashSet();
+ Set<Principal> principals = new LinkedHashSet<Principal>();
principals.add( Role.ALL );
principals.add( Role.ANONYMOUS );
principals.add( Role.ASSERTED );
principals.add( Role.AUTHENTICATED );
ProtectionDomain[] domains = policy.getProtectionDomains();
- for ( int i = 0; i < domains.length; i++ )
+ for ( ProtectionDomain domain : domains )
{
- Principal[] domainPrincipals = domains[i].getPrincipals();
- for( int j = 0; j < domainPrincipals.length; j++ )
+ for( Principal principal : domain.getPrincipals() )
{
- principals.add( domainPrincipals[j] );
+ principals.add( principal );
}
}
- m_policyPrincipals = (Principal[]) principals.toArray( new Principal[principals.size()] );
+ m_policyPrincipals = principals.toArray( new Principal[principals.size()] );
}
catch( IOException e )
{
@@ -824,7 +758,7 @@
Subject subject = new Subject();
subject.getPrincipals().add( principal );
boolean allowedByGlobalPolicy = ((Boolean)
- Subject.doAsPrivileged( subject, new PrivilegedAction()
+ Subject.doAsPrivileged( subject, new PrivilegedAction<Object>()
{
public Object run()
{
@@ -896,11 +830,11 @@
String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
try
{
- UserProfile profile = new DefaultUserProfile();
- profile.setEmail("testuser@testville.com");
+ UserProfile profile = db.newProfile();
+ profile.setEmail( "testuser@testville.com" );
profile.setLoginName( loginName );
profile.setFullname( "FullName"+loginName );
- profile.setPassword("password");
+ profile.setPassword( "password" );
db.save(profile);
// Make sure the profile saved successfully
@@ -936,16 +870,4 @@
m_session.addMessage( INFO_DB, "The user database configuration looks fine." );
}
-
- /**
- * Returns the location of the JAAS configuration file if and only if the
- * <code>java.security.auth.login.config</code> is set <em>and</em> the
- * file it points to exists in the file system; returns <code>null</code>
- * in all other cases.
- * @return the location of the JAAS configuration file
- */
- public final File jaasConfiguration()
- {
- return m_jaasConfig;
- }
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SessionMonitor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SessionMonitor.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SessionMonitor.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/SessionMonitor.java Sun Aug 3 05:15:57 2008
@@ -1,22 +1,23 @@
-/*
- JSPWiki - a JSP-based WikiWiki clone.
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2006 JSPWiki Development Team
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ 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.
+ */
package com.ecyrd.jspwiki.auth;
import java.security.Principal;
@@ -48,10 +49,10 @@
private static Logger log = Logger.getLogger( SessionMonitor.class );
/** Map with WikiEngines as keys, and SessionMonitors as values. */
- private static Map c_monitors = new HashMap();
+ private static Map<WikiEngine, SessionMonitor> c_monitors = new HashMap<WikiEngine, SessionMonitor>();
/** Weak hashmap with HttpSessions as keys, and WikiSessions as values. */
- private final Map m_sessions = new WeakHashMap();
+ private final Map<String, WikiSession> m_sessions = new WeakHashMap<String, WikiSession>();
private WikiEngine m_engine;
@@ -73,7 +74,7 @@
synchronized( c_monitors )
{
- monitor = (SessionMonitor) c_monitors.get(engine);
+ monitor = c_monitors.get(engine);
if( monitor == null )
{
monitor = new SessionMonitor(engine);
@@ -108,7 +109,7 @@
{
WikiSession wikiSession = null;
String sid = ( session == null ) ? "(null)" : session.getId();
- WikiSession storedSession = (WikiSession)m_sessions.get( sid );
+ WikiSession storedSession = m_sessions.get( sid );
// If the weak reference returns a wiki session, return it
if( storedSession != null )
@@ -197,14 +198,12 @@
*/
public final Principal[] userPrincipals()
{
- Collection principals = new ArrayList();
- for ( Iterator it = m_sessions.values().iterator(); it.hasNext(); )
+ Collection<Principal> principals = new ArrayList<Principal>();
+ for ( WikiSession session : m_sessions.values() )
{
- WikiSession session = (WikiSession)it.next();
-
principals.add( session.getUserPrincipal() );
}
- Principal[] p = (Principal[])principals.toArray( new Principal[principals.size()] );
+ Principal[] p = principals.toArray( new Principal[principals.size()] );
Arrays.sort( p, m_comparator );
return p;
}
@@ -264,10 +263,10 @@
public void sessionDestroyed( HttpSessionEvent se )
{
HttpSession session = se.getSession();
- Iterator it = c_monitors.values().iterator();
+ Iterator<SessionMonitor> it = c_monitors.values().iterator();
while( it.hasNext() )
{
- SessionMonitor monitor = (SessionMonitor)it.next();
+ SessionMonitor monitor = it.next();
WikiSession storedSession = monitor.findSession(session);
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java Sun Aug 3 05:15:57 2008
@@ -1,24 +1,26 @@
-/*
- JSPWiki - a JSP-based WikiWiki clone.
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ 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.
+ */
package com.ecyrd.jspwiki.auth;
+import java.io.Serializable;
import java.security.Permission;
import java.security.Principal;
import java.text.MessageFormat;
@@ -28,12 +30,9 @@
import javax.mail.internet.AddressException;
import javax.servlet.http.HttpServletRequest;
-import net.sourceforge.stripes.action.UrlBinding;
-
import org.apache.log4j.Logger;
import com.ecyrd.jspwiki.*;
-import com.ecyrd.jspwiki.action.LoginActionBean;
import com.ecyrd.jspwiki.auth.permissions.AllPermission;
import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
import com.ecyrd.jspwiki.auth.user.AbstractUserDatabase;
@@ -55,7 +54,6 @@
/**
* Provides a facade for obtaining user information.
- * @author Janne Jalkanen
* @author Andrew Jaquith
* @since 2.3
*/
@@ -86,8 +84,8 @@
// private static final String PROP_ACLMANAGER = "jspwiki.aclManager";
- /** Associateds wiki sessions with profiles */
- private final Map<WikiSession,UserProfile> m_profiles = new WeakHashMap<WikiSession,UserProfile>();
+ /** Associates wiki sessions with profiles */
+ private final Map<WikiSession,UserProfile> m_profiles = new WeakHashMap<WikiSession,UserProfile>();
/** The user database loads, manages and persists user identities */
private UserDatabase m_database;
@@ -106,6 +104,7 @@
* @param engine the current wiki engine
* @param props the wiki engine initialization properties
*/
+ @SuppressWarnings("deprecation")
public final void initialize( WikiEngine engine, Properties props )
{
m_engine = engine;
@@ -116,7 +115,7 @@
// TODO: it would be better if we did this in PageManager directly
addWikiEventListener( engine.getPageManager() );
- JSONRPCManager.registerGlobalObject( "users", new JSONUserModule(), new AllPermission(null) );
+ JSONRPCManager.registerGlobalObject( "users", new JSONUserModule(this), new AllPermission(null) );
}
/**
@@ -149,7 +148,7 @@
PROP_DATABASE );
log.info("Attempting to load user database class "+dbClassName);
- Class dbClass = ClassUtil.findClass( USERDATABASE_PACKAGE, dbClassName );
+ Class<?> dbClass = ClassUtil.findClass( USERDATABASE_PACKAGE, dbClassName );
m_database = (UserDatabase) dbClass.newInstance();
m_database.initialize( m_engine, m_engine.getWikiProperties() );
log.info("UserDatabase initialized.");
@@ -431,7 +430,7 @@
{
// Retrieve the user's profile (may have been previously cached)
UserProfile profile = getUserProfile( context.getWikiSession() );
- HttpServletRequest request = context.getContext().getRequest();
+ HttpServletRequest request = context.getHttpRequest();
// Extract values from request stream (cleanse whitespace as needed)
String loginName = request.getParameter( PARAM_LOGINNAME );
@@ -472,8 +471,8 @@
* (see {@link WikiSession#getMessages()}.
* @param context the current wiki context
* @param profile the supplied UserProfile
- * @deprecated
*/
+ @SuppressWarnings("unchecked")
public final void validateProfile( WikiContext context, UserProfile profile )
{
boolean isNew = profile.isNew();
@@ -485,11 +484,9 @@
// Query the SpamFilter first
//
- List ls = m_engine.getFilterManager().getFilterList();
- for( Iterator i = ls.iterator(); i.hasNext(); )
+ List<PageFilter> ls = m_engine.getFilterManager().getFilterList();
+ for( PageFilter pf : ls )
{
- PageFilter pf = (PageFilter)i.next();
-
if( pf instanceof SpamFilter )
{
if( ((SpamFilter)pf).isValidUserProfile( context, profile ) == false )
@@ -502,10 +499,8 @@
}
// If container-managed auth and user not logged in, throw an error
- // unless we're allowed to add profiles to the container
if ( m_engine.getAuthenticationManager().isContainerAuthenticated()
- && !context.getWikiSession().isAuthenticated()
- && !getUserDatabase().isSharedWithContainer() )
+ && !context.getWikiSession().isAuthenticated() )
{
session.addMessage( SESSION_MESSAGES, rb.getString("security.error.createprofilebeforelogin") );
}
@@ -569,6 +564,12 @@
{ /* It's clean */ }
}
+ /**
+ * A helper method for returning all of the known WikiNames in this system.
+ *
+ * @return An Array of Principals
+ * @throws WikiSecurityException If for reason the names cannot be fetched
+ */
public Principal[] listWikiNames()
throws WikiSecurityException
{
@@ -579,7 +580,6 @@
* This is a database that gets used if nothing else is available. It does
* nothing of note - it just mostly thorws NoSuchPrincipalExceptions if
* someone tries to log in.
- * @author Janne Jalkanen
*/
public static class DummyUserDatabase extends AbstractUserDatabase
{
@@ -588,6 +588,7 @@
* No-op.
* @throws WikiSecurityException never...
*/
+ @SuppressWarnings("deprecation")
public void commit() throws WikiSecurityException
{
// No operation
@@ -638,6 +639,16 @@
/**
* No-op; always throws <code>NoSuchPrincipalException</code>.
+ * @param uid the unique identifier to search for
+ * @return the user profile
+ * @throws NoSuchPrincipalException never...
+ */
+ public UserProfile findByUid( long uid ) throws NoSuchPrincipalException
+ {
+ throw new NoSuchPrincipalException("No user profiles available");
+ }
+ /**
+ * No-op; always throws <code>NoSuchPrincipalException</code>.
* @param index the name to search for
* @return the user profile
* @throws NoSuchPrincipalException never...
@@ -668,15 +679,6 @@
}
/**
- * No-op.
- * @return <code>false</code>
- */
- public boolean isSharedWithContainer()
- {
- return false;
- }
-
- /**
* No-op; always throws <code>NoSuchPrincipalException</code>.
* @param loginName the login name
* @param newName the proposed new login name
@@ -711,6 +713,7 @@
*/
public static class SaveUserProfileTask extends Task
{
+ private static final long serialVersionUID = 6994297086560480285L;
private final UserDatabase m_db;
private final WikiEngine m_engine;
@@ -753,7 +756,7 @@
+ "Your name : " + profile.getFullname() + "\n"
+ "E-mail : " + profile.getEmail() + "\n\n"
+ "If you forget your password, you can reset it at "
- + m_engine.getBaseURL() + LoginActionBean.class.getAnnotation(UrlBinding.class).value();
+ + m_engine.getURL(WikiContext.LOGIN, null, null, true);
MailUtil.sendMessage( m_engine, to, subject, content);
}
catch ( AddressException e)
@@ -810,11 +813,25 @@
/**
* Implements the JSON API for usermanager.
- *
- * @author Janne Jalkanen
+ * <p>
+ * Even though this gets serialized whenever container shuts down/restarts,
+ * this gets reinstalled to the session when JSPWiki starts. This means
+ * that it's not actually necessary to save anything.
*/
- public final class JSONUserModule implements RPCCallable
+ public static final class JSONUserModule implements RPCCallable, Serializable
{
+ private static final long serialVersionUID = 1L;
+ private volatile UserManager m_manager;
+
+ /**
+ * Create a new JSONUserModule.
+ * @param mgr Manager
+ */
+ public JSONUserModule( UserManager mgr )
+ {
+ m_manager = mgr;
+ }
+
/**
* Directly returns the UserProfile object attached to an uid.
*
@@ -825,12 +842,14 @@
public UserProfile getUserInfo( String uid )
throws NoSuchPrincipalException
{
- log.info("request "+uid);
- UserProfile prof = getUserDatabase().find( uid );
-
- log.info("answer "+prof);
+ if( m_manager != null )
+ {
+ UserProfile prof = m_manager.getUserDatabase().find( uid );
- return prof;
+ return prof;
+ }
+
+ throw new IllegalStateException("The manager is offline.");
}
}
-}
\ No newline at end of file
+}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java Sun Aug 3 05:15:57 2008
@@ -1,24 +1,26 @@
/*
- JSPWiki - a JSP-based WikiWiki clone.
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth;
+import java.io.Serializable;
import java.security.Principal;
import java.util.Arrays;
import java.util.Comparator;
@@ -32,12 +34,12 @@
* or hash code; two WikiPrincipals with the same name but different types are still
* considered equal.
*
- * @author Janne Jalkanen
* @author Andrew Jaquith
* @since 2.2
*/
-public final class WikiPrincipal implements Principal
+public final class WikiPrincipal implements Principal, Comparable<Principal>, Serializable
{
+ private static final long serialVersionUID = 1L;
/**
* Represents an anonymous user. WikiPrincipals may be
@@ -72,6 +74,12 @@
private final String m_name;
private final String m_type;
+ /** For serialization purposes */
+ protected WikiPrincipal()
+ {
+ this(null);
+ }
+
/**
* Constructs a new WikiPrincipal with a given name and a type of
* {@link #UNSPECIFIED}.
@@ -95,10 +103,6 @@
*/
public WikiPrincipal( String name, String type )
{
- if ( name == null )
- {
- throw new IllegalArgumentException( "Name cannot be null" );
- }
m_name = name;
if ( Arrays.binarySearch( VALID_TYPES, type ) < 0 )
{
@@ -159,6 +163,19 @@
{
return "[WikiPrincipal (" + m_type + "): " + getName() + "]";
}
+
+ /**
+ * Allows comparisons to any other Principal objects. Primary sorting
+ * order is by the principal name, as returned by getName().
+ *
+ * @param o {@inheritDoc}
+ * @return {@inheritDoc}
+ * @since 2.7.0
+ */
+ public int compareTo(Principal o)
+ {
+ return getName().compareTo( o.getName() );
+ }
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiSecurityException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiSecurityException.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiSecurityException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiSecurityException.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth;
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/Acl.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/Acl.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/Acl.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/Acl.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
-/*
- JSPWiki - a JSP-based WikiWiki clone.
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
@@ -51,7 +52,6 @@
* the getPermissions() and checkPermission() methods have been eliminated due
* to the complexities associated with resolving Role principal membership.
* </p>
- * @author Janne Jalkanen
* @author Andrew Jaquith
* @since 2.3
*/
@@ -74,6 +74,7 @@
* enumeration is of type AclEntry.
* @return an enumeration of the entries in this ACL.
*/
+ @SuppressWarnings("unchecked")
public Enumeration entries();
/**
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntry.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntry.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntry.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntry.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
@@ -39,7 +40,6 @@
* interface, minus negative permissions.
* </p>
* @see Acl
- * @author Janne Jalkanen
* @author Andrew Jaquith
* @since 2.3
*/
@@ -80,6 +80,7 @@
* Returns an enumeration of the permissions in this ACL entry.
* @return an enumeration of the permissions
*/
+ @SuppressWarnings("unchecked")
public Enumeration permissions();
/**
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntryImpl.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntryImpl.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntryImpl.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclEntryImpl.java Sun Aug 3 05:15:57 2008
@@ -1,42 +1,43 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
+import java.io.Serializable;
import java.security.Permission;
import java.security.Principal;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.Vector;
import com.ecyrd.jspwiki.auth.permissions.PagePermission;
/**
* Implementation of a JSPWiki AclEntry.
- * @author Janne Jalkanen
+ *
* @author Andrew Jaquith
* @since 2.3
*/
-public class AclEntryImpl implements AclEntry
+public class AclEntryImpl implements AclEntry, Serializable
{
-
- private Vector m_permissions = new Vector();
+ private static final long serialVersionUID = 1L;
+ private Vector<Permission> m_permissions = new Vector<Permission>();
private Principal m_principal;
/**
@@ -95,6 +96,7 @@
* Returns an enumeration of the permissions in this ACL entry.
* @return an enumeration of the permissions
*/
+ @SuppressWarnings("unchecked")
public Enumeration permissions()
{
return m_permissions.elements();
@@ -150,10 +152,8 @@
sb.append( "[AclEntry ALLOW " + ( p != null ? p.getName() : "null" ) );
sb.append( " " );
- for( Iterator i = m_permissions.iterator(); i.hasNext(); )
+ for( Permission pp : m_permissions )
{
- Permission pp = (Permission) i.next();
-
sb.append( pp.toString() );
sb.append( "," );
}
@@ -169,10 +169,8 @@
*/
private Permission findPermission( Permission p )
{
- for( Iterator i = m_permissions.iterator(); i.hasNext(); )
+ for( Permission pp : m_permissions )
{
- Permission pp = (Permission) i.next();
-
if ( pp.implies( p ) )
{
return pp;
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclImpl.java Sun Aug 3 05:15:57 2008
@@ -1,38 +1,40 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
+import java.io.Serializable;
import java.security.Permission;
import java.security.Principal;
import java.util.Enumeration;
-import java.util.Iterator;
import java.util.Vector;
/**
* JSPWiki implementation of an Access Control List.
- * @author Janne Jalkanen
+ *
* @author Andrew Jaquith
* @since 2.3
*/
-public class AclImpl implements Acl
+public class AclImpl implements Acl, Serializable
{
+ private static final long serialVersionUID = 1L;
private final Vector<AclEntry> m_entries = new Vector<AclEntry>();
/**
@@ -44,24 +46,25 @@
/**
* Returns all Principal objects assigned a given Permission in the access
- * control list. The Princiapls returned are those that have been granted
+ * control list. The Principals returned are those that have been granted
* either the supplied permission, or a permission implied by the supplied
* permission. Principals are not "expanded" if they are a role or group.
* @param permission the permission to search for
- * @return an array of Principals posessing the permission
+ * @return an array of Principals possessing the permission
*/
+ @SuppressWarnings("unchecked")
public Principal[] findPrincipals( Permission permission )
{
Vector<Principal> principals = new Vector<Principal>();
- Enumeration entries = entries();
+ Enumeration<AclEntry> entries = entries();
while (entries.hasMoreElements())
{
- AclEntry entry = (AclEntry)entries.nextElement();
- Enumeration permissions = entry.permissions();
+ AclEntry entry = entries.nextElement();
+ Enumeration<Permission> permissions = entry.permissions();
while ( permissions.hasMoreElements() )
{
- Permission perm = (Permission)permissions.nextElement();
+ Permission perm = permissions.nextElement();
if ( perm.implies( permission ) )
{
principals.add( entry.getPrincipal() );
@@ -78,10 +81,8 @@
return false;
}
- for( Iterator i = m_entries.iterator(); i.hasNext(); )
+ for( AclEntry e : m_entries )
{
- AclEntry e = (AclEntry) i.next();
-
Principal ep = e.getPrincipal();
Principal entryp = entry.getPrincipal();
@@ -141,6 +142,7 @@
* enumeration is of type AclEntry.
* @return an enumeration of the entries in this ACL.
*/
+ @SuppressWarnings("unchecked")
public Enumeration entries()
{
return m_entries.elements();
@@ -154,10 +156,8 @@
*/
public AclEntry getEntry( Principal principal )
{
- for( Enumeration e = m_entries.elements(); e.hasMoreElements(); )
+ for( AclEntry entry : m_entries )
{
- AclEntry entry = (AclEntry) e.nextElement();
-
if( entry.getPrincipal().getName().equals( principal.getName() ) )
{
return entry;
@@ -171,14 +171,13 @@
* Returns a string representation of the contents of this Acl.
* @return the string representation
*/
+ @SuppressWarnings("unchecked")
public String toString()
{
StringBuffer sb = new StringBuffer();
- for( Enumeration myEnum = entries(); myEnum.hasMoreElements(); )
+ for( AclEntry entry : m_entries )
{
- AclEntry entry = (AclEntry) myEnum.nextElement();
-
Principal pal = entry.getPrincipal();
if( pal != null )
@@ -187,9 +186,9 @@
sb.append( " user = null: " );
sb.append( "(" );
- for( Enumeration perms = entry.permissions(); perms.hasMoreElements(); )
+ for( Enumeration<Permission> perms = entry.permissions(); perms.hasMoreElements(); )
{
- Permission perm = (Permission) perms.nextElement();
+ Permission perm = perms.nextElement();
sb.append( perm.toString() );
}
sb.append( ")\n" );
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclManager.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/AclManager.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/DefaultAclManager.java Sun Aug 3 05:15:57 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
@@ -47,7 +48,7 @@
static Logger log = Logger.getLogger( DefaultAclManager.class );
private AuthorizationManager m_auth = null;
- private WikiEngine m_engine = null;
+ private WikiEngine m_engine = null;
private static final String PERM_REGEX = "(" +
PagePermission.COMMENT_ACTION + "|" +
PagePermission.DELETE_ACTION + "|" +
@@ -179,7 +180,7 @@
//
// Or, try parsing the page
//
- WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( page );
+ WikiContext ctx = m_engine.getWikiActionBeanFactory().newViewActionBean( null, null, page );
ctx.setVariable( RenderingManager.VAR_EXECUTE_PLUGINS, Boolean.FALSE );
@@ -243,19 +244,20 @@
* @param acl the ACL
* @return the ACL string
*/
+ @SuppressWarnings("unchecked")
protected static String printAcl( Acl acl )
{
// Extract the ACL entries into a Map with keys == permissions, values == principals
- Map<String,List<Principal>> permissionPrincipals = new TreeMap<String,List<Principal>>();
- Enumeration entries = acl.entries();
+ Map<String, List<Principal>> permissionPrincipals = new TreeMap<String, List<Principal>>();
+ Enumeration<AclEntry> entries = acl.entries();
while ( entries.hasMoreElements() )
{
- AclEntry entry = (AclEntry)entries.nextElement();
+ AclEntry entry = entries.nextElement();
Principal principal = entry.getPrincipal();
- Enumeration permissions = entry.permissions();
+ Enumeration<Permission> permissions = entry.permissions();
while ( permissions.hasMoreElements() )
{
- Permission permission = (Permission)permissions.nextElement();
+ Permission permission = permissions.nextElement();
List<Principal> principals = permissionPrincipals.get( permission.getActions() );
if ( principals == null )
{
@@ -274,7 +276,7 @@
// Now, iterate through each permission in the map and generate an ACL string
StringBuffer s = new StringBuffer();
- for ( Map.Entry<String,List<Principal>> entry : permissionPrincipals.entrySet() )
+ for ( Map.Entry<String,List<Principal>>entry : permissionPrincipals.entrySet() )
{
String action = entry.getKey();
List<Principal> principals = entry.getValue();
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/UnresolvedPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/UnresolvedPrincipal.java?rev=682143&r1=682142&r2=682143&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/UnresolvedPrincipal.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/UnresolvedPrincipal.java Sun Aug 3 05:15:57 2008
@@ -1,24 +1,26 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 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.
*/
package com.ecyrd.jspwiki.auth.acl;
+import java.io.Serializable;
import java.security.Principal;
/**
@@ -34,9 +36,9 @@
* @author Andrew Jaquith
* @since 2.3
*/
-public final class UnresolvedPrincipal implements Principal
+public final class UnresolvedPrincipal implements Principal, Serializable
{
-
+ private static final long serialVersionUID = 1L;
private final String m_name;
/**
Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/package.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/package.html?rev=682143&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/package.html (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/acl/package.html Sun Aug 3 05:15:57 2008
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>JSPWiki: ACL</title>
+</head>
+<body>
+
+<p>Access Control List implementation.</p>
+
+<h3>Package Specification</h3>
+
+<p>This package contains all the JSPWiki ACL implementation.</p>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file
Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/package.html
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/package.html?rev=682143&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/package.html (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/package.html Sun Aug 3 05:15:57 2008
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+
+<p>Authentication, Authorization and the third A thing.</p>
+
+<h3>Package Specification</h3>
+
+<p>JSPWiki contains a fairly versatile AAA subsystem, with per-page access control. This is the
+main package which contains everything which is related to it.</p>
+
+<h3>Related Documentation</h3>
+
+TBA.
+
+</body>
+</html>
\ No newline at end of file