37
37
import java .nio .file .attribute .PosixFilePermission ;
38
38
import jenkins .model .IdStrategy ;
39
39
import jenkins .model .Jenkins ;
40
- import org .acegisecurity .AuthenticationException ;
41
- import org .acegisecurity .BadCredentialsException ;
42
- import org .acegisecurity .GrantedAuthority ;
43
- import org .acegisecurity .GrantedAuthorityImpl ;
44
- import org .acegisecurity .userdetails .User ;
45
- import org .acegisecurity .userdetails .UserDetails ;
46
- import org .acegisecurity .userdetails .UsernameNotFoundException ;
47
40
48
41
import org .jvnet .libpam .PAM ;
49
42
import org .jvnet .libpam .PAMException ;
50
43
import org .jvnet .libpam .UnixUser ;
51
44
import org .kohsuke .stapler .DataBoundConstructor ;
52
45
import org .kohsuke .stapler .interceptor .RequirePOST ;
53
- import org .springframework .dao .DataAccessException ;
46
+ import org .springframework .security .authentication .BadCredentialsException ;
47
+ import org .springframework .security .core .AuthenticationException ;
48
+ import org .springframework .security .core .GrantedAuthority ;
49
+ import org .springframework .security .core .authority .SimpleGrantedAuthority ;
50
+ import org .springframework .security .core .userdetails .User ;
51
+ import org .springframework .security .core .userdetails .UserDetails ;
52
+ import org .springframework .security .core .userdetails .UsernameNotFoundException ;
54
53
55
54
import java .io .File ;
55
+ import java .util .ArrayList ;
56
+ import java .util .Collection ;
56
57
import java .util .Set ;
57
58
import java .util .logging .Logger ;
58
59
@@ -78,7 +79,7 @@ public PAMSecurityRealm(String serviceName) {
78
79
}
79
80
80
81
@ Override
81
- protected synchronized UserDetails authenticate (String username , String password ) throws AuthenticationException {
82
+ protected synchronized UserDetails authenticate2 (String username , String password ) throws AuthenticationException {
82
83
try {
83
84
UnixUser u = new PAM (serviceName ).authenticate (username , password );
84
85
@@ -90,7 +91,7 @@ protected synchronized UserDetails authenticate(String username, String password
90
91
}
91
92
92
93
@ Override
93
- public UserDetails loadUserByUsername (String username ) throws UsernameNotFoundException , DataAccessException {
94
+ public UserDetails loadUserByUsername2 (String username ) throws UsernameNotFoundException {
94
95
if (!UnixUser .exists (username )) {
95
96
throw new UsernameNotFoundException ("No such Unix user: " + username );
96
97
}
@@ -103,19 +104,18 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
103
104
}
104
105
}
105
106
106
- private static GrantedAuthority [] toAuthorities (UnixUser u ) {
107
+ private static Collection <? extends GrantedAuthority > toAuthorities (UnixUser u ) {
107
108
Set <String > groups = u .getGroups ();
108
- GrantedAuthority [] authorities = new GrantedAuthority [groups .size () + 1 ];
109
- int i = 0 ;
109
+ Collection <GrantedAuthority > authorities = new ArrayList <>();
110
110
for (String group : groups ) {
111
- authorities [ i ++] = new GrantedAuthorityImpl (group );
111
+ authorities . add ( new SimpleGrantedAuthority (group ) );
112
112
}
113
- authorities [ i ] = AUTHENTICATED_AUTHORITY ;
113
+ authorities . add ( AUTHENTICATED_AUTHORITY2 ) ;
114
114
return authorities ;
115
115
}
116
116
117
117
@ Override
118
- public GroupDetails loadGroupByGroupname (String groupName ) throws UsernameNotFoundException , DataAccessException {
118
+ public GroupDetails loadGroupByGroupname2 (String groupName , boolean fetchMembers ) throws UsernameNotFoundException {
119
119
String group = groupName .startsWith ("@" ) ? groupName .substring (1 ) : groupName ;
120
120
121
121
try {
0 commit comments