Spring Security 2ΒΆ

See also

spring-security.xml
LoginAction.java

classes, interfaces:

[I] org.springframework.security.Authentication
[I] org.springframework.security.providers.AuthenticationProvider
[I] org.springframework.security.userdetails.UserDetails
[I] org.springframework.security.userdetails.UserDetailsService
[I] org.springframework.security.userdetails.AuthenticationUserDetailsService

// the object containing the Authentication object
[C] org.springframework.security.context.SecurityContextHolder

// credential check non required
[C] org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationProvider [I AuthenticationProvider]
[C] org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationToken [I Authentication]

// credential check required
[C] org.springframework.security.providers.dao.DaoAuthenticationProvider [I AuthenticationProvider]
[C] org.springframework.security.providers.UsernamePasswordAuthenticationToken [I Authentication]

// anonymous user access no credential check ( not used )
[C] org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider
[C] org.springframework.security.providers.anonymous.AnonymousAuthenticationToken

[C] org.springframework.security.providers.ProviderManager // the object containing the Authentication object

[I] sangah.security.service.UserService
[C] sangah.security.service.UserServiceImpl ( CRUD implementation for user )

[I] sangah.security.UserProfile
[C] sangah.security.UserProfileImpl (  )

example:

// pre authenticated user ( credential check not required )
Authentication auth = new PreAuthenticatedAuthenticationToken([userid], [password]);
auth = preAuthAuthenticationProvider.authenticate(auth);

// user to be authenticated ( credential check required )
auth = new UsernamePasswordAuthenticationToken( new UserProfileImpl( [userid], [password] ), [password] );
auth = authenticationProvider.authenticate( auth );

if( auth != null && auth.isAuthenticated() ){
    SecurityContextHolder.getContext().setAuthentication( auth );
}

reference: