Thanks a million Erik. This will really help me to get going.
I really appreciate your quick response.
Sunraider
Erik van Oosten wrote:
>
> Hi,
>
> Here is an example (we're using wicket-auth-roles).
> We use Spring to inject the authentication manager into the application.
>
> Regards,
> Erik.
>
> --------------------------8<------------------------------------------
> public class MySession extends AuthenticatedWebSession {
>
> .. constructor, etc...
>
> /**
> * Attempts to authenticate a user that has provided the given
> username and password.
> * @param username current username
> * @param password current password
> * @return <code>true</code> if authentication succeeds,
> <code>false</code> otherwise
> */
> public boolean authenticate(String username, String password) {
> String u = username == null ? "" : username.trim();
> String p = password == null ? "" : password.trim();
>
> // Create an Acegi authentication request.
> UsernamePasswordAuthenticationToken authRequest = new
> UsernamePasswordAuthenticationToken(u, p);
>
> // Attempt authentication.
> try {
> AuthenticationManager authenticationManager =
> ((MyApplication)
> getApplication()).getAuthenticationManager();
> Authentication authResult =
> authenticationManager.authenticate(authRequest);
>
> SecurityContextHolder.getContext().setAuthentication(authResult);
> return true;
> } catch (AuthenticationException e) {
> // Clear the security context.
> SecurityContextHolder.getContext().setAuthentication(null);
> return false;
> }
> }
>
> /**
> * Returns the current user roles.
> * @return current user roles
> */
> public Roles getRoles() {
> if (isSignedIn()) {
> Roles roles = new Roles();
> // Retrieve the granted authorities from the current
> authentication. These correspond one on
> // one with user roles.
> GrantedAuthority[] authorities =
> SecurityContextHolder.getContext().getAuthentication().getAuthorities();
> for (int i = 0; i < authorities.length; i++) {
> GrantedAuthority authority = authorities[i];
> roles.add(authority.getAuthority());
> }
> return roles;
> }
> return null;
> }
> }
> --------------------------8<------------------------------------------
>
>
>
> sunraider schreef:
>> Can you give me a sample of how the authorizationstrategy can be plugged
>> in
>> for Acegi?
>>
>>
>
> --
> Erik van Oosten
> http://www.day-to-day-stuff.blogspot.com/
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
--
View this message in context:
http://www.nabble.com/Wicket-With-Acegi-tf2478230.html#a7007422
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user