1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services.security.nosecurity;
1819import java.util.Vector;
20import java.util.Iterator;
21import java.security.Principal;
2223// Turbine 24import org.apache.turbine.services.TurbineBaseService;
252627// Jetspeed Security28import org.apache.jetspeed.om.security.JetspeedUser;
2930import org.apache.jetspeed.services.security.UserManagement;
31import org.apache.jetspeed.services.security.nosecurity.FakeJetspeedUser;
3233import org.apache.jetspeed.services.security.CredentialsManagement;
34import org.apache.jetspeed.services.security.JetspeedSecurityException;
3536/***37 * <p> The <code>NoUserManagement</code> class is a Jetspeed38 * security provider, implementing the <code>UserManagement</code> and <code>CredentialsManagement</code>39 * interfaces. It does not manage any users - no users are listed, no users are saved, any40 * request for a user is satisfied with a temp. User object.41 *42 * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>43 * @version $Id: NoUserManagement.java,v 1.2 2004/02/23 03:53:24 jford Exp $44 */45publicclassNoUserManagement46extends TurbineBaseService
47 implements UserManagement, CredentialsManagement48 {
49/***50 * Retrieves a <code>JetspeedUser</code> given the primary principle.51 * The principal can be any valid Jetspeed Security Principal:52 * <code>org.apache.jetspeed.om.security.UserNamePrincipal</code>53 * <code>org.apache.jetspeed.om.security.UserIdPrincipal</code>54 * 55 * The security service may optionally check the current user context56 * to determine if the requestor has permission to perform this action.57 *58 * @param principal a principal identity to be retrieved.59 * @return a <code>JetspeedUser</code> associated to the principal identity.60 * @exception UserException when the security provider has a general failure retrieving a user.61 * @exception UnknownUserException when the security provider cannot match62 * the principal identity to a user.63 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 64 */65publicJetspeedUser getUser(Principal principal)
66 throws JetspeedSecurityException67 {
68// create a user object with this username for Jetspeed use69FakeJetspeedUser user = newFakeJetspeedUser(principal.getName(), false);
70return user;
71 }
7273/***74 * Retrieves a collection of all <code>JetspeedUser</code>s.75 * The security service may optionally check the current user context76 * to determine if the requestor has permission to perform this action.77 *78 * @return a collection of <code>JetspeedUser</code> entities.79 * @exception UserException when the security provider has a general failure retrieving users.80 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 81 */82public Iterator getUsers()
83 throws JetspeedSecurityException84 {
85returnnew Vector().iterator();
86 }
8788/***89 * Retrieves a collection of <code>JetspeedUser</code>s filtered by a security 90 * provider-specific query string. For example SQL, OQL, JDOQL.91 * The security service may optionally check the current user context92 * to determine if the requestor has permission to perform this action.93 *94 * @return a collection of <code>JetspeedUser</code> entities.95 * @exception UserException when the security provider has a general failure retrieving users.96 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 97 */98public Iterator getUsers(String filter)
99 throws JetspeedSecurityException100 {
101returnnew Vector().iterator();
102 }
103104/***105 * Saves a <code>JetspeedUser</code>'s attributes into permanent storage. 106 * The user's account is required to exist in the storage.107 * The security service may optionally check the current user context108 * to determine if the requestor has permission to perform this action.109 *110 * @exception UserException when the security provider has a general failure retrieving users.111 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 112 */113publicvoid saveUser(JetspeedUser user)
114 throws JetspeedSecurityException115 {
116 }
117118/***119 * Adds a <code>JetspeedUser</code> into permanent storage. 120 * The security service can throw a <code>NotUniqueUserException</code> when the public121 * credentials fail to meet the security provider-specific unique constraints.122 * The security service may optionally check the current user context123 * to determine if the requestor has permission to perform this action.124 *125 * @exception UserException when the security provider has a general failure retrieving users.126 * @exception NotUniqueUserException when the public credentials fail to meet 127 * the security provider-specific unique constraints.128 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 129 */130publicvoid addUser(JetspeedUser user)
131 throws JetspeedSecurityException132 {
133 }
134135/***136 * Removes a <code>JetspeedUser</code> from the permanent store.137 * The security service may optionally check the current user context138 * to determine if the requestor has permission to perform this action.139 *140 * @param principal the principal identity to be retrieved.141 * @exception UserException when the security provider has a general failure retrieving a user.142 * @exception UnknownUserException when the security provider cannot match143 * the principal identity to a user.144 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 145 */146publicvoid removeUser(Principal principal)
147 throws JetspeedSecurityException148 {
149 }
150151/***152 * Allows for a user to change their own password.153 *154 * @param user the user to change the password for.155 * @param oldPassword the current password supplied by the user.156 * @param newPassword the current password requested by the user.157 * @exception UserException when the security provider has a general failure retrieving a user.158 * @exception UnknownUserException when the security provider cannot match159 * the principal identity to a user.160 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 161 */162publicvoid changePassword( JetspeedUser user,
163 String oldPassword,
164 String newPassword )
165 throws JetspeedSecurityException166 {
167 }
168169/***170 * Forcibly sets new password for a User.171 *172 * Provides an administrator the ability to change the forgotten or173 * compromised passwords. Certain implementatations of this feature174 * would require administrative level access to the authenticating175 * server / program.176 * 177 * @param user the user to change the password for.178 * @param password the new password. 179 * @exception UserException when the security provider has a general failure retrieving a user.180 * @exception UnknownUserException when the security provider cannot match181 * the principal identity to a user.182 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 183 */184publicvoid forcePassword( JetspeedUser user, String password )
185 throws JetspeedSecurityException186 {
187 }
188189/***190 * This method provides client-side encryption of passwords.191 *192 * If <code>secure.passwords</code> are enabled in JetspeedSecurity properties,193 * the password will be encrypted, if not, it will be returned unchanged.194 * The <code>secure.passwords.algorithm</code> property can be used195 * to chose which digest algorithm should be used for performing the196 * encryption. <code>SHA</code> is used by default.197 *198 * @param password the password to process199 * @return processed password200 */201public String encryptPassword( String password )
202 throws JetspeedSecurityException203 {
204return password;
205 }
206 }
207