weaver 2004/10/29 07:08:36
Modified: components/security/src/java/org/apache/jetspeed/security/spi/impl
DefaultSecurityMappingHandler.java
DefaultGroupSecurityHandler.java
DefaultCredentialHandler.java
DefaultUserSecurityHandler.java
DefaultRoleSecurityHandler.java
components/security/src/java/org/apache/jetspeed/security/impl
PermissionManagerImpl.java
Added: components/security/src/java/org/apache/jetspeed/security/spi/impl
SecurityAccessImpl.java
components/security/src/java/org/apache/jetspeed/security/spi
SecurityAccess.java
Removed: components/security/src/java/org/apache/jetspeed/security/spi/impl
CommonQueries.java
Log:
see: http://nagoya.apache.org/jira/browse/JS2-144
- security refactor
Revision Changes Path
1.5 +4 -3
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java
Index: DefaultSecurityMappingHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultSecurityMappingHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultSecurityMappingHandler.java 11 Oct 2004 23:25:29 -0000 1.4
+++ DefaultSecurityMappingHandler.java 29 Oct 2004 14:08:35 -0000 1.5
@@ -31,6 +31,7 @@
import org.apache.jetspeed.security.om.InternalRolePrincipal;
import org.apache.jetspeed.security.om.InternalUserPrincipal;
import org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl;
+import org.apache.jetspeed.security.spi.SecurityAccess;
import org.apache.jetspeed.security.spi.SecurityMappingHandler;
/**
@@ -47,14 +48,14 @@
HierarchyResolver groupHierarchyResolver = new
GeneralizationHierarchyResolver();
/** Common queries. */
- private CommonQueries commonQueries = null;
+ private SecurityAccess commonQueries = null;
/**
* <p>
* Constructor providing access to the common queries.
* </p>
*/
- public DefaultSecurityMappingHandler(CommonQueries commonQueries)
+ public DefaultSecurityMappingHandler(SecurityAccess commonQueries)
{
this.commonQueries = commonQueries;
}
@@ -65,7 +66,7 @@
* resolvers.
* </p>
*/
- public DefaultSecurityMappingHandler(CommonQueries commonQueries,
HierarchyResolver roleHierarchyResolver,
+ public DefaultSecurityMappingHandler(SecurityAccess commonQueries,
HierarchyResolver roleHierarchyResolver,
HierarchyResolver groupHierarchyResolver)
{
this.commonQueries = commonQueries;
1.5 +3 -2
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultGroupSecurityHandler.java
Index: DefaultGroupSecurityHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultGroupSecurityHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultGroupSecurityHandler.java 11 Oct 2004 23:25:29 -0000 1.4
+++ DefaultGroupSecurityHandler.java 29 Oct 2004 14:08:35 -0000 1.5
@@ -22,6 +22,7 @@
import org.apache.jetspeed.security.om.InternalGroupPrincipal;
import org.apache.jetspeed.security.om.impl.InternalGroupPrincipalImpl;
import org.apache.jetspeed.security.spi.GroupSecurityHandler;
+import org.apache.jetspeed.security.spi.SecurityAccess;
/**
* @see org.apache.jetspeed.security.spi.GroupSecurityHandler
@@ -30,12 +31,12 @@
public class DefaultGroupSecurityHandler implements GroupSecurityHandler
{
/** Common queries. */
- private CommonQueries commonQueries = null;
+ private SecurityAccess commonQueries = null;
/**
* <p>Constructor providing access to the common queries.</p>
*/
- public DefaultGroupSecurityHandler(CommonQueries commonQueries)
+ public DefaultGroupSecurityHandler(SecurityAccess commonQueries)
{
this.commonQueries = commonQueries;
}
1.8 +3 -2
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultCredentialHandler.java
Index: DefaultCredentialHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultCredentialHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultCredentialHandler.java 27 Oct 2004 22:09:28 -0000 1.7
+++ DefaultCredentialHandler.java 29 Oct 2004 14:08:35 -0000 1.8
@@ -29,6 +29,7 @@
import org.apache.jetspeed.security.om.InternalUserPrincipal;
import org.apache.jetspeed.security.om.impl.InternalCredentialImpl;
import org.apache.jetspeed.security.spi.CredentialHandler;
+import org.apache.jetspeed.security.spi.SecurityAccess;
/**
* @see org.apache.jetspeed.security.spi.CredentialHandler
@@ -45,14 +46,14 @@
private static final int PUBLIC = 1;
/** Common queries. */
- private CommonQueries commonQueries = null;
+ private SecurityAccess commonQueries = null;
/**
* <p>
* Constructor providing access to the common queries.
* </p>
*/
- public DefaultCredentialHandler(CommonQueries commonQueries)
+ public DefaultCredentialHandler(SecurityAccess commonQueries)
{
this.commonQueries = commonQueries;
}
1.4 +3 -2
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java
Index: DefaultUserSecurityHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultUserSecurityHandler.java 27 Oct 2004 22:09:28 -0000 1.3
+++ DefaultUserSecurityHandler.java 29 Oct 2004 14:08:35 -0000 1.4
@@ -24,6 +24,7 @@
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
import org.apache.jetspeed.security.om.InternalUserPrincipal;
import org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl;
+import org.apache.jetspeed.security.spi.SecurityAccess;
import org.apache.jetspeed.security.spi.UserSecurityHandler;
/**
@@ -33,12 +34,12 @@
public class DefaultUserSecurityHandler implements UserSecurityHandler
{
/** Common queries. */
- private CommonQueries commonQueries = null;
+ private SecurityAccess commonQueries = null;
/**
* <p>Constructor providing access to the common queries.</p>
*/
- public DefaultUserSecurityHandler(CommonQueries commonQueries)
+ public DefaultUserSecurityHandler(SecurityAccess commonQueries)
{
this.commonQueries = commonQueries;
}
1.6 +3 -2
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java
Index: DefaultRoleSecurityHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultRoleSecurityHandler.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultRoleSecurityHandler.java 11 Oct 2004 23:25:29 -0000 1.5
+++ DefaultRoleSecurityHandler.java 29 Oct 2004 14:08:35 -0000 1.6
@@ -22,6 +22,7 @@
import org.apache.jetspeed.security.om.InternalRolePrincipal;
import org.apache.jetspeed.security.om.impl.InternalRolePrincipalImpl;
import org.apache.jetspeed.security.spi.RoleSecurityHandler;
+import org.apache.jetspeed.security.spi.SecurityAccess;
/**
* @see org.apache.jetspeed.security.spi.RoleSecurityHandler
@@ -30,14 +31,14 @@
public class DefaultRoleSecurityHandler implements RoleSecurityHandler
{
/** Common queries. */
- private CommonQueries commonQueries = null;
+ private SecurityAccess commonQueries = null;
/**
* <p>
* Constructor providing access to the common queries.
* </p>
*/
- public DefaultRoleSecurityHandler(CommonQueries commonQueries)
+ public DefaultRoleSecurityHandler(SecurityAccess commonQueries)
{
this.commonQueries = commonQueries;
}
1.1
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java
Index: SecurityAccessImpl.java
===================================================================
/* Copyright 2004 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.security.spi.impl;
import java.security.Principal;
import java.util.Iterator;
import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.UserPrincipal;
import org.apache.jetspeed.security.impl.UserPrincipalImpl;
import org.apache.jetspeed.security.om.InternalGroupPrincipal;
import org.apache.jetspeed.security.om.InternalRolePrincipal;
import org.apache.jetspeed.security.om.InternalUserPrincipal;
import org.apache.jetspeed.security.om.impl.InternalGroupPrincipalImpl;
import org.apache.jetspeed.security.om.impl.InternalRolePrincipalImpl;
import org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl;
import org.apache.jetspeed.security.spi.SecurityAccess;
import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.query.QueryFactory;
/**
* <p>
* Provides a utility class for common SPI queries.
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Le Strat </a>
*/
public class SecurityAccessImpl extends InitablePersistenceBrokerDaoSupport
implements SecurityAccess
{
/**
*
* @param repositoryPath
*/
public SecurityAccessImpl(String repositoryPath)
{
super(repositoryPath);
}
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalUserPrincipal} from the user name.
* </p>
*
* @param username The user name.
* @return The [EMAIL PROTECTED] InternalUserPrincipal}.
*/
public InternalUserPrincipal getInternalUserPrincipal(String username)
{
UserPrincipal userPrincipal = new UserPrincipalImpl(username);
String fullPath = userPrincipal.getFullPath();
// Get user.
Criteria filter = new Criteria();
filter.addEqualTo("fullPath", fullPath);
Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, filter);
InternalUserPrincipal internalUser = (InternalUserPrincipal)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalUser;
}
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalUserPrincipal} from the user name.
* </p>
*
* @param username The user name.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @return The [EMAIL PROTECTED] InternalUserPrincipal}.
*/
public InternalUserPrincipal getInternalUserPrincipal(String username, boolean
isMappingOnly)
{
UserPrincipal userPrincipal = new UserPrincipalImpl(username);
String fullPath = userPrincipal.getFullPath();
// Get user.
Criteria filter = new Criteria();
filter.addEqualTo("fullPath", fullPath);
filter.addEqualTo("isMappingOnly", new Boolean(isMappingOnly));
Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, filter);
InternalUserPrincipal internalUser = (InternalUserPrincipal)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalUser;
}
/**
* <p>
* Returns a collection of [EMAIL PROTECTED] Principal}given the filter.
* </p>
*
* @param filter The filter.
* @return Collection of [EMAIL PROTECTED] InternalUserPrincipal}.
*/
public Iterator getInternalUserPrincipals(String filter)
{
Criteria queryCriteria = new Criteria();
queryCriteria.addEqualTo("isMappingOnly", new Boolean(false));
Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class,
queryCriteria);
Iterator result = getPersistenceBrokerTemplate().getIteratorByQuery(query);
return result;
}
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalUserPrincipal}.
* </p>
*
* @param internalUser The [EMAIL PROTECTED] InternalUserPrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void setInternalUserPrincipal(InternalUserPrincipal internalUser, boolean
isMappingOnly) throws SecurityException
{
try
{
if (isMappingOnly)
{
internalUser.setMappingOnly(isMappingOnly);
}
getPersistenceBrokerTemplate().store(internalUser);
}
catch (Exception e)
{
String msg = "Unable to lock user for update.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalUserPrincipal}.
* </p>
*
* @param internalUser The [EMAIL PROTECTED] InternalUserPrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void removeInternalUserPrincipal(InternalUserPrincipal internalUser)
throws SecurityException
{
try
{
// Remove user.
getPersistenceBrokerTemplate().delete(internalUser);
if (logger.isDebugEnabled())
{
logger.debug("Deleted user: " + internalUser.getFullPath());
}
}
catch (Exception e)
{
String msg = "Unable to lock User for update.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalRolePrincipal}from the role full path
name.
* </p>
*
* @param username The role full path name.
* @return The [EMAIL PROTECTED] InternalRolePrincipal}.
*/
public InternalRolePrincipal getInternalRolePrincipal(String roleFullPathName)
{
Criteria filter = new Criteria();
filter.addEqualTo("fullPath", roleFullPathName);
Query query = QueryFactory.newQuery(InternalRolePrincipalImpl.class, filter);
InternalRolePrincipal internalRole = (InternalRolePrincipal)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalRole;
}
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalRolePrincipal}.
* </p>
*
* @param internalRole The [EMAIL PROTECTED] InternalRolePrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void setInternalRolePrincipal(InternalRolePrincipal internalRole, boolean
isMappingOnly) throws SecurityException
{
try
{
if (isMappingOnly)
{
internalRole.setMappingOnly(isMappingOnly);
}
getPersistenceBrokerTemplate().store(internalRole);
}
catch (Exception e)
{
String msg = "Unable to lock role for update.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalRolePrincipal}.
* </p>
*
* @param internalRole The [EMAIL PROTECTED] InternalRolePrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void removeInternalRolePrincipal(InternalRolePrincipal internalRole)
throws SecurityException
{
try
{
// Remove role.
getPersistenceBrokerTemplate().delete(internalRole);
if (logger.isDebugEnabled())
{
logger.debug("Deleted role: " + internalRole.getFullPath());
}
}
catch (Exception e)
{
String msg = "Unable to lock role for delete.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalGroupPrincipal}from the group full path
name.
* </p>
*
* @param username The group full path name.
* @return The [EMAIL PROTECTED] InternalGroupPrincipal}.
*/
public InternalGroupPrincipal getInternalGroupPrincipal(String groupFullPathName)
{
Criteria filter = new Criteria();
filter.addEqualTo("fullPath", groupFullPathName);
Query query = QueryFactory.newQuery(InternalGroupPrincipalImpl.class,
filter);
InternalGroupPrincipal internalGroup = (InternalGroupPrincipal)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalGroup;
}
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalGroupPrincipal}.
* </p>
*
* @param internalGroup The [EMAIL PROTECTED] internalGroupPrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void setInternalGroupPrincipal(InternalGroupPrincipal internalGroup,
boolean isMappingOnly) throws SecurityException
{
try
{
if (isMappingOnly)
{
internalGroup.setMappingOnly(isMappingOnly);
}
getPersistenceBrokerTemplate().store(internalGroup);
}
catch (Exception e)
{
String msg = "Unable to lock group for update.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalGroupPrincipal}.
* </p>
*
* @param internalGroup The [EMAIL PROTECTED] InternalGroupPrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
public void removeInternalGroupPrincipal(InternalGroupPrincipal internalGroup)
throws SecurityException
{
try
{
// Remove role.
getPersistenceBrokerTemplate().delete(internalGroup);
if (logger.isDebugEnabled())
{
logger.debug("Deleted group: " + internalGroup.getFullPath());
}
}
catch (Exception e)
{
String msg = "Unable to lock group for delete.";
logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
}
1.1
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/spi/SecurityAccess.java
Index: SecurityAccess.java
===================================================================
/*
* Copyright 2000-2001,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.security.spi;
import java.util.Iterator;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.om.InternalGroupPrincipal;
import org.apache.jetspeed.security.om.InternalRolePrincipal;
import org.apache.jetspeed.security.om.InternalUserPrincipal;
/**
* <p>
* SecurityAccess
* </p>
* <p>
*
* </p>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: SecurityAccess.java,v 1.1 2004/10/29 14:08:36 weaver Exp $
*
*/
public interface SecurityAccess
{
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalUserPrincipal} from the user name.
* </p>
*
* @param username The user name.
* @return The [EMAIL PROTECTED] InternalUserPrincipal}.
*/
InternalUserPrincipal getInternalUserPrincipal( String username );
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalUserPrincipal} from the user name.
* </p>
*
* @param username The user name.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @return The [EMAIL PROTECTED] InternalUserPrincipal}.
*/
InternalUserPrincipal getInternalUserPrincipal( String username, boolean
isMappingOnly );
/**
* <p>
* Returns a collection of [EMAIL PROTECTED] Principal}given the filter.
* </p>
*
* @param filter The filter.
* @return Collection of [EMAIL PROTECTED] InternalUserPrincipal}.
*/
Iterator getInternalUserPrincipals( String filter );
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalUserPrincipal}.
* </p>
*
* @param internalUser The [EMAIL PROTECTED] InternalUserPrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void setInternalUserPrincipal( InternalUserPrincipal internalUser, boolean
isMappingOnly ) throws SecurityException;
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalUserPrincipal}.
* </p>
*
* @param internalUser The [EMAIL PROTECTED] InternalUserPrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void removeInternalUserPrincipal( InternalUserPrincipal internalUser ) throws
SecurityException;
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalRolePrincipal}from the role full path
name.
* </p>
*
* @param username The role full path name.
* @return The [EMAIL PROTECTED] InternalRolePrincipal}.
*/
InternalRolePrincipal getInternalRolePrincipal( String roleFullPathName );
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalRolePrincipal}.
* </p>
*
* @param internalRole The [EMAIL PROTECTED] InternalRolePrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void setInternalRolePrincipal( InternalRolePrincipal internalRole, boolean
isMappingOnly ) throws SecurityException;
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalRolePrincipal}.
* </p>
*
* @param internalRole The [EMAIL PROTECTED] InternalRolePrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void removeInternalRolePrincipal( InternalRolePrincipal internalRole ) throws
SecurityException;
/**
* <p>
* Returns the [EMAIL PROTECTED] InternalGroupPrincipal}from the group full path
name.
* </p>
*
* @param username The group full path name.
* @return The [EMAIL PROTECTED] InternalGroupPrincipal}.
*/
InternalGroupPrincipal getInternalGroupPrincipal( String groupFullPathName );
/**
* <p>
* Sets the given [EMAIL PROTECTED] InternalGroupPrincipal}.
* </p>
*
* @param internalGroup The [EMAIL PROTECTED] internalGroupPrincipal}.
* @param isMappingOnly Whether a principal's purpose is for security mappping
only.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void setInternalGroupPrincipal( InternalGroupPrincipal internalGroup, boolean
isMappingOnly )
throws SecurityException;
/**
* <p>
* Remove the given [EMAIL PROTECTED] InternalGroupPrincipal}.
* </p>
*
* @param internalGroup The [EMAIL PROTECTED] InternalGroupPrincipal}.
* @throws SecurityException Throws a [EMAIL PROTECTED] SecurityException}.
*/
void removeInternalGroupPrincipal( InternalGroupPrincipal internalGroup ) throws
SecurityException;
}
1.9 +28 -66
jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java
Index: PermissionManagerImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PermissionManagerImpl.java 12 Oct 2004 20:18:46 -0000 1.8
+++ PermissionManagerImpl.java 29 Oct 2004 14:08:36 -0000 1.9
@@ -24,11 +24,6 @@
import java.util.Collections;
import java.util.Iterator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.components.persistence.store.Filter;
-import org.apache.jetspeed.components.persistence.store.PersistenceStore;
-import org.apache.jetspeed.components.persistence.store.Transaction;
import org.apache.jetspeed.security.PermissionManager;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.SecurityHelper;
@@ -37,6 +32,10 @@
import org.apache.jetspeed.security.om.impl.InternalPermissionImpl;
import org.apache.jetspeed.security.om.impl.InternalPrincipalImpl;
import org.apache.jetspeed.util.ArgUtil;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
/**
* <p>
@@ -64,28 +63,8 @@
*
*
*/
-public class PermissionManagerImpl implements PermissionManager
+public class PermissionManagerImpl extends PersistenceBrokerDaoSupport implements
PermissionManager
{
- private static final Log log = LogFactory.getLog(PermissionManagerImpl.class);
-
- /** The persistence store. */
- private PersistenceStore persistenceStore;
-
- /**
- * <p>
- * Constructor providing access to the persistence component.
- * </p>
- */
- public PermissionManagerImpl(PersistenceStore persistenceStore)
- {
- if (persistenceStore == null)
- {
- throw new IllegalArgumentException("persistenceStore cannot be null.");
- }
-
- this.persistenceStore = persistenceStore;
- }
-
/**
* @see
org.apache.jetspeed.security.PermissionManager#getPermissions(java.security.Principal)
*/
@@ -119,10 +98,10 @@
Collection principalsFullPath = getPrincipalsFullPath(principals);
if ((null != principalsFullPath) && principalsFullPath.size() > 0)
{
- Filter filter = persistenceStore.newFilter();
+ Criteria filter = new Criteria();
filter.addIn("fullPath", principalsFullPath);
- Object query = persistenceStore.newQuery(InternalPrincipalImpl.class,
filter);
- Collection internalPrincipals =
persistenceStore.getCollectionByQuery(query);
+ Query query = QueryFactory.newQuery(InternalPrincipalImpl.class,
filter);
+ Collection internalPrincipals =
getPersistenceBrokerTemplate().getCollectionByQuery(query);
Iterator internalPrincipalsIter = internalPrincipals.iterator();
while (internalPrincipalsIter.hasNext())
{
@@ -208,17 +187,13 @@
InternalPermission internalPermission = new
InternalPermissionImpl(permission.getClass().getName(), permission
.getName(), permission.getActions());
try
- {
- Transaction tx = persistenceStore.getTransaction();
- tx.begin();
- persistenceStore.lockForWrite(internalPermission);
- tx.commit();
+ {
+ getPersistenceBrokerTemplate().store(internalPermission);
}
catch (Exception e)
{
String msg = "Unable to add permission.";
- log.error(msg, e);
- persistenceStore.getTransaction().rollback();
+ logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
@@ -237,16 +212,12 @@
try
{
// Remove permission.
- Transaction tx = persistenceStore.getTransaction();
- tx.begin();
- persistenceStore.deletePersistent(internalPermission);
- tx.commit();
+ getPersistenceBrokerTemplate().delete(internalPermission);
}
catch (Exception e)
{
String msg = "Unable to lock Permission for update.";
- log.error(msg, e);
- persistenceStore.getTransaction().rollback();
+ logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
@@ -272,18 +243,15 @@
}
try
{
- Transaction tx = persistenceStore.getTransaction();
- tx.begin();
- persistenceStore.lockForWrite(internalPrincipal);
internalPrincipal.setModifiedDate(new
Timestamp(System.currentTimeMillis()));
internalPrincipal.setPermissions(internalPermissions);
- tx.commit();
+
+ getPersistenceBrokerTemplate().store(internalPrincipal);
}
catch (Exception e)
{
String msg = "Unable to lock Principal for update.";
- log.error(msg, e);
- persistenceStore.getTransaction().rollback();
+ logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
@@ -323,18 +291,15 @@
}
try
{
- Transaction tx = persistenceStore.getTransaction();
- tx.begin();
- persistenceStore.lockForWrite(internalPrincipal);
internalPrincipal.setModifiedDate(new
Timestamp(System.currentTimeMillis()));
internalPrincipal.setPermissions(internalPermissions);
- tx.commit();
+
+ getPersistenceBrokerTemplate().store(internalPrincipal);
}
catch (Exception e)
{
String msg = "Unable to lock Principal for update.";
- log.error(msg, e);
- persistenceStore.getTransaction().rollback();
+ logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
@@ -391,18 +356,15 @@
{
try
{
- Transaction tx = persistenceStore.getTransaction();
- tx.begin();
- persistenceStore.lockForWrite(internalPrincipal);
internalPrincipal.setModifiedDate(new
Timestamp(System.currentTimeMillis()));
internalPrincipal.setPermissions(newInternalPermissions);
- tx.commit();
+
+ getPersistenceBrokerTemplate().store(internalPrincipal);
}
catch (Exception e)
{
String msg = "Unable to lock principal for update.";
- log.error(msg, e);
- persistenceStore.getTransaction().rollback();
+ logger.error(msg, e);
throw new SecurityException(msg, e);
}
}
@@ -420,10 +382,10 @@
*/
InternalPrincipal getInternalPrincipal(String fullPath)
{
- Filter filter = persistenceStore.newFilter();
+ Criteria filter = new Criteria();
filter.addEqualTo("fullPath", fullPath);
- Object query = persistenceStore.newQuery(InternalPrincipalImpl.class,
filter);
- InternalPrincipal internalPrincipal = (InternalPrincipal)
persistenceStore.getObjectByQuery(query);
+ Query query = QueryFactory.newQuery(InternalPrincipalImpl.class, filter);
+ InternalPrincipal internalPrincipal = (InternalPrincipal)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalPrincipal;
}
@@ -437,12 +399,12 @@
*/
InternalPermission getInternalPermission(Permission permission)
{
- Filter filter = persistenceStore.newFilter();
+ Criteria filter = new Criteria();
filter.addEqualTo("classname", permission.getClass().getName());
filter.addEqualTo("name", permission.getName());
filter.addEqualTo("actions", permission.getActions());
- Object query = persistenceStore.newQuery(InternalPermissionImpl.class,
filter);
- InternalPermission internalPermission = (InternalPermission)
persistenceStore.getObjectByQuery(query);
+ Query query = QueryFactory.newQuery(InternalPermissionImpl.class, filter);
+ InternalPermission internalPermission = (InternalPermission)
getPersistenceBrokerTemplate().getObjectByQuery(query);
return internalPermission;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]