java - Spring LDAP Authentication (Automatic or not?) -
i read through spring ldap reference docs , unable figure out whether user authentication against ldap server automated or not.
by "automated" mean happens automatically on bean instantiation if provide userdn , password in contextsource
. say, programmer never has call ldaptemplate.authenticate(...)
- happens "behind-the-scenes".
so know
- if spring ldap authentication automatic
- if there fields can set change behavior
thanks,
ktm
edit: ask question in context of code wrote. following contextsource
1 of context sources in beans file, user can opt use. used configure userdn , password @ runtime (for security reasons). want know whether ldap application use userdn/password collect @ runtime in authentication. (does authentication precede execution of code? ignore userdn/password fields code configures?)
public class runtimecontext extends ldapcontextsource { public runtimecontext() { super(); if (!resolveauthinfo()) { system.out.println("failed resolve auth info. exiting..."); system.exit(1); } } public boolean resolveauthinfo() { string myuserdn, mypassword; try { bufferedreader br = new bufferedreader( new inputstreamreader(system.in)); system.out.print("userdn: "); myuserdn = br.readline(); system.out.print("password: "); mypassword = br.readline(); } catch (ioexception e) { return false; } super.setuserdn(myuserdn); super.setpassword(mypassword); return true; } }
i want know whether ldap application use userdn/password collect @ runtime in authentication.
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html
it use userdn , password collect @ runtime. based on how configure beans, ldap authentication use 1 of 2 paths in spring:
- bind authentication (using
bindauthenticator
) - password comparison (using
passwordcomparisonauthenticator
)
these authenticators called within context of ldapauthenticationprovider
can configured authenticator in security namespace configuration:
<authentication-manager alias="authenticationmanager"> <authentication-provider user-service-ref="usernamepassworduserdetailsservice"> <password-encoder ref="passwordencoder"> <salt-source ref="saltsource"/> </password-encoder> </authentication-provider> <authentication-provider ref="ldapauthenticationprovider"/> </authentication-manager>
when usernamepasswordauthenticationfilter
invoked (via /auth/login page):
<http auto-config="true"> <form-login login-page="/auth/login" login-processing-url="/auth/j_security_check"/> <logout invalidate-session="true" logout-url="/auth/logout"/> </http>
a token created username , password. ldapauthenticationprovider
responds token type:
public class ldapauthenticationprovider implements authenticationprovider, messagesourceaware { ... public boolean supports(class<?> authentication) { return (usernamepasswordauthenticationtoken.class.isassignablefrom(authentication)); } }
and uses information stored in ldapcontextsource
authentication.
Comments
Post a Comment