@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); LDAPRoleServiceConfig ldapConfig = (LDAPRoleServiceConfig) config; if (!isEmpty(ldapConfig.getAdminGroup())) { this.adminGroup = ldapConfig.getAdminGroup(); } if (!isEmpty(ldapConfig.getGroupAdminGroup())) { this.groupAdminGroup = ldapConfig.getGroupAdminGroup(); } } /** Read only store. */
public LDAPSecurityServiceConfig(LDAPSecurityServiceConfig other) { super(other); userDnPattern = other.getUserDnPattern(); userGroupServiceName = other.getUserGroupServiceName(); userFormat = other.getUserFormat(); }
/** * We need to give authoritiesPopulator both username and password, so * it can bind to the LDAP server. */ @Override protected Collection<? extends GrantedAuthority> loadUserAuthorities( DirContextOperations userData, String username, String password) { return ((BindingLdapAuthoritiesPopulator) getAuthoritiesPopulator()) .getGrantedAuthorities(userData, username, password); } };
public LDAPBaseSecurityServiceConfig(LDAPBaseSecurityServiceConfig other) { super(other); serverURL = other.getServerURL(); groupSearchBase = other.getGroupSearchBase(); groupFilter = other.getGroupFilter(); adminGroup = other.getAdminGroup(); groupAdminGroup = other.getGroupAdminGroup(); bindBeforeGroupSearch = other.isBindBeforeGroupSearch(); userFilter = other.getUserFilter(); useTLS = other.isUseTLS(); user = other.getUser(); password = other.getPassword(); }
@Before public void createUserGroupService() throws Exception { config.setGroupNameAttribute("cn"); config.setUserSearchBase("ou=People"); config.setUserNameAttribute("uid"); config.setGroupSearchFilter("member={1},dc=example,dc=com"); ((LDAPUserGroupServiceConfig) config) .setPopulatedAttributes("sn, givenName, telephoneNumber, mail"); service = new LDAPUserGroupService(config); Assume.assumeTrue( LDAPTestUtils.initLdapServer(true, ldapServerUrl, basePath, "data4.ldif")); }
private void configureAuthentication() { ((LDAPRoleServiceConfig) config) .setUser( "uid=admin,ou=People,dc=example,dc=com"); // ("uid=admin,ou=People,dc=example,dc=com"); ((LDAPRoleServiceConfig) config).setPassword("admin"); config.setBindBeforeGroupSearch(true); }
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); LDAPUserGroupServiceConfig ldapConfig = ((LDAPUserGroupServiceConfig) config); passwordEncoderName = ldapConfig.getPasswordEncoderName(); passwordValidatorName = ldapConfig.getPasswordPolicyName(); if (!isEmpty(ldapConfig.getPopulatedAttributes())) { populatedAttributes = ldapConfig.getPopulatedAttributes().trim().split("[\\s]*,[\\s]*"); } }
/** * Initializes an in-memory LDAP server to use for testing. * * @param allowAnonymous anonymous access is allowed or not */ public static boolean initLdapServer( boolean allowAnonymous, String ldapServerUrl, String basePath) throws Exception { return initLdapServer(allowAnonymous, ldapServerUrl, basePath, "data.ldif"); }
private void createAuthenticationProvider() { authProvider = (LDAPAuthenticationProvider) securityProvider .createAuthenticationProvider(config); } }
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search(userSearchBase, propname + "=*", addToUsers(users)); } });
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search(groupSearchBase, allGroupsSearchFilter, counter(size)); } });
@Override public GeoServerRoleService createRoleService(SecurityNamedServiceConfig config) throws IOException { return new LDAPRoleService(); }
private void fillAllRoles(DirContext ctx, SortedSet<GeoServerRole> roles) { Set<String> roleNames = LDAPUtils.getLdapTemplateInContext(ctx, template) .searchForSingleAttributeValues( groupSearchBase, allGroupsSearchFilter, new String[] {}, groupNameAttribute); addRolesToSet(roles, roleNames); }
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search(groupSearchBase, allGroupsSearchFilter, counter(count)); } });
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { fillRolesForUser(ctx, username, lookupDn(username), roles); } });
/** * Shuts down the embedded server, if there is one. If no server was previously started in this * JVM this is silently ignored. * * @since 1.3.2 */ public static void shutdownEmbeddedServer() throws Exception { if (embeddedServer != null) { embeddedServer.shutdown(); embeddedServer = null; } }
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search( userSearchBase, "(&(!(" + propname + "=*))(" + allUsersSearchFilter + "))", addToUsers(users)); } });
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search(userSearchBase, propname + "=" + propvalue, counter(size)); } });
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search( userSearchBase, propname + "=" + propvalue, addToUsers(users)); } });
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { LDAPUtils.getLdapTemplateInContext(ctx, template) .search( userSearchBase, "(&(!(" + propname + "=*))(" + allUsersSearchFilter + "))", counter(size)); } });