Sample Spring MVC App with Security

Mar 9, 2011 at 2:00 PM

I've created a very simple Spring 3.0 MVC application that uses Spring Security and Waffle. I'd be glad to upload the zip file of the project if there is a place I can put it.

Here is the test.jsp page I wrote that shows all the authorities for the logged in user.

<%@ page import="java.security.Principal,org.apache.catalina.realm.GenericPrincipal,org.springframework.security.core.*,java.util.Collection" %>
<html>
 <body>
  Hello, <%= request.getUserPrincipal().getName() %>
  <%
  		System.out.println(request.getUserPrincipal().getClass().getSimpleName());
        Authentication token = (Authentication) request.getUserPrincipal();
        Collection<GrantedAuthority> roles = token.getAuthorities();
        out.println("<p>You have " + roles.size() + " role(s).</p>");
        out.println("<ul>");
        for(GrantedAuthority role : roles) {
                out.println("<li>" + role);
        }
        out.println("</ul>");
  %>
 </body>
</html>

If anyone is interested I started with the STS 2.5.2 MVC template and then added the waffle-spring-filter configuration files. I modified the Home controller to show either the standard waffle index.jsp page or my test.jsp page (above) that shows all the authorities.

Bob Fleischman

Coordinator
Mar 11, 2011 at 1:07 PM

If you want to add a working sample to Waffle proper, upload a patch. There're a few in Source\JNAWindowsAuthProvider\demo. Otherwise, maybe a tutorial on your blog and the source in some repository or a CodeProject article could be great! Thx.

Mar 17, 2011 at 3:45 PM

I’m a bit too busy right now to right this up, but here is the Eclipse Project zipped up.

From: dblock [email removed]
Sent: Friday, March 11, 2011 9:07 AM
To: Fleischman, Robert
Subject: Re: Sample Spring MVC App with Security [waffle:249027]

From: dblock

If you want to add a working sample to Waffle proper, upload a patch. There're a few in Source\JNAWindowsAuthProvider\demo. Otherwise, maybe a tutorial on your blog and the source in some repository or a CodeProject article could be great! Thx.




For more information about Duane Morris, please visit http://www.DuaneMorris.com


Confidentiality Notice: This electronic mail transmission is privileged and confidential and is intended only for the review of the party to whom it is addressed. If you have received this transmission in error, please immediately return it to the sender. Unintended transmission shall not constitute waiver of the attorney-client or any other privilege.
Coordinator
Mar 17, 2011 at 10:50 PM

CodePlex strips attachments. Can you please create a feature request and attach the zip to it? Thx.

Mar 18, 2011 at 2:55 PM

I just uploaded it

Work Item Details

Item #

10484

Status

Proposed

Type

Issue

Impact

Low

Release

Unassigned

Assigned To

Unassigned

Component

No Component Selected

Reported On

Today at 10:51 AM

Reported By

BobFleischman

Updated On

Today at 10:51 AM

Updated By

BobFleischman

Closed On

n/a

Closed By

n/a

Wiki Link

[workitem:10484]

From: dblock [email removed]
Sent: Thursday, March 17, 2011 6:51 PM
To: Fleischman, Robert
Subject: Re: Sample Spring MVC App with Security [waffle:249027]

From: dblock

CodePlex strips attachments. Can you please create a feature request and attach the zip to it? Thx.




For more information about Duane Morris, please visit http://www.DuaneMorris.com


Confidentiality Notice: This electronic mail transmission is privileged and confidential and is intended only for the review of the party to whom it is addressed. If you have received this transmission in error, please immediately return it to the sender. Unintended transmission shall not constitute waiver of the attorney-client or any other privilege.