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 at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * 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 and 14 * limitations under the License. 15 */ 16 17 package org.apache.jetspeed.services; 18 19 import java.util.Iterator; 20 import java.security.Principal; 21 22 // Turbine 23 import org.apache.turbine.services.TurbineServices; 24 25 // Jetspeed 26 import org.apache.jetspeed.om.security.JetspeedUser; 27 import org.apache.jetspeed.services.security.UserManagement; 28 import org.apache.jetspeed.services.security.JetspeedSecurityException; 29 30 31 32 /*** 33 * Static accessor for the PortalAccessController service 34 * 35 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> 36 * @version $Id: JetspeedUserManagement.java,v 1.4 2004/02/23 04:00:57 jford Exp $ 37 */ 38 public abstract class JetspeedUserManagement 39 { 40 41 /* 42 * Utility method for accessing the service 43 * implementation 44 * 45 * @return a UserManagement implementation instance 46 */ 47 protected static UserManagement getService() 48 { 49 return (UserManagement)TurbineServices 50 .getInstance().getService(UserManagement.SERVICE_NAME); 51 } 52 53 /*** 54 * @see org.apache.jetspeed.services.security.UserManagement#getUser 55 */ 56 public static JetspeedUser getUser(Principal principal) 57 throws JetspeedSecurityException 58 { 59 return getService().getUser(principal); 60 } 61 62 /*** 63 * @see org.apache.jetspeed.services.security.UserManagement#getUsers 64 */ 65 public static Iterator getUsers() 66 throws JetspeedSecurityException 67 { 68 return getService().getUsers(); 69 } 70 71 /*** 72 * @see org.apache.jetspeed.services.security.UserManagement#getUsers 73 */ 74 public static Iterator getUsers(String filter) 75 throws JetspeedSecurityException 76 { 77 return getService().getUsers(filter); 78 } 79 80 /*** 81 * @see org.apache.jetspeed.services.security.UserManagement#saveUser 82 */ 83 public static void saveUser(JetspeedUser user) 84 throws JetspeedSecurityException 85 { 86 getService().saveUser(user); 87 } 88 89 /*** 90 * @see org.apache.jetspeed.services.security.UserManagement#addUser 91 */ 92 public static void addUser(JetspeedUser user) 93 throws JetspeedSecurityException 94 { 95 getService().addUser(user); 96 } 97 98 /*** 99 * @see org.apache.jetspeed.services.security.UserManagement#removeUser 100 */ 101 public static void removeUser(Principal principal) 102 throws JetspeedSecurityException 103 { 104 getService().removeUser(principal); 105 } 106 107 /////////////////////////////////////////////////////////////////////// 108 // Credentials Management 109 ////////////////////////////////////////////////////////////////////// 110 111 /*** 112 * @see org.apache.jetspeed.services.security.UserManagement#changePassword 113 */ 114 public static void changePassword( JetspeedUser user, 115 String oldPassword, 116 String newPassword ) 117 throws JetspeedSecurityException 118 { 119 getService().changePassword(user, oldPassword, newPassword); 120 } 121 122 /*** 123 * @see org.apache.jetspeed.services.security.UserManagement#forcePassword 124 */ 125 public static void forcePassword( JetspeedUser user, String password ) 126 throws JetspeedSecurityException 127 { 128 getService().forcePassword(user, password); 129 } 130 131 132 /*** 133 * @see org.apache.jetspeed.services.security.UserManagement#encryptPassword 134 */ 135 public static String encryptPassword( String password ) 136 throws JetspeedSecurityException 137 { 138 return getService().encryptPassword(password); 139 } 140 141 } 142