[java-identity-provider COMMIT] in /trunk/idp-authn-impl/src: main/java/net/shibboleth/idp/authn/impl/AbstractTemplat...
noreply at shibboleth.net
noreply at shibboleth.net
Mon May 9 22:30:10 EDT 2016
Author: dfisher
Date: Mon May 9 22:30:10 2016
New Revision: 8234
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8234&view=rev
Log:
IDP-827 - Velocity support for auth filter
Add template based search dn resolver implementations.
Update LDAP auth to pass velocity context.
Depends on ldaptive 1.0.8-SNAPSHOT.
Added:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/AbstractTemplateSearchDnResolver.java
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PooledTemplateSearchDnResolver.java
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/TemplateSearchDnResolver.java
Modified:
trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java
trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java
Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java?rev=8234&r1=8233&r2=8234&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java (original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAP.java Mon May 9 22:30:10 2016
@@ -30,6 +30,7 @@
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import org.apache.velocity.VelocityContext;
import org.ldaptive.Credential;
import org.ldaptive.LdapException;
import org.ldaptive.ResultCode;
@@ -38,6 +39,7 @@
import org.ldaptive.auth.AuthenticationResponse;
import org.ldaptive.auth.AuthenticationResultCode;
import org.ldaptive.auth.Authenticator;
+import org.ldaptive.auth.User;
import org.ldaptive.jaas.LdapPrincipal;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
@@ -130,9 +132,11 @@
try {
log.debug("{} Attempting to authenticate user {}", getLogPrefix(), getUsernamePasswordContext()
.getUsername());
+ final VelocityContext context = new VelocityContext();
+ context.put("usernamePasswordContext", getUsernamePasswordContext());
final AuthenticationRequest request =
- new AuthenticationRequest(getUsernamePasswordContext().getUsername(), new Credential(
- getUsernamePasswordContext().getPassword()), returnAttributes);
+ new AuthenticationRequest(new User(getUsernamePasswordContext().getUsername(), context),
+ new Credential(getUsernamePasswordContext().getPassword()), returnAttributes);
response = authenticator.authenticate(request);
log.trace("{} Authentication response {}", getLogPrefix(), response);
if (response.getResult()) {
Modified: trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java?rev=8234&r1=8233&r2=8234&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java (original)
+++ trunk/idp-authn-impl/src/test/java/net/shibboleth/idp/authn/impl/ValidateUsernamePasswordAgainstLDAPTest.java Mon May 9 22:30:10 2016
@@ -33,6 +33,7 @@
import net.shibboleth.idp.authn.context.UsernamePasswordContext;
import net.shibboleth.idp.authn.principal.UsernamePrincipal;
import net.shibboleth.idp.profile.ActionTestingSupport;
+import net.shibboleth.utilities.java.support.velocity.VelocityEngine;
import org.ldaptive.DefaultConnectionFactory;
import org.ldaptive.LdapException;
@@ -65,12 +66,12 @@
public class ValidateUsernamePasswordAgainstLDAPTest extends BaseAuthenticationContextTest {
private static final String DATA_PATH = "src/test/resources/net/shibboleth/idp/authn/impl/";
-
+
private ValidateUsernamePasswordAgainstLDAP action;
private InMemoryDirectoryServer directoryServer;
- private SearchDnResolver dnResolver;
+ private TemplateSearchDnResolver dnResolver;
private BindAuthenticationHandler authHandler;
@@ -96,9 +97,9 @@
*/
@BeforeClass public void setupAuthenticator() {
- dnResolver = new SearchDnResolver(new DefaultConnectionFactory("ldap://localhost:10389"));
+ dnResolver = new TemplateSearchDnResolver(new DefaultConnectionFactory("ldap://localhost:10389"),
+ VelocityEngine.newVelocityEngine(), "(uid=$usernamePasswordContext.username)");
dnResolver.setBaseDn("ou=people,dc=shibboleth,dc=net");
[... 308 lines stripped ...]
More information about the commits
mailing list