You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/08/23 17:26:55 UTC
cvs commit: jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/manager TurbineUserManager.java
epugh 2003/08/23 08:26:55
Added: security/src/java/org/apache/fulcrum/security/model/simple/entity
SimpleUser.java SimpleGroup.java
SimplePermission.java SimpleRole.java
security/src/java/org/apache/fulcrum/security/model/turbine/entity
TurbineGroup.java TurbinePermission.java
TurbineRole.java TurbineUser.java
security/src/java/org/apache/fulcrum/security/model/simple/manager
SimpleUserManager.java SimpleRoleManager.java
SimpleGroupManager.java
security/src/java/org/apache/fulcrum/security/model/turbine/manager
TurbineUserManager.java
Log:
Refactored the packaging. Now there is a a model/ directory where the model lives,
and a spi/ where the various service providers live. I think this will allow better
mixing and matching of models and implementors. Also makes the names clearer.
Revision Changes Path
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/entity/SimpleUser.java
Index: SimpleUser.java
===================================================================
package org.apache.fulcrum.security.model.simple.entity;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.GroupSet;
/**
* @author Eric Pugh
*
* Represents the "simple" model where permissions are related to roles,
* roles are related to groups and groups are related to users,
* all in many to many relationships.
*/
public class SimpleUser extends SecurityEntityImpl implements User
{
private String password;
private GroupSet groups = new GroupSet();
/**
* @return
*/
public String getPassword()
{
return password;
}
/**
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* @return
*/
public GroupSet getGroups()
{
return groups;
}
/**
* @param groups
*/
public void setGroups(GroupSet groups)
{
this.groups = groups;
}
public void removeGroup(Group group)
{
getGroups().remove(group);
}
public void addGroup(Group group)
{
getGroups().add(group);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/entity/SimpleGroup.java
Index: SimpleGroup.java
===================================================================
package org.apache.fulcrum.security.model.simple.entity;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.RoleSet;
/**
* @author Eric Pugh
*
* Represents the "simple" model where permissions are related to roles,
* roles are related to groups and groups are related to users,
* all in many to many relationships.
*/
public class SimpleGroup extends SecurityEntityImpl implements Group
{
private RoleSet roleSet = new RoleSet();
/**
* @return
*/
public RoleSet getRoles()
{
return roleSet;
}
/**
* @param roleSet
*/
public void setRoles(RoleSet roleSet)
{
this.roleSet = roleSet;
}
public void addRole(Role role)
{
getRoles().add(role);
}
public void removeRole(Role role)
{
getRoles().remove(role);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/entity/SimplePermission.java
Index: SimplePermission.java
===================================================================
package org.apache.fulcrum.security.model.simple.entity;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
/**
* @author Eric Pugh
*
* Represents the "simple" model where permissions are related to roles,
* roles are related to groups and groups are related to users,
* all in many to many relationships.
*/
public class SimplePermission extends SecurityEntityImpl implements Permission
{
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/entity/SimpleRole.java
Index: SimpleRole.java
===================================================================
package org.apache.fulcrum.security.model.simple.entity;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.PermissionSet;
/**
* @author Eric Pugh
*
* Represents the "simple" model where permissions are related to roles,
* roles are related to groups and groups are related to users,
* all in many to many relationships.
*/
public class SimpleRole extends SecurityEntityImpl implements Role
{
private PermissionSet permissionSet = new PermissionSet();
/**
* @return
*/
public PermissionSet getPermissions()
{
return permissionSet;
}
/**
* @param permissionSet
*/
public void setPermissions(PermissionSet permissionSet)
{
this.permissionSet = permissionSet;
}
public void addPermission(Permission permission)
{
getPermissions().add(permission);
}
public void removePermission(Permission permission)
{
getPermissions().remove(permission);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineGroup.java
Index: TurbineGroup.java
===================================================================
package org.apache.fulcrum.security.model.turbine.entity;
import java.util.HashSet;
import java.util.Set;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.RoleSet;
/**
* @author Eric Pugh
*
* Represents the "turbine" model where there is a many to many to many
* relationship between users, groups, and roles.
*/
public class TurbineGroup extends SecurityEntityImpl implements Group
{
private RoleSet roleSet = new RoleSet();
private Set users = new HashSet();
/**
* @return
*/
public Set getUsers()
{
return users;
}
/**
* @param users
*/
public void setUsers(Set users)
{
this.users = users;
}
/**
* @return
*/
public RoleSet getRoles()
{
return roleSet;
}
/**
* @param roleSet
*/
public void setRoles(RoleSet roleSet)
{
this.roleSet = roleSet;
}
public void addRole(Role role)
{
getRoles().add(role);
}
public void removeRole(Role role)
{
getRoles().remove(role);
}
public void addUser(User user)
{
getUsers().add(user);
}
public void removeUser(User user)
{
getUsers().remove(user);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java
Index: TurbinePermission.java
===================================================================
package org.apache.fulcrum.security.model.turbine.entity;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
/**
* @author Eric Pugh
*
* Represents the "turbine" model where there is a many to many to many
* relationship between users, groups, and roles.
*/
public class TurbinePermission extends SecurityEntityImpl implements Permission
{
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java
Index: TurbineRole.java
===================================================================
package org.apache.fulcrum.security.model.turbine.entity;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.GroupSet;
import org.apache.fulcrum.security.util.PermissionSet;
/**
* @author Eric Pugh
*
* Represents the "turbine" model where there is a many to many to many
* relationship between users, groups, and roles.
*/
public class TurbineRole extends SecurityEntityImpl implements Role
{
private GroupSet groupSet = new GroupSet();
private PermissionSet permissionSet = new PermissionSet();
/**
* @return
*/
public PermissionSet getPermissions()
{
return permissionSet;
}
/**
* @param permissionSet
*/
public void setPermissions(PermissionSet permissionSet)
{
this.permissionSet = permissionSet;
}
/**
* @return
*/
GroupSet getGroups()
{
return groupSet;
}
/**
* @param groupSet
*/
void setGroups(GroupSet groupSet)
{
this.groupSet = groupSet;
}
public void addPermission(Permission permission)
{
getPermissions().add(permission);
}
public void removePermission(Permission permission)
{
getPermissions().remove(permission);
}
public void addGroup(Group group)
{
getGroups().add(group);
}
public void removeGroup(Group group)
{
getGroups().remove(group);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUser.java
Index: TurbineUser.java
===================================================================
package org.apache.fulcrum.security.model.turbine.entity;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.entity.impl.SecurityEntityImpl;
import org.apache.fulcrum.security.util.GroupSet;
import org.apache.fulcrum.security.util.RoleSet;
/**
* @author Eric Pugh
*
* Represents the "turbine" model where there is a many to many to many
* relationship between users, groups, and roles.
*/
public class TurbineUser extends SecurityEntityImpl implements User
{
private GroupSet groups = new GroupSet();
private RoleSet roles = new RoleSet();
private String password;
/**
* @return
*/
public String getPassword()
{
return password;
}
/**
* @param password
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* @return
*/
RoleSet getRoles()
{
return roles;
}
/**
* @param roles
*/
void setRoles(RoleSet roles)
{
this.roles = roles;
}
public void addRole(Role role)
{
getRoles().add(role);
}
public void removeRole(Role role)
{
getRoles().remove(role);
}
/**
* @return
*/
public GroupSet getGroups()
{
return groups;
}
/**
* @param groups
*/
public void setGroups(GroupSet groups)
{
this.groups = groups;
}
public void removeGroup(Group group)
{
getGroups().remove(group);
}
public void addGroup(Group group)
{
getGroups().add(group);
}
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/manager/SimpleUserManager.java
Index: SimpleUserManager.java
===================================================================
package org.apache.fulcrum.security.model.simple.manager;
import org.apache.fulcrum.security.UserManager;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.UnknownEntityException;
/**
* @author Eric Pugh
*
*/
public interface SimpleUserManager extends UserManager
{
/**
* Puts a user in a group.
*
* This method is used when adding a user to a group
*
* @param user the User.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the account is not present.
*/
void grant(User user, Group group) throws DataBackendException, UnknownEntityException;
/**
* Removes a user from a group
*
*
* @param user the User.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the user or group is not present.
*/
void revoke(User user, Group group) throws DataBackendException, UnknownEntityException;
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/manager/SimpleRoleManager.java
Index: SimpleRoleManager.java
===================================================================
package org.apache.fulcrum.security.model.simple.manager;
import org.apache.fulcrum.security.RoleManager;
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.UnknownEntityException;
/**
* @author Eric Pugh
*
*/
public interface SimpleRoleManager extends RoleManager
{
/**
* Puts a permission in a role
*
* This method is used when adding a permission to a role
*
* @param user the User.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the account is not present.
*/
void grant(Role role, Permission permission) throws DataBackendException, UnknownEntityException;
/**
* Removes a permission from a role
*
*
* @param role the Role.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the user or group is not present.
*/
void revoke(Role role, Permission permission) throws DataBackendException, UnknownEntityException;
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/simple/manager/SimpleGroupManager.java
Index: SimpleGroupManager.java
===================================================================
package org.apache.fulcrum.security.model.simple.manager;
import org.apache.fulcrum.security.GroupManager;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.UnknownEntityException;
/**
* @author Eric Pugh
*
*/
public interface SimpleGroupManager extends GroupManager
{
/**
* Puts a role into a group
*
* This method is used when adding a role to a group.
*
* @param group the group to use
* @param role the role that will join the group
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the group or role is not present.
*/
void grant(Group group, Role role) throws DataBackendException, UnknownEntityException;
/**
* Remove a role from a group
*
* This method is used when removeing a role to a group.
*
* @param group the group to use
* @param role the role that will join the group
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if the group or role is not present.
*/
void revoke(Group group, Role role) throws DataBackendException, UnknownEntityException;
}
1.1 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/model/turbine/manager/TurbineUserManager.java
Index: TurbineUserManager.java
===================================================================
package org.apache.fulcrum.security.model.turbine.manager;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import org.apache.fulcrum.security.UserManager;
import org.apache.fulcrum.security.entity.Group;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.UnknownEntityException;
/**
* This User managers adds the Torque Criteria class and listUsers.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id: TurbineUserManager.java,v 1.1 2003/08/23 15:26:55 epugh Exp $
*/
public interface TurbineUserManager extends UserManager
{
/**
* Constructs an User object to represent an anonymous user of the
* application.
*
* @return An anonymous Turbine User.
* @throws UnknownEntityException if the anonymous User object couldn't be
* constructed.
*/
User getAnonymousUser() throws UnknownEntityException;
/**
* Checks whether a passed user object matches the anonymous user pattern
* according to the configured user manager
*
* @param An user object
*
* @return True if this is an anonymous user
*
*/
boolean isAnonymousUser(User u);
/**
* Grant an User a Role in a Group.
*
* @param user the user.
* @param group the group.
* @param role the role.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if user account, group or role is not
* present.
*/
void grant(User user, Group group, Role role) throws DataBackendException, UnknownEntityException;
/**
* Revoke a Role in a Group from an User.
*
* @param user the user.
* @param group the group.
* @param role the role.
* @throws DataBackendException if there was an error accessing the data
* backend.
* @throws UnknownEntityException if user account, group or role is not
* present.
*/
void revoke(User user, Group group, Role role) throws DataBackendException, UnknownEntityException;
}