Tuesday, May 17, 2011

Spring Security and CAS Integration with Vaadin

We have been working with Vaadin for some time now. We have done multiple websites and admin applications. There was a customer who requested a SSO (Single Sign On) to be added to one of the new website we are creating. So we thought its not that big of a deal; we just needed to add Spring security and then do the CAS filter and we are all done. Well the solution is striaght forward but don't even try to search this on the web, there is not even one fully integrated working solution out there, so what I did was I sat down and did a Vaadin wrapper with spring security integrated. I have used Spring 3.0.5 so all spring security tags are written for that.

This is how it looked like in the end

public class SampleVaadinApplication extends VaadinApplication {

    private UriFragmentUtility fragmentUtility;
    private VerticalLayout layout;

    public void init() {
        final Window mainWindow = new Window("Vaadin Cas Sample");
        fragmentUtility = new UriFragmentUtility();
        layout = new VerticalLayout();

public void buttonClick(Button.ClickEvent event) {
     final String path = getURL().getPath();
     if (!hasAnyRole("ROLE_DEFAULT_ACCESS")) {
        getMainWindow().open(new ExternalResource(path + "do-something/"));
     } else {

web.xml you just need to add this to be the wrapper (and of cos the spring tags ;) ).



I have hosted it in git you can have a look at the sample to get your self up and running.


  1. I compile the core and the sample and obtain when push the Do Someting button:

    State HTTP 404 - /cas/login
    El recurso requerido (/cas/login) no está disponible.

  2. Sorry for my previous problem, I didn't have the CAS service running at the same port with your default configuration ;) good work

  3. Could you please add a License to it. (preferably Apache/BSD). Until you do that nobody can safely use your example.

  4. Licence file added. Now you can go ahead and do anything you like ;)

  5. The King Casino - Herzaman in the Aztec City
    The King 바카라 사이트 Casino in Aztec City is the place where you can find and play for real, real money. worrione.com Enjoy titanium metal trim a memorable stay at herzamanindir.com/ this one-of-a-kind casino