-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build against Spring Security #49
Changes from 2 commits
9bf71eb
bc478a4
c2cab64
6463be1
d600c62
5b3de91
7b876e8
f345adf
ffe7187
7dcddf3
03a4aaf
d62654c
a1f1f4d
d145884
17feb1a
8d576b9
0f8b360
9993b9b
a0943f4
270cffc
4b99b0b
c1e4287
8159c83
a9dc4e4
68f6252
c08f374
e7e4064
8ce42d8
b876e54
fdc1ec0
7c00268
87b0e14
53f75aa
74a81d6
f95183c
e15835f
474aa6d
4a3a73d
92b0950
321a357
e530174
e8a2a6a
2935db9
b994caf
9577fe6
69fa05a
f779469
5ae8750
03d10b1
93d8489
475a03b
d46b981
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
|
||
import hudson.Extension; | ||
import hudson.security.LDAPSecurityRealm; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
@@ -35,13 +36,12 @@ | |
import javax.naming.NamingException; | ||
import javax.naming.directory.Attributes; | ||
import javax.naming.ldap.LdapName; | ||
import org.acegisecurity.GrantedAuthority; | ||
import org.acegisecurity.ldap.LdapEntryMapper; | ||
import org.acegisecurity.providers.ldap.LdapAuthoritiesPopulator; | ||
import org.acegisecurity.userdetails.ldap.LdapUserDetails; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.springframework.dao.DataAccessException; | ||
import org.springframework.ldap.core.DirContextOperations; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.ldap.LdapUtils; | ||
import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator; | ||
|
||
/** | ||
* Traditional strategy. | ||
|
@@ -77,15 +77,15 @@ public void setAuthoritiesPopulator(LdapAuthoritiesPopulator authoritiesPopulato | |
} | ||
|
||
@Override | ||
public GrantedAuthority[] getGrantedAuthorities(LdapUserDetails ldapUser) { | ||
return getAuthoritiesPopulator().getGrantedAuthorities(ldapUser); | ||
public Collection<? extends GrantedAuthority> getGrantedAuthorities(DirContextOperations userData, String username) { | ||
return getAuthoritiesPopulator().getGrantedAuthorities(userData, username); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just trying to make something work. |
||
} | ||
|
||
@Override | ||
public Set<String> getGroupMembers(String groupDn, LDAPConfiguration conf) throws DataAccessException { | ||
public Set<String> getGroupMembers(String groupDn, LDAPConfiguration conf) { | ||
LDAPExtendedTemplate template = conf.getLdapTemplate(); | ||
String[] memberAttributes = { "member", "uniqueMember", "memberUid" }; | ||
return (Set<String>) template.retrieveEntry(groupDn, new GroupMembersMapper(), memberAttributes); | ||
return template.executeReadOnly(ctx -> new GroupMembersMapper().mapAttributes(groupDn, ctx.getAttributes(LdapUtils.getRelativeName(groupDn, ctx), memberAttributes))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just guessing here. Read only? Read write? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the calls should be read-only. The ldap plugin never writes in the remote ldap afair. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
⇒ #52 |
||
} | ||
|
||
@Extension | ||
|
@@ -100,7 +100,7 @@ public String getDisplayName() { | |
/** | ||
* Maps member attributes in groups to a set of member names. | ||
*/ | ||
private static class GroupMembersMapper implements LdapEntryMapper { | ||
private static class GroupMembersMapper implements LdapEntryMapper<Set<String>> { | ||
@Override | ||
public Set<String> mapAttributes(String dn, Attributes attributes) throws NamingException { | ||
NamingEnumeration<?> enumeration; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleBindException
is nowprotected
so no more need to align packages.