1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.ws.soap.security.support;
17
18 import org.springframework.security.core.userdetails.UserDetails;
19 import org.springframework.security.authentication.LockedException;
20 import org.springframework.security.authentication.DisabledException;
21 import org.springframework.security.authentication.AccountExpiredException;
22 import org.springframework.security.authentication.CredentialsExpiredException;
23
24
25
26
27
28
29
30 public abstract class SpringSecurityUtils {
31
32
33
34
35
36
37
38
39
40 public static void checkUserValidity(UserDetails user)
41 throws AccountExpiredException, CredentialsExpiredException, DisabledException, LockedException {
42 if (!user.isAccountNonLocked()) {
43 throw new LockedException("User account is locked", user);
44 }
45
46 if (!user.isEnabled()) {
47 throw new DisabledException("User is disabled", user);
48 }
49
50 if (!user.isAccountNonExpired()) {
51 throw new AccountExpiredException("User account has expired", user);
52 }
53
54 if (!user.isCredentialsNonExpired()) {
55 throw new CredentialsExpiredException("User credentials have expired", user);
56 }
57 }
58 }