1 /* 2 * Copyright 2002-2009 the original author or authors. 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.springframework.ws.soap.security.support; 18 19 import org.acegisecurity.AccountExpiredException; 20 import org.acegisecurity.CredentialsExpiredException; 21 import org.acegisecurity.DisabledException; 22 import org.acegisecurity.LockedException; 23 import org.acegisecurity.userdetails.UserDetails; 24 25 /** 26 * Generic utility methods for Spring Security 27 * 28 * @author Tareq Abedrabbo 29 * @since 1.5.8 30 * @deprecated As of Spring-WS 1.5, in favor of Spring Security 31 */ 32 public abstract class AcegiUtils { 33 34 /** 35 * Checks the validity of a user's account and credentials. 36 * 37 * @param user the user to check 38 * @throws org.springframework.security.AccountExpiredException 39 * if the account has expired 40 * @throws org.springframework.security.CredentialsExpiredException 41 * if the credentials have expired 42 * @throws org.springframework.security.DisabledException 43 * if the account is disabled 44 * @throws org.springframework.security.LockedException 45 * if the account is locked 46 */ 47 public static void checkUserValidity(UserDetails user) 48 throws AccountExpiredException, CredentialsExpiredException, DisabledException, LockedException { 49 if (!user.isAccountNonLocked()) { 50 throw new LockedException("User account is locked"); 51 } 52 53 if (!user.isEnabled()) { 54 throw new DisabledException("User is disabled"); 55 } 56 57 if (!user.isAccountNonExpired()) { 58 throw new AccountExpiredException("User account has expired"); 59 } 60 61 if (!user.isCredentialsNonExpired()) { 62 throw new CredentialsExpiredException("User credentials have expired"); 63 } 64 } 65 }