I am using vaadin UI library in my project. I want to implement that on form submit (button click) spring-saml extension will check if user is authenticated. If not it will redirect to authetication form. For this reason i use code snippet below:
The authenticationManager I describe in securityContext.xml:Code:public void onLogin(LoginEvent event) { if (event.getLoginParameter("username").isEmpty() || event.getLoginParameter("password").isEmpty()) { getWindow().showNotification("Please enter username and password", Notification.TYPE_ERROR_MESSAGE); } else { try { SpringContextHelper helper = new SpringContextHelper(getApplication()); authenticationManager = (ProviderManager)helper.getBean("authenticationManager"); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(event.getLoginParameter("username"), event.getLoginParameter("password")); Authentication authentication = authenticationManager.authenticate(token); //exception comes here SecurityContextHolder.getContext().setAuthentication(authentication); authentication.getDetails(); } catch (Exception e) { getWindow().showNotification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } }
So when I push the button I got "No AuthenticationProvider found for UsernamePasswordAuthenticationToken" exception. It looks like that calss SAMLAuthenticationProvider cannot be resolved. So what i am doing wrong? Maybe I am doing bad conversion from (ProviderManager)helper.getBean("authenticationMan ager");. Maybe I should use something like that (SAMLAuthenticationManager)helper.getBean("authent icationManager");. But I can't find such class SAMLAuthenticationManager. Or maybe It is impossible to do such thing in way that I do. I am new to spring and spring security sorry if the questions looks dumb.Code:<context:annotation-config/> <context:component-scan base-package="org.springframework.security.saml"/> <security:authentication-manager alias="authenticationManager"> <security:authentication-provider ref="samlAuthenticationProvider"/> </security:authentication-manager> <bean id="samlAuthenticationProvider" class="org.springframework.security.saml.SAMLAuthenticationProvider"> <!-- OPTIONAL property: can be used to store/load user data after login --> <!-- <property name="userDetails" ref="bean" /> --> </bean>


Reply With Quote
ort/context/saml/login which will typically (depending on configuration) initialize login with your default IDP.