<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>spring-security &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/spring-security/</link>
	<description>Feed of posts on WordPress.com tagged "spring-security"</description>
	<pubDate>Sun, 27 Dec 2009 04:31:15 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Spring security, DWR and session time out]]></title>
<link>http://adij.wordpress.com/2009/12/02/spring-security-dwr-and-session-time-out/</link>
<pubDate>Wed, 02 Dec 2009 05:51:32 +0000</pubDate>
<dc:creator>Adi</dc:creator>
<guid>http://adij.wordpress.com/2009/12/02/spring-security-dwr-and-session-time-out/</guid>
<description><![CDATA[In AJAX applications, using Spring security, handling session time out is a bit tricky. The problem ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In AJAX applications, using Spring security, handling session time out is a bit tricky. The problem is summarized <a href="http://forum.springsource.org/showthread.php?t=39574">here</a>. Fortunately with DWR it is easy. DWR provides a way to handle errors, exceptions etc globally. Check  more on this <a href="http://forum.springsource.org/showthread.php?t=39574">here </a>. As mentioned in the doc, you can use &#8216;textHtmlHandler&#8217; to handle session time out. Here is the snippet,</p>
<p>dwr.engine.setTextHtmlHandler(function() {</p>
<div id="_mcePaste">//If the current page is secure, Spring security redirects you to login page</div>
<div>document.location.reload(true);</div>
<div>//Or you can set the document.location to your login page.</div>
<div id="_mcePaste">})</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Spring Security 3 schema changes]]></title>
<link>http://deprecatedconsciousness.wordpress.com/2009/12/01/spring-security-3-schema-changes/</link>
<pubDate>Tue, 01 Dec 2009 18:16:41 +0000</pubDate>
<dc:creator>electrikmonk</dc:creator>
<guid>http://deprecatedconsciousness.wordpress.com/2009/12/01/spring-security-3-schema-changes/</guid>
<description><![CDATA[I was upgrading my application from Spring 2.5.6 + Spring Security 2.0.x to the latest 3.0 RC releas]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I was upgrading my application from Spring 2.5.6 + Spring Security 2.0.x to the latest 3.0 RC releases. After modifying my Maven pom.xml files to accomodate for the new artifact naming conventions, I still couldn&#8217;t get my application context to load due to a SAX exception:</p>
<pre class="brush: java;">
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 37 in XML document from class path resource [security-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'security:authentication-provider'.
</pre>
<p>I found myself spending almost an hour trying to figure out what&#8217;s wrong with my configuration file. Was I missing a JAR file? no, everything seems to be in its right place (you WILL want to make sure that you&#8217;re including spring-security-config.jar, though!), Eclipse didn&#8217;t detect anything wrong with the config file. In my despair, I turned to <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html">Security Namespace Configuration</a> chapter of the Spring Security 3 reference manual. There I noticed the following paragraph:</p>
<pre class="brush: xml;">
  &#60;authentication-manager&#62;
    &#60;authentication-provider&#62;
      &#60;user-service&#62;
        &#60;user name=&#34;jimi&#34; password=&#34;jimispassword&#34; authorities=&#34;ROLE_USER, ROLE_ADMIN&#34; /&#62;
        &#60;user name=&#34;bob&#34; password=&#34;bobspassword&#34; authorities=&#34;ROLE_USER&#34; /&#62;
      &#60;/user-service&#62;
    &#60;/authentication-provider&#62;
  &#60;/authentication-manager&#62;
</pre>
<p>Turning to my own configuration file, I saw this:</p>
<pre class="brush: xml;">
&#60;security:authentication-provider user-service-ref=&#34;userService&#34;&#62;
   &#60;security:password-encoder ref=&#34;passwordEncoder&#34;&#62;
      &#60;security:salt-source user-property=&#34;username&#34;/&#62;
   &#60;/security:password-encoder&#62;
&#60;/security:authentication-provider&#62;

&#60;security:authentication-manager alias=&#34;authenticationManager&#34;/&#62;
</pre>
<p>Apparently, while in Spring Security 2.x the <em>authentication-provider</em> tag used to be a root-level citizen, now it must live inside the <em>authentication-manager</em> definition.</p>
<p>I hope this will save some other folks some time when migrating to the 3.x Spring stack.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[LSNED 14: A minimal configuration for Spring Security IV]]></title>
<link>http://yaytay.wordpress.com/2009/11/17/lsned-14-a-minimal-configuration-for-spring-security-iv/</link>
<pubDate>Tue, 17 Nov 2009 09:11:32 +0000</pubDate>
<dc:creator>yaytay</dc:creator>
<guid>http://yaytay.wordpress.com/2009/11/17/lsned-14-a-minimal-configuration-for-spring-security-iv/</guid>
<description><![CDATA[Yesterday I got Struts working in separate sub folders of my domain. The reason for wanting to do th]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Yesterday I got Struts working in separate sub folders of my domain.<br />
The reason for wanting to do this is so that Spring Security can require specific roles to access the contents of those folders &#8211; and this is how I did that.</p>
<p>The simple bit is protecting the folder, by adding the /admin URL pattern to the applicationContext.xml:</p>
<pre class="brush: xml;">
    &#60;security:http&#62;
        &#60;security:intercept-url pattern=&#34;/login.jsp&#34; filters=&#34;none&#34; /&#62;
        &#60;security:intercept-url pattern=&#34;/bare/**&#34; filters=&#34;none&#34; /&#62;
        &#60;security:intercept-url pattern=&#34;/**&#34; access=&#34;ROLE_USER&#34; /&#62;
        &#60;security:intercept-url pattern=&#34;/admin/**&#34; access=&#34;ROLE_ADMIN&#34;/&#62;
        &#60;security:form-login login-page='/login.jsp' default-target-url='/index.action' always-use-default-target='true' authentication-failure-url=&#34;/login.jsp?error=true&#34; login-processing-url=&#34;/j_security_check&#34; /&#62;
        &#60;security:logout/&#62;
        &#60;!--&#60;remember-me/&#62;--&#62;
    &#60;/security:http&#62;
</pre>
<p>That&#8217;s all that&#8217;s needed to protect the folder, but it would be a pretty poor UI that invites users to do things that they aren&#8217;t allowed to do &#8211; so I wanted to change the links to the admin area to only be displayed if the user is in the ROLE_ADMIN role.<br />
Firstly I had to add the Spring Security taglib to my project by changing the maven pom.xml:</p>
<pre class="brush: xml;">
&#60;dependency&#62;
    &#60;groupId&#62;org.springframework.security&#60;/groupId&#62;
    &#60;artifactId&#62;spring-security-taglibs&#60;/artifactId&#62;
    &#60;version&#62;2.0.4&#60;/version&#62;
&#60;/dependency&#62;
</pre>
<p>Then in my jsp file (which happened to be the main decorator jsp file) I use the taglib:</p>
<pre class="brush: java;">
&#60;%@taglib prefix=&#34;sec&#34; uri=&#34;http://www.springframework.org/security/tags&#34; %&#62;
...
                    &#60;sec:authorize ifAllGranted=&#34;ROLE_ADMIN&#34;&#62;
                        &#60;li&#62;&#60;a href=&#34;users-list.action&#34;&#62;Users&#60;/a&#62;&#60;/li&#62;
                    &#60;/sec:authorize&#62;
...
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Spring Security 3.0 and JSR-286 Liferay Portlet]]></title>
<link>http://crabbake.wordpress.com/2009/10/22/spring-security-3-0-and-jsr-286-liferay-portlet/</link>
<pubDate>Thu, 22 Oct 2009 19:55:26 +0000</pubDate>
<dc:creator>crabbake</dc:creator>
<guid>http://crabbake.wordpress.com/2009/10/22/spring-security-3-0-and-jsr-286-liferay-portlet/</guid>
<description><![CDATA[Overview My current project is using Liferay 5.2.3 as a Portal container and Spring Security 3 to se]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Overview</h2>
<p>My current project is using Liferay 5.2.3 as a Portal container and Spring Security 3 to secure portlets.  We are not using Liferay&#8217;s built-in permission systems as we expect to deliver our portlets on many different portal platforms.  Therefore we decided to use Spring Security, specifically the 3.0 version, as Spring 3 supports the JSR-286 specification.</p>
<p>In the RC1 version of Spring Security 3.0 (SS3), the Portlet jar was dropped that was available in v2.0.5 (spring-security-portlet-2.0.x.jar).  That leaves us with a dilemma when it comes to securing portlets using SS3.  To implement security in a portlet in a JSR-168 context one would have to re-implement everything in the portlet jar to use an interceptor based way of adding an Authentication to the SecurityContext.</p>
<p>Rather than taking that path, Spring 3 supports JSR-286 portlet specification which allows for portlet filters.  Since a common way to implement security is through security filters, a portlet filter method seems like a viable alternative.  There is one main issue with using portlet filters in that Spring cannot be used to create or inject dependencies into the portlet filter.  (Maybe it can but I wasn’t able to get it to work).</p>
<p>Thus, I’ve created a PortletSecurityFilter filter that more or less follows the SS3 security process used in the Servlet side implementation (AbstractAuthenticationProcessingFilter).</p>
<p>What&#8217;s the point of doing this?  Well, we need to deploy our portlet to multiple portal containers.  Thus, if we use SS3 we can easily control our portlet roles and not have to rely on the portal implementation.</p>
<h2>Process</h2>
<p>The whole point of this exercise is to push an Authentication into the SecurityContext for SS3 to use later when verifying Role information.  We’ll create a PortletSecurityFilter to accomplish this push.</p>
<p>Warning, many might think of this as a hack to fool SS3.  If you’re okay with that then keep reading.</p>
<h2>Portlet Lifecycle Location</h2>
<p>The first question is in what portlet lifecycle should the filter live?  That depends but the best location is during the Action Phase.  Adding the filter at this point sets the SecurityContext early enough for both the Action and Render phases meaning SS3 will work for both annotation driven security as well as jsp rendering security.</p>
<h2>PortletSecurityFilter</h2>
<p>Below is the code for the PortletSecurityFilter.  Note that you will have to implement your own AuthenticationDetailsSource and AuthenticationManager for this to work.  You’ll notice this also throws the Authentication token onto the PortletSession for use in later requests.</p>
<pre>package com.your.package.name;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;
import javax.portlet.filter.ActionFilter;
import javax.portlet.filter.FilterChain;
import javax.portlet.filter.FilterConfig;
import javax.portlet.filter.PortletFilter;

import org.apache.log4j.Logger;
import org.springframework.security.authentication.AuthenticationDetailsSource;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;

/**
 * Implements security behavior for Spring Security 3.0.  Adds an <tt>Authentication</tt> to the
 * <tt>SecurityContext</tt> and to the <tt>PortletSession</tt>.  Spring Security picks up the
 * <tt>Authentication</tt> when it meets annotated methods with the @Secured annotation.
 */
public class PortletSecurityFilter implements PortletFilter, ActionFilter {

    private static Logger logger = Logger.getLogger(PortletSecurityFilter.class);
    private static final String SECURITY_TOKEN = "SECURITY_TOKEN";

    private AuthenticationDetailsSource authenticationDetailsSource = new PortletAuthenticationDetailsSource();
    private AuthenticationManager authenticationManager = new PortletAuthenticationManager();

    @Override
    /**
     * Follow the Spring Security method for an AuthenticationFilter.
     * @see AbstractAuthenticationProcessingFilter
     */
    public void doFilter(ActionRequest request, ActionResponse response, FilterChain chain) throws IOException, PortletException {
	if(request.getUserPrincipal() == null) {
	    // If no UserPrincipal from Portal stop the chain here.
	    return;
	}
	Authentication auth = (Authentication) request.getPortletSession().getAttribute(SECURITY_TOKEN);
	if(auth == null) {
	    PreAuthenticatedAuthenticationToken authToken = new PreAuthenticatedAuthenticationToken(request.getUserPrincipal(), request.getRemoteUser());
	    setDetails(request, authToken);
	    auth = authenticationManager.authenticate(authToken);
	}

        if(auth.isAuthenticated()) {
	    successfulAuthentication(request, response, auth);
	    chain.doFilter(request, response);
	    return;
        }
    }

    /**
     * Default behavior for successful authentication.
     *
     *	Sets the successful Authentication object on the {@link  SecurityContextHolder}
     *	Sets the Authentication onto the PortletSession
     *
     *
     * @see AbstractAuthenticationProcessingFilter
     * @param authResult the object returned from the  <tt>attemptAuthentication</tt> method.
     */
    protected void successfulAuthentication(ActionRequest request, ActionResponse response,
            Authentication authResult) throws IOException, PortletException {

        if (logger.isDebugEnabled()) {
            logger.debug("Authentication success. Updating SecurityContextHolder to contain: " + authResult);
        }
        SecurityContextHolder.getContext().setAuthentication(authResult);

	PortletSession session = request.getPortletSession();
	session.setAttribute(SECURITY_TOKEN, authResult);
    }

    /**
     * Implementation of setDetails.
     *
     * @see UsernamePasswordAuthenticationFilter
     * @param request that an authentication request is being created for
     * @param authRequest the authentication request object that should have its details set
     */
    protected void setDetails(ActionRequest request, PreAuthenticatedAuthenticationToken authRequest) {
        authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
    }

    @Override
    public void destroy() {
	System.out.println("Action filter destroy.");
    }

    @Override
    public void init(FilterConfig arg0) throws PortletException {
	System.out.println("Action filter init.");
    }
}
</pre>
<h2>portlet.xml</h2>
<p>The next step is to add this portlet filter to the portlet.xml file.  After you have declared your portlets, insert the following filter declaration:</p>
<div class="code" style="font-family:monospace;">&#60;filter&#62;</p>
<p>&#60;filter-name&#62;PortletSecurityFilter&#60;/filter-name&#62;<br />
&#60;filter-class&#62;<br />
<span style="text-decoration:underline;">com.your.package.name</span>.PortletSecurityFilter<br />
&#60;/filter-class&#62;<br />
&#60;lifecycle&#62;ACTION_PHASE&#60;/lifecycle&#62;<br />
&#60;init-param&#62;<br />
&#60;name&#62;message&#60;/name&#62;<br />
&#60;value&#62;Security Filter&#60;/value&#62;<br />
&#60;/init-param&#62;<br />
&#60;/filter&#62;<br />
&#60;filter-mapping&#62;<br />
&#60;filter-name&#62;PortletSecurityFilter&#60;/filter-name&#62;<br />
&#60;portlet-name&#62;your-portlet&#60;/portlet-name&#62;<br />
&#60;/filter-mapping&#62;</p>
</div>
<h2>Spring Security 3.0 Configuration</h2>
<p>We have to enable SS3 by creating an applicationContext-security.xml file.  Basically, all we really have to do is enable secure annotations so if you don’t want to create a new file than just throw this into your current applicationContext.xml:</p>
<pre>
&#60;?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?&#62;
&#60;beans xmlns=<em>"http://www.springframework.org/schema/beans"</em>
xmlns:xsi=<em>"http://www.w3.org/2001/XMLSchema-instance"</em>
xmlns:security=<em>"http://www.springframework.org/schema/security"</em>
xsi:schemaLocation=<em>"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</em>
<em> http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"</em>

&#62;
&#60;security:global-method-security secured-annotations=<em>"enabled"</em>/&#62;
&#60;security:authentication-manager alias=<em>"authenticationManager"</em> /&#62;

&#60;/beans&#62;
</pre>
<h2>web.xml</h2>
<p>Finally, if you added a new applicationContext than you’ll need to add that to your web.xml as a new contextConfigLocation.  That path will depend on where you put the file but one path might be:</p>
<p>/WEB-INF/context/applicationContext-security.xml</p>
<h2>Add Security</h2>
<p>Now all you need to do is add @Secured notations to your protected services or &#60;security:authorize&#62; tags to your jsp.  Assuming you created an AuthenticationManager that added the proper GrantedAuthorities than your security should now work.</p>
<p>I did this with Liferay portal v5.2.3 and successfully secured my portlet outside of Liferay.  Of course Liferay provides you with methods to expose your portlet permissions and administer them through Liferay control panel but we did not want to use that method.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Integration of Spring Security into Grails - plugin approach 3]]></title>
<link>http://imagesiteproject.wordpress.com/2009/09/24/integration-of-spring-security-into-grails-plugin-approach-3/</link>
<pubDate>Thu, 24 Sep 2009 18:07:25 +0000</pubDate>
<dc:creator>phillme</dc:creator>
<guid>http://imagesiteproject.wordpress.com/2009/09/24/integration-of-spring-security-into-grails-plugin-approach-3/</guid>
<description><![CDATA[In this post, as mentioned earlier, I will explain how my spring security 2.0.5 ACL (access control ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In this post, as mentioned earlier, I will explain how my spring security 2.0.5 ACL (access control list) enhancement of the acegi security plugin 0.5.1 for Grails can be configured. My work bases on Stephan February&#8217;s solution for the 0.3 plugin version and acegi security. Apart from the implementation changes within the plugin, the plugin configuration only has minor changes. This is the reason why it is strongly advised to read Stephan&#8217;s <a href="http://blog.bruary.net/2008/04/grails-acegi-acl-howto.html">blog post</a> before continuing with this article as I will only mention major differences between the configuration of his plugin version and mine.</p>
<p>One difference in my version is the possibility of <strong>applying ACLs to method parameters</strong> (<a href="http://blog.bruary.net/2008/04/grails-acegi-acl-howto.html">see 2.1</a> for an example):</p>
<p>For this to work custom voters have to be defined. A custom definition for the example of Stephan&#8217;s blog post looks as follows:</p>
<pre class="brush: java;">
springSecACLVoters = [ //this map must be called 'springSecACLVoters'
			aclReportWriteVoter: [// custom beanName
			domainObjectClass: 'Report', // which type of domainclass will be secured
			roleName: 'ACL_REPORT_WRITE', // under which name the voter should be referenced later? Must start with 'ACL_'
			permissions: [ org.springframework.security.acls.domain.BasePermission.ADMINISTRATION,
			org.springframework.security.acls.domain.BasePermission.WRITE] // which concrete permissions will be checked if 'ACL_REPORT_WRITE' is specified
			],
			aclReportDeleteVoter: [
			domainObjectClass: 'Report',
			roleName: 'ACL_REPORT_DELETE',
			permissions: [ org.springframework.security.acls.domain.BasePermission.DELETE]
			]
	]
</pre>
<p>I added comments in the corresponding lines to describe the single options in detail. As you can see more than one voter can be defined as long as the map name is &#8217;springSecACLVoters&#8217; and the map is defined in SecurityConfig.groovy. Please note that if you do not need method parameter checking with ACLs you can simply omit the map configuration of voters. </p>
<p>Aside from the definition of custom voters and for applying ACLs to method parameters I added <strong>three other options</strong> to SecurityConfig.groovy:</p>
<pre class="brush: java;">
useAcl = true // defaults to false, optional
aclClassIdentityQuery=&#34;SELECT @@IDENTITY&#34; // this query is for MySQL, default is 'identity()' for hsqldb, optional
aclSidIdentityQuery=&#34;SELECT @@IDENTITY&#34; // this query is for MySQL, default is 'identity()' for hsqldb, optional
</pre>
<p>If you want to use ACL extensions in general <em>useAcl</em> must be specified and set to &#8220;true&#8221;. Furthermore the enhancement uses the default JdbcMutableAclService  implementation of Spring. For this reason you must have the possibility to change its identity queries (look <a href="http://static.springsource.org/spring-security/site/docs/2.0.x/apidocs/org/springframework/security/acls/jdbc/JdbcMutableAclService.html">here</a>) to match your database. This can be done with the two corresponding options. The code snippet above shows working example values for hsqldb and MySQL.</p>
<p>Apart from feature and configuration changes the infrastructure of the plugin did also undergo a change since Stephan&#8217;s version: Because of the move of the ACL domain classes into the plugin domain directory the Gant target &#8220;CreateAclDomains&#8221; is no longer needed.  </p>
<p>Therewith the description of the plugin configuration is complete. <strong>Some issues however remain to be done</strong>:</p>
<ol>
<li>Calling of acl security functionality when using &#8216;run-app&#8217; may raise a class not found exception which will not be raised when &#8216;run-war&#8217; is used. I have to examine this more precisely and eventually file a bug report.</li>
<li>Test cases should be developed before a possible integration of the code into the main acegi security plugin tree. I am in contact with Burt Beckwith to get this working.</li>
<li>I have to upload the code to the <a href="http://jira.codehaus.org/browse/GRAILSPLUGINS-723">GRAILSPLUGINS-723</a> JIRA task so that Burt Beckwith can decide on a possible integration into the acegi plugin version control tree. I will do this within the next week as I am very busy at the moment.</li>
</ol>
<p>I hope this helps somebody<br />
Feedback is greatly appreciated</p>
<p>Regards,<br />
Phillip</p>
<p>Jump to other parts of this series:</p>
<ul>
<li>Integration of Spring Security into Grails &#8211; plugin approach 3</li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-ii/">Integration of Spring Security into Grails – plugin approach 2</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-i/">Integration of Spring Security into Grails – plugin approach 1</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails/">Integration of Spring Security into Grails – Spring approach</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/the-decision/">The Decision</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Integration of Spring Security into Grails - plugin approach 1]]></title>
<link>http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-i/</link>
<pubDate>Sat, 19 Sep 2009 15:46:56 +0000</pubDate>
<dc:creator>phillme</dc:creator>
<guid>http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-i/</guid>
<description><![CDATA[This blog post describes problems and challenges when porting Stephan February&#8217;s solution from]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This blog post describes problems and challenges when porting <a href="http://blog.bruary.net/2008/04/grails-acegi-acl-howto.html">Stephan February&#8217;s</a> solution from acegi security and acegiSecurityPlugin 0.3 to acegiSecurityPlugin 0.5.1 and Spring Security 2.0.5.</p>
<p>One issue was the fact that the whole API names changed from acegi security to spring security and that few api calls changed. Also the libraries had to be changed to work with Spring Security 2.0.5. In this case the grails maven project of the &#8220;Spring Way&#8221; mentioned before was of great help because maven&#8217;s calculated dependencies could simply be copied to the plugin. In this way all Java method.invocation errors went away magically <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Regrettably the domain classes of Stephan&#8217;s solution could not be used any further because the whole schema had changed from Acegi security to Spring Security. That is why I decided to continue the usage of the standard JDBCMutableAclService of Spring in combination with a simple Spring bean which controls the deletion and creation of schemata with plain SQL commands. </p>
<p>Apart from these issues I learned to work with the Grails plugin and the Spring Security API and digged deeper into interceptor technology, expando meta classes, the <a href="http://grails.org/doc/1.1.x/guide/14.%20Grails%20and%20Spring.html#14.3%20Runtime%20Spring%20with%20the%20Beans%20DS">Grails Bean Builder DSL</a> and Spring Security as a whole.</p>
<p>I already mentioned that our Image Site makes use of very fine grained permission control for which reason it was not acceptable to us that Stephan&#8217;s solution did not support applying ACLs (Access Control Lists) to method parameters. For example this could turn out to be very useful if a user wants to delete an image and the deletion method is able to check whether the user has the correct permission on the given image object. This is the reason why I tried to implement applying ACLs to method parameters. Details of the implementation and arising problems will be subject to my next blog post.</p>
<p>Regards,<br />
Phillip</p>
<p>Jump to other parts of this series:</p>
<ul>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/24/integration-of-spring-security-into-grails-plugin-approach-3/">Integration of Spring Security into Grails &#8211; plugin approach 3</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-ii/">Integration of Spring Security into Grails – plugin approach 2</a></li>
<li>Integration of Spring Security into Grails – plugin approach 1</li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails/">Integration of Spring Security into Grails – Spring approach</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/the-decision/">The Decision</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Integration of Spring Security into Grails - Spring approach]]></title>
<link>http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails/</link>
<pubDate>Sat, 19 Sep 2009 09:03:35 +0000</pubDate>
<dc:creator>phillme</dc:creator>
<guid>http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails/</guid>
<description><![CDATA[In the last post of the security layer we decided to integrate Spring Domain Object Security the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In the last post of the security layer we decided to integrate Spring Domain Object Security the &#8216;Spring Way&#8217; into our Grails application. This means that I tried to integrate the security concept without implementing or enhancing Grails or the acegi security plugin. Testable functionality was provided by the contact sample application of Spring Security. This was achieved by using a plain spring configuration file which was referenced from <em>grails-app/config/spring/resources.xml</em></p>
<p>As we planned to use MySQL as our datasource several changes had to be done to the default configuration. First I needed to provide a different database schema which luckily could be found on <a href="http://jim.bernatowicz.net/spring-security-2-acl-mysql-ddl">Jim Bernatowicz&#8217; Website</a>. Apart from this the <em>identity queries</em> of Spring&#8217;s JdbcMutableAclService had to be adapted like this to support MySQL:</p>
<pre class="brush: xml;">
&#60;bean id=&#34;aclService&#34; class=&#34;org.springframework.security.acls.jdbc.JdbcMutableAclService&#34;&#62;
    &#60;constructor-arg ref=&#34;dataSource&#34;/&#62;
    &#60;constructor-arg ref=&#34;lookupStrategy&#34;/&#62;
    &#60;constructor-arg ref=&#34;aclCache&#34;/&#62;
    &#60;property name=&#34;classIdentityQuery&#34; value=&#34;SELECT @@IDENTITY&#34;/&#62;
    &#60;property name=&#34;sidIdentityQuery&#34; value=&#34;SELECT @@IDENTITY&#34;/&#62;
&#60;/bean&#62;
</pre>
<p>Another problem I faced was that <em>grails run:app</em> threw errors when trying to find some security classes. Strange to say <em>grails run:war</em> worked perfectly. As we did not need <em>grails:run-app</em> functionality I decided to postpone this problem.</p>
<p>Apart from these issues this solution worked, but only for Java classes. An integration of Groovy classes into Spring like <a href="http://www.javabeat.net/articles/46-integrating-spring-and-groovy-1.html">http://www.javabeat.net/articles/46-integrating-spring-and-groovy-1.html</a> seemed heavy weighted and cumbersome to me. For this reason and with more Spring Security insight I decided to look deeper into the plugin approach of <a href="http://blog.bruary.net/2008/04/grails-acegi-acl-howto.html">Stephan February</a> and port it to the version 0.5.1 of the acegi-security plugin which will be part of the next blog post.</p>
<p>Regards,<br />
Phillip</p>
<p>Jump to other parts of this series:</p>
<ul>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/24/integration-of-spring-security-into-grails-plugin-approach-3/">Integration of Spring Security into Grails &#8211; plugin approach 3</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-ii/">Integration of Spring Security into Grails – plugin approach 2</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-i/">Integration of Spring Security into Grails – plugin approach 1</a></li>
<li>Integration of Spring Security into Grails – Spring approach</li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/the-decision/">The Decision</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[The Decision]]></title>
<link>http://imagesiteproject.wordpress.com/2009/09/19/the-decision/</link>
<pubDate>Sat, 19 Sep 2009 08:56:46 +0000</pubDate>
<dc:creator>phillme</dc:creator>
<guid>http://imagesiteproject.wordpress.com/2009/09/19/the-decision/</guid>
<description><![CDATA[As you probably already know when reading this blog our project consists of building an image managi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>As you probably already know when reading this blog our project consists of building an image managing website based on Grails with fine grained access control.  Therefore we need access control not only on role level but on object level. This means that we have to define access rights for a dynamic set of roles each with a dynamic set of users. UserA e.g. may have ReadRights on ImageA but AdminRights on ImageB and UserB may have ReadRights on ImageB but AdminRights on ImageA. In this case a role based approach needs to define a role for each combination of permission and image. Because normal role based approaches are not developed for millions of roles we needed a different approach.</p>
<p>As we did not have enough time to implement a whole security system by ourself we decided to look into Spring Security which we had in mind because of the acegi security plugin for grails. Spring Security has several advantages which were for us in short:</p>
<ul>
<li>very flexible because security access can be defined on method level</li>
<li>LDAP, RemeberMe and OpenID authentication</li>
<li>long history (acegi security base) and thus a hopefully stable approach</li>
</ul>
<p>Because of the use case mentioned in the beginning of this post the basic role based approach in &#8220;normal&#8221; Spring Security was not enough. <a title="Domain object security" href="http://static.springsource.org/spring-security/site/docs/2.0.x/reference/domain-acls.html">Domain object security</a> however seemed to be exactly what we needed.  Some reasons for using domain object security in our case are:</p>
<ul>
<li>For each domain object instance (eg picture number 23) it is possible to define an own ACL (Access Control List) which contains ACEs (Access Control Entries). This way each object instance has its own list of principals (users) which again have its own permissions (read, write, etc.)</li>
<li>White and black ACEs are supported (either restrict or enhance permissions)</li>
<li>Furthermore inheritance of ACLs is supported</li>
<li>Performance -&#62; &#8220;one of the main capabilities of the Spring             Security ACL module is providing a high-performance way of retrieving ACLs&#8221;</li>
</ul>
<p>The only problem seemed to be that the Acegi Security Plugin for Grails did not support domain object security and that is why we decided to integrate Spring Security the spring-way into grails. How I solved this will be mentioned in the next post.</p>
<p>Regards,</p>
<p>Phillip</p>
<p>Jump to other parts of this series:</p>
<ul>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/24/integration-of-spring-security-into-grails-plugin-approach-3/">Integration of Spring Security into Grails &#8211; plugin approach 3</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-ii/">Integration of Spring Security into Grails – plugin approach 2</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails-plugin-approach-i/">Integration of Spring Security into Grails – plugin approach 1</a></li>
<li><a href="http://imagesiteproject.wordpress.com/2009/09/19/integration-of-spring-security-into-grails/">Integration of Spring Security into Grails – Spring approach</a></li>
<li>The Decision</li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex: Enterprise security implementation using Chimp, permission based filtering component]]></title>
<link>http://jaibeermalik.wordpress.com/2009/08/28/flex-enterprise-security-implementation-using-chimp-permission-based-filtering-component/</link>
<pubDate>Fri, 28 Aug 2009 03:22:54 +0000</pubDate>
<dc:creator>Jai</dc:creator>
<guid>http://jaibeermalik.wordpress.com/2009/08/28/flex-enterprise-security-implementation-using-chimp-permission-based-filtering-component/</guid>
<description><![CDATA[This post covers how you can implement enterprise security solution for flex applications. You can i]]></description>
<content:encoded><![CDATA[This post covers how you can implement enterprise security solution for flex applications. You can i]]></content:encoded>
</item>
<item>
<title><![CDATA[JSFUnit with Spring Security]]></title>
<link>http://codergott.wordpress.com/2009/08/27/jsfunit-with-spring-security/</link>
<pubDate>Thu, 27 Aug 2009 08:48:48 +0000</pubDate>
<dc:creator>codergott</dc:creator>
<guid>http://codergott.wordpress.com/2009/08/27/jsfunit-with-spring-security/</guid>
<description><![CDATA[Some days ago, I tried to integrate JSFUnit into a Spring based JSF application. I stumbled over the]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Some days ago, I tried to integrate JSFUnit into a Spring based JSF application. I stumbled over the problem that the test crashed after a successful login. The stacktrace said, that the session was invalid.</p>
<p>The problem is that Spring Security invalidates the session after a successful login. Therefore I created a maven test profile which modified the spring security configuration to use the session-fixation-protection attribute of the http element.</p>
<pre>&#60;http auto-config="true" access-denied-page="/login.html" <span style="color:#ff0000;">session-fixation-protection="none"</span>&#62;</pre>
<h3>Links</h3>
<pre><a title="Spring Security Reference" href="http://static.springsource.org/spring-security/site/docs/2.0.x/reference/appendix-namespace.html#session-fixation-protection" target="_blank">http://static.springsource.org/spring-security/site/docs/2.0.x/reference/appendix-namespace.html#session-fixation-protection</a></pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[AccessDecisionVoter based on content related roles]]></title>
<link>http://webdevchoices.wordpress.com/2009/07/01/accessdecisionvoter-based-on-content-related-roles/</link>
<pubDate>Wed, 01 Jul 2009 10:11:29 +0000</pubDate>
<dc:creator>Andrea Bandera</dc:creator>
<guid>http://webdevchoices.wordpress.com/2009/07/01/accessdecisionvoter-based-on-content-related-roles/</guid>
<description><![CDATA[As Spring Security user I&#8217;m quite familiar with resource access control based on authenticated]]></description>
<content:encoded><![CDATA[As Spring Security user I&#8217;m quite familiar with resource access control based on authenticated]]></content:encoded>
</item>
<item>
<title><![CDATA[A Spring Security week !]]></title>
<link>http://boymeetstechnology.wordpress.com/2009/06/19/spring-security/</link>
<pubDate>Fri, 19 Jun 2009 16:29:30 +0000</pubDate>
<dc:creator>Stephen</dc:creator>
<guid>http://boymeetstechnology.wordpress.com/2009/06/19/spring-security/</guid>
<description><![CDATA[A Spring Security week for me ! We have a Java Work Group in my work place, and last month I volunte]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>A Spring Security week for me !</p>
<p>We have a Java Work Group in my work place, and last month I volunteered to do a presentation on Spring Security. Spring Security is a behemoth now. The most recent download (v 3.0.0M1) had the product documentation at 200+ pages. This session was just to give every one an overview. I used a number of sources to put this together, it&#8217;s all listed in the last slide. Ben Alex&#8217;s video presentation was extremely useful to understand the concepts&#8230;</p>
<div style="width:425px;text-align:left;"><!-- SlideShare error: doc is missing or has illegal characters /[^-_a-zA-Z0-9]/ --></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JOSSO Agent for Spring Security Users]]></title>
<link>http://webdevchoices.wordpress.com/2009/06/19/josso-for-spring-security-users/</link>
<pubDate>Fri, 19 Jun 2009 11:10:16 +0000</pubDate>
<dc:creator>Andrea Bandera</dc:creator>
<guid>http://webdevchoices.wordpress.com/2009/06/19/josso-for-spring-security-users/</guid>
<description><![CDATA[A couple of weeks ago I was looking for a single sign on solution to use in a web project I&#8217;m ]]></description>
<content:encoded><![CDATA[A couple of weeks ago I was looking for a single sign on solution to use in a web project I&#8217;m ]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex with Java Collaborative using the Best Architectures of Both]]></title>
<link>http://nsdevaraj.wordpress.com/2009/06/18/cairnspring/</link>
<pubDate>Thu, 18 Jun 2009 13:12:02 +0000</pubDate>
<dc:creator>nsdevaraj</dc:creator>
<guid>http://nsdevaraj.wordpress.com/2009/06/18/cairnspring/</guid>
<description><![CDATA[This Post was my overdue subject, I wanted to help with a sample Application using Cairngorm, Spring]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This Post was my overdue subject, I wanted to help with a sample Application using <strong>Cairngorm, Spring BlazeDS Integration &#38; Generic DAO.</strong></p>
<p>This might be a heavy subject as it deals with many subjects:</p>
<ul>
<li>Cairngorm with <a href="http://code.google.com/p/flexcairngorm/">UM Extensions</a> , from Universal Mind</li>
<li>Spring <a href="http://www.springsource.org/spring-flex">BlazeDS Integration</a>, from Spring Source</li>
<li>Spring, from Spring Source</li>
<li>Hibernate</li>
<li><a href="http://www.ibm.com/developerworks/java/library/j-genericdao.html">Generic DAO</a>, from IBM.</li>
<li>Spring Security 2.0, using MySQL.</li>
</ul>
<p>The Source is available at the link: <a href="http://code.google.com/p/cairnspring">cairnspring</a></p>
<p>How to use the source effectively?<br />
it is simple, steps below:</p>
<ol>
<li>Download, <a href="http://cairnspring.googlecode.com/files/CairnSpring.zip" target="_blank">Source</a> and <a href="http://cairnspring.googlecode.com/files/lib.zip" target="_blank">Libs</a></li>
<li>Unzip both and import &#8220;CairnSpring&#8221;, to your Eclipse</li>
<li>Paste the lib files to &#8220;CairnSpring\WebContent\WEB-INF\lib&#8221; folder</li>
<li>Import the &#8220;db.sql&#8221; into your MySQL Db, (change mysql port to 3036, else can be configured to default in &#8220;CairnSpring\WebContent\WEB-INF\config\jdbc.properties&#8221; file)</li>
<li>In Eclipse, Window -&#62; Preferences -&#62; Web and XML -&#62; XML Catalog -&#62; Add User Specified Entries with below values<br />
Location :  CairnSpring/WebContent/WEB-INF/config/spring-flex-1.0.xsd<br />
KeyType :  Namespace Name<br />
Key : http://www.springframework.org/schema/flex/spring-flex-1.0.xsd</li>
<li>Start the Tomcat Server with CairnSpring instance (the server host and port can be configured in file &#8220;CairnSpring\flex_src\Server.properties&#8221;)</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Deploy the Spring Security Tutorial]]></title>
<link>http://myminutes.wordpress.com/2009/06/17/deploy-the-tutorial-sample-application/</link>
<pubDate>Wed, 17 Jun 2009 16:31:48 +0000</pubDate>
<dc:creator>dedeibel</dc:creator>
<guid>http://myminutes.wordpress.com/2009/06/17/deploy-the-tutorial-sample-application/</guid>
<description><![CDATA[Ich arbeite mich zur Zeit ein wenig in verschiedene Sicherheitsframeworks für Java ein und bin gerad]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ich arbeite mich zur Zeit ein wenig in verschiedene Sicherheitsframeworks für Java ein und bin gerade dabei Spring Security genauer unter die Lupe zu nehmen.</p>
<p>Allerdings gab es bereits Probleme beim Deployen der Beispielanwendung aus dem <a href="http://static.springframework.org/spring-security/site/start-here.html">Quick Start Guide</a>. </p>
<p>Der Tomcat Application Manager gab nachdem Installieren nur ein sehr hilfreiches: <em>FEHLER &#8211; Anwendung mit Kontext Pfad /tutorial konnte nicht gestartet werden</em> von sich.</p>
<p>Das Systemlog führte einen dann schon eher auf die richtige Fährte:</p>
<p><code>[ERROR,[/tutorial]] Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener java.security.AccessControlException: access denied (java.util.PropertyPermission tutorial.root read)<br />
...<br />
SEVERE: Error listenerStart<br />
SEVERE: Context [/tutorial] startup failed due to previous errors</code></p>
<p>Interessanterweise landete die oberste Meldung nicht in den Tomcat Logs sondern nur in der <em>/var/log/syslog</em>. Die <em>SEVERE</em> Meldungen sind auch in den Tomcat Logs zu finden aber eben nicht annähernd so hilfreich.</p>
<p>Um nun nicht die ganze Beispielanwendung untersuchen und die einzelnen Regeln definieren zu müssen, reicht es für Testzwecke aus die Sicherheitsprüfung im Tomcat zu deaktivieren. Für den 5.5er Tomcat untern Debian, wird dies in der <em>/etc/default/tomcat5.5</em> mit dem Eintrag <em>TOMCAT5_SECURITY=no</em> erreicht.</p>
<p>hth</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Spring Security in a Swing Desktop application]]></title>
<link>http://sacrephill.wordpress.com/2009/06/12/using-spring-security-in-a-swing-desktop-application/</link>
<pubDate>Fri, 12 Jun 2009 10:56:25 +0000</pubDate>
<dc:creator>Phill</dc:creator>
<guid>http://sacrephill.wordpress.com/2009/06/12/using-spring-security-in-a-swing-desktop-application/</guid>
<description><![CDATA[It seems like there&#8217;s very little support (in terms of documentation) for using Spring Securit]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It seems like there&#8217;s very little support (in terms of documentation) for using Spring Security in a Swing (or general Desktop) application. All the documentation I could find assumed that Spring Security was going to be used in a web application.</p>
<p>However, it&#8217;s very possible to use the security framework in a Swing application &#8211; a little custom code is required, but then, that is only to be expected!</p>
<p>Essentially what we did is create a LoginUtils class, which had an authenticate(username, password) method. This referenced the Spring AuthenticationProvider (we&#8217;re using a custom LDAP AuthenticationProvider, but you can use whichever suits your needs).</p>
<p>This is what the code looks like:</p>
<pre class="brush: java;">
public Authentication authenticate( String username, String password )
 {
 UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( username, password );

 Authentication auth = _authProvider.authenticate( token );
 if (null != auth)
 {
 SecurityContextHolder.getContext().setAuthentication( auth );

 _eventPublisher.publishEvent( new InteractiveAuthenticationSuccessEvent( auth, this.getClass() ) );

 return auth;
 }
 throw new BadCredentialsException( &quot;null authentication&quot; );
 }
</pre>
<p>You can then call this method from wherever you want in your application (for example, from a Login action) and your user will be logged in.</p>
<p>Both _authProvider and _eventPublisher are dependency-injected properties.</p>
<p>Notice the _eventPublisher.publish(&#8230;) call.  You do not need this if you have nothing listening out for those events. However, if you do not publish them then they will not be published, so it&#8217;s worthwhile doing &#8211; particularly if you&#8217;re writing a security framework!</p>
<p>The other important thing is &#8211; and this is something which caught me out first time round &#8211; is that the SecurityContextHolder by default uses a ThreadLocal pattern. For a Swing application you will want the Global pattern. Put this somewhere in your code (i.e. a static initializer, or your main method):</p>
<pre class="brush: java;">SecurityContextHolder.setStrategyName( SecurityContextHolder.MODE_GLOBAL );</pre>
<p>This means that the Authentication object will be available to your entire application &#8211; if you don&#8217;t do this, objects on a different thread to the one you logged in on will not be able to &#8217;see&#8217; your credentials. For a while I couldn&#8217;t figure out why my Authentication object was coming back as null, until I realised!</p>
<p>Note: this post is application to Spring Security 2.0.4. At the time of writing, version 3 is only at milestone 1 so I have not tried it yet!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Developing Spring Web Flow 2 Application part 4 - Spring Security and HTTPS]]></title>
<link>http://cchweblog.wordpress.com/2009/05/26/developing-spring-web-flow-2-application-part-4-spring-security-and-https/</link>
<pubDate>Tue, 26 May 2009 19:57:26 +0000</pubDate>
<dc:creator>cchweblog</dc:creator>
<guid>http://cchweblog.wordpress.com/2009/05/26/developing-spring-web-flow-2-application-part-4-spring-security-and-https/</guid>
<description><![CDATA[As part of “Developing Spring Web Flow 2 Application” series, this post shows the following features]]></description>
<content:encoded><![CDATA[As part of “Developing Spring Web Flow 2 Application” series, this post shows the following features]]></content:encoded>
</item>
<item>
<title><![CDATA[Spring Security Authorisation and ACL]]></title>
<link>http://nitinaggarwal.wordpress.com/2009/05/14/spring-security-authorisation-and-acl/</link>
<pubDate>Thu, 14 May 2009 16:50:26 +0000</pubDate>
<dc:creator>Nitin</dc:creator>
<guid>http://nitinaggarwal.wordpress.com/2009/05/14/spring-security-authorisation-and-acl/</guid>
<description><![CDATA[I have been reading spring security over the past few days and have come across a few link which wil]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I have been reading spring security over the past few days and have come across a few link which will be helpful to you guys.</p>
<p>You will find some documentation which i will come up with on my blog soon.</p>
<p>I the mean while go through</p>
<p>http://static.springsource.org/spring-security/site/reference/pdf/springsecurity.pdf</p>
<p>http://grzegorzborkowski.blogspot.com/2008/10/spring-security-acl-very-basic-tutorial.html</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Start of something new.]]></title>
<link>http://2009summer.wordpress.com/2009/05/07/start-of-something-new/</link>
<pubDate>Thu, 07 May 2009 02:29:19 +0000</pubDate>
<dc:creator>Dan</dc:creator>
<guid>http://2009summer.wordpress.com/2009/05/07/start-of-something-new/</guid>
<description><![CDATA[So high school musical huh? Hahahaha. Yesterday, after presenting our iBatis, Struts and Spring Fram]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>So high school musical huh? Hahahaha.<br />
Yesterday, after presenting our iBatis, Struts and Spring Frameworked CASE 3, our real project was presented to us. I, Joelle Ortiz and Pau Pablo are going to work with Miss Jem, SEER&#8217;s External Consultant in doing a Payroll System. They left us an impression that it&#8217;s quite a big project but we&#8217;re not expected to do the whole thing, just modules. </p>
<p><!--more--><br />
Since Miss Jem has been the client of one of the CS 192 groups under Ma&#8217;am Solamo, I think she expects a lot from us too. *pressure*</p>
<p>We were given another set of materials to study before we actually start on Monday. </p>
<p>CSS and AJAX (<a href="http://jquery.com">JQuery &#8211; http://jquery.com/</a>)<br />
Freemarker &#8211; <a href="http://www.freemarker.org/">http://www.freemarker.org/</a><br />
jYMSG &#8211; http://jymsg9.sourceforge.net/<br />
Spring Security (formerly ACEGI Security) &#8211; <a href="http://www.acegisecurity.org">http://www.acegisecurity.org</a><br />
Jasper Report interface with Java Servlets<br />
(<a href="http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html">http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html</a>)</p>
<p>I predict another challenging week next week (or next month!). I hope we get out of it alive! haha.</p>
<p>Ciao!</p>
<p>-D</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[how to use manage to login in multiple steps with Spring Security]]></title>
<link>http://laeno.wordpress.com/2009/02/26/multiplestepsloginwithspringsecurity/</link>
<pubDate>Wed, 25 Feb 2009 16:31:40 +0000</pubDate>
<dc:creator>laeno</dc:creator>
<guid>http://laeno.wordpress.com/2009/02/26/multiplestepsloginwithspringsecurity/</guid>
<description><![CDATA[Solution: 1.  Suppose the whole login page have 3 steps. 2. Make sure the first step page be accessi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><!--[if !mso]&#62;--><br />
<!--[if gte mso 9]&#62;  &#60;![endif]--><!--[if gte mso 9]&#62;   &#60;![endif]-->Solution:</p>
<p>1.  Suppose the whole login page have 3 steps.</p>
<p>2. Make sure the first step page be accessible for all users, it&#8217;s just a simple page for user to input username and password.</p>
<p>3. Put all the remaining steps in to a webflow named loginprocess. after username/password is verified successfully, the page is navigated to the flow automatically.</p>
<p>4. Configure that loginprocess flow is only accessible by role &#8221; ROLE_LOGIN&#8221;.</p>
<p>5. Add a customer filter at position: AUTHENTICATION_PROCESSING, override the onSuccessfulAuthentication() method, in this method, set the Authentication into session, and replace it with a temp authentication which only contains &#8220;ROLE_LOGIN&#8221; role</p>
<p>6. Now user can only access the loginprocess flow, in this flow, user will finish the remaining steps. Before we exit the flow, restore the authentication which is stored into session in the filter.</p>
<p>Some configuration and codes:</p>
<p>Security-config.xml</p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:http</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">auto-config</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;false&#8221;</span></em> <span style="color:#7f007f;">entry-point-ref</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;myAuthenticationFilterEntryPoint&#8221;</span></em> <span style="color:#7f007f;">path-type</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;ant&#8221;</span></em><span style="color:teal;">&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:logout</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">logout-url</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/faces/login/logout&#8221;</span></em> <span style="color:#7f007f;">logout-success-url</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/faces/login/login.jspx&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:intercept-url</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">pattern</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/spring/login&#8221;</span></em> <span style="color:#7f007f;">access</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;ROLE_LOGIN&#8221;</span></em> <span style="color:teal;">/&#62;</span><span style="color:black;"> </span><span style="color:#3f5fbf;">&#60;!&#8211;  this should be set before other flow &#8211;&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:intercept-url</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">pattern</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/spring/**&#8221;</span></em> <span style="color:#7f007f;">access</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;ROLE_USER&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:http</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:authentication-manager</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">alias</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;authenticationManager&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:authentication-provider</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">user-service-ref</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;securityManager&#8221;</span></em><span style="color:teal;">&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:authentication-provider</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">bean</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">id</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;myAuthenticationFilterEntryPoint&#8221;</span></em> <span style="color:#7f007f;">class</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;com.trpoc.login.MyAuthenticationFilterEntryPoint&#8221;</span></em><span style="color:teal;">&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;loginFormUrl&#8221;</span></em> <span style="color:#7f007f;">value</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/faces/login/login.jspx&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">bean</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">bean</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">id</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;authenticationProcessingFilter&#8221;</span></em> <span style="color:#7f007f;">class</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;com.trpoc.login.MyAuthenticationFilter&#8221;</span></em><span style="color:teal;">&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">security:custom-filter</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">position</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;AUTHENTICATION_PROCESSING_FILTER&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;authenticationManager&#8221;</span></em> <span style="color:#7f007f;">ref</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;authenticationManager&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;authenticationFailureUrl&#8221;</span></em> <span style="color:#7f007f;">value</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/faces/login/login.jspx&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;defaultTargetUrl&#8221;</span></em> <span style="color:#7f007f;">value</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/spring/login&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;filterProcessesUrl&#8221;</span></em> <span style="color:#7f007f;">value</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;/login/j_spring_security_check&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">property</span><span style="font-size:10pt;font-family:&#34;"> <span style="color:#7f007f;">name</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;alwaysUseDefaultTargetUrl&#8221;</span></em> <span style="color:#7f007f;">value</span><span style="color:black;">=</span><em><span style="color:#2a00ff;">&#8220;true&#8221;</span></em> <span style="color:teal;">/&#62;</span></span></p>
<p><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">bean</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p><span style="font-size:10pt;font-family:&#34;color:teal;"> </span></p>
<p>MyAuthenticationFilter</p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:#646464;">@Override</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">protected</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">void</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> onSuccessfulAuthentication(HttpServletRequest request,</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> HttpServletResponse response, Authentication authResult)</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">throws</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> IOException {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> System.</span><em><span style="font-size:10pt;font-family:&#34;color:#0000c0;">out</span></em><span style="font-size:10pt;font-family:&#34;color:black;">.println(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8221; on successful login . &#8220;</span><span style="font-size:10pt;font-family:&#34;color:black;">);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> request.<span style="background:silver none repeat scroll 0 0;">getSession</span>().setAttribute(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;AUTH&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">, SecurityContextHolder.<em>getContext</em>().getAuthentication());</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> SecurityContextHolder.<em>getContext</em>().setAuthentication(</span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">new</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> <span style="text-decoration:underline;">Authentication()</span>{</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> Authentication </span><span style="font-size:10pt;font-family:&#34;color:#0000c0;">auth</span><span style="font-size:10pt;font-family:&#34;color:black;"> = SecurityContextHolder.<em>getContext</em>().getAuthentication();</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">public</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> GrantedAuthority[] getAuthorities() {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:#3f7f5f;">// </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f9fbf;">TODO</span></strong><span style="font-size:10pt;font-family:&#34;color:#3f7f5f;"> Auto-generated method stub</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> GrantedAuthorityImpl granted = </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">new</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> GrantedAuthorityImpl(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;ROLE_LOGIN&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> GrantedAuthority[] arr = {granted};</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">return</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> arr;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> /.. .. .. other codes omittd.</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> });</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"> }</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;">How to go to the requested URL after login, </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;">Add a new flowHandler, </span></p>
<p class="MsoNormal"><!--[if gte vml 1]&#62;   &#60;![endif]--><!--[if !vml]--></p>
<table style="height:481px;" border="0" cellspacing="0" cellpadding="0" width="399">
<tbody>
<tr>
<td style="border:.75pt solid black;background:white none repeat scroll 0 0;vertical-align:top;" width="571" height="397" bgcolor="white"><!--[endif]--><!--[if !mso]--><span style="position:absolute;z-index:251658240;"></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td><!--[endif]--></p>
<div class="shape" style="padding:4.35pt 7.95pt;">
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">public</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> String     handleExecutionOutcome(FlowExecutionOutcome outcome,</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> HttpServletRequest     request, HttpServletResponse response) {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">if</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> (outcome.getId().equals(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;target&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">)) {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> ((SecurityContext)     request.getSession().getAttribute(</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;SPRING_SECURITY_CONTEXT&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">))</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> .setAuthentication((Authentication)     request.getSession()</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> .getAttribute(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;AUTH&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">));</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">if</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> (request.getSession().getAttribute(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;TARGET_URL&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">) != </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">null</span></strong><span style="font-size:10pt;font-family:&#34;color:black;">) {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">return</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;"> +     request.getSession().getAttribute(</span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;TARGET_URL&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">);</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> } </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">else</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">return</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;externalContext:demo&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> } </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">else</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> {</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> </span><strong><span style="font-size:10pt;font-family:&#34;color:#7f0055;">return</span></strong><span style="font-size:10pt;font-family:&#34;color:black;"> </span><span style="font-size:10pt;font-family:&#34;color:#2a00ff;">&#8220;login&#8221;</span><span style="font-size:10pt;font-family:&#34;color:black;">;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"> }</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;"> </span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"> }</span></p>
</div>
<p><!--[if !mso]--></td>
</tr>
</tbody>
</table>
<p></span><!--[endif]--><!--[if !mso &#38; !vml]--> <!--[endif]--><!--[if !vml]--></td>
</tr>
</tbody>
</table>
<p><!--[endif]--></p>
<p><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;">If access is denied, navigate to login page:</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"><span> </span></span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">error-page</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"><span> </span></span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">error-code</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span><span style="font-size:10pt;font-family:&#34;color:black;">403</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">error-code</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal" style="margin-bottom:.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&#34;color:black;"><span> </span></span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">location</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span><span style="font-size:10pt;font-family:&#34;color:black;">/faces/login/login.<span style="text-decoration:underline;">jspx</span></span><span style="font-size:10pt;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;font-family:&#34;color:#3f7f7f;">location</span><span style="font-size:10pt;font-family:&#34;color:teal;">&#62;</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"><span> </span></span><span style="font-size:10pt;line-height:115%;font-family:&#34;color:teal;">&#60;/</span><span style="font-size:10pt;line-height:115%;font-family:&#34;color:#3f7f7f;">error-page</span><span style="font-size:10pt;line-height:115%;font-family:&#34;color:teal;">&#62;</span></p>
<p><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"><br />
</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&#34;color:black;"> </span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Spring Security - JCIFS - Windows authentication]]></title>
<link>http://thoughtsofken.wordpress.com/2009/01/14/spring-security-jcifs-windows-authentication/</link>
<pubDate>Wed, 14 Jan 2009 15:04:53 +0000</pubDate>
<dc:creator>predhme</dc:creator>
<guid>http://thoughtsofken.wordpress.com/2009/01/14/spring-security-jcifs-windows-authentication/</guid>
<description><![CDATA[I had a requirement to be able to authenticate against a local windows machine&#8217;s user database]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I had a requirement to be able to authenticate against a local windows machine&#8217;s user database or active directory. I dug and dug around forever trying to find a pre built solution but found nothing. So I wrote my own <a href="http://static.springsource.org/spring-security/site/apidocs/org/springframework/security/providers/AuthenticationProvider.html">AuthenticationProvider</a></p>
<p>I used spring 2.0.3 and jcifs 1.3.2. Below are my related security beans:</p>
<pre class="brush: xml;">
    &lt;beans:bean id=&quot;authenticationProvider&quot;
            class=&quot;util.NtlmAuthenticationProvider&quot;&gt;

        &lt;custom-authentication-provider /&gt;
        &lt;beans:property name=&quot;domain&quot; value=&quot;domain&quot;/&gt;
        &lt;beans:property name=&quot;hostname&quot; value=&quot;hostname&quot; /&gt;
        &lt;beans:property name=&quot;userDetailsService&quot; ref=userDetailsServiceImpl&quot;/&gt;
    &lt;/beans:bean&gt;
</pre>
<p>The userDetailsService is a custom service that maps a &#8220;windows&#8221; user account to an account in the local database. This is where our &#8220;roles&#8221; are stored. Here is a snippet from the AuthenticationProvider:</p>
<pre class="brush: java;">
public Authentication authenticate(Authentication authentication)
            throws AuthenticationException {
        try {
            log.info(&quot;Attempting to contact server: &quot; + hostname);
            UniAddress domainController = UniAddress.getByName(hostname);
            NtlmPasswordAuthentication credentials =
                new NtlmPasswordAuthentication(domain, authentication.getName(),
                (String)authentication.getCredentials());

            log.info(&quot;Attempting log into domain: &quot; + domain + &quot; as &quot; +
                    authentication.getName());

            SmbSession.logon(domainController, credentials);

            // populate a authentication object with authorities.
            UserDetails userDetails = userDetailsService.loadUserByUsername(
                (String)authentication.getPrincipal());

            UsernamePasswordAuthenticationToken auth = new
                    UsernamePasswordAuthenticationToken(authentication.getPrincipal(),
                    authentication.getCredentials(), userDetails.getAuthorities());

            return auth;

        } catch (UnknownHostException ex) {
            throw new AuthenticationServiceException(ex.getMessage());
        } catch (SmbAuthException ex) {
            throw new BadCredentialsException(ex.getMessage());
        } catch (SmbException ex) {
            throw new AuthenticationServiceException(ex.getMessage());
        }
    }
}
</pre>
<p>Instead of using a UserDetailsService you could instead just create a new token (as I did) and pass in some kind of authorities. Return that new object as that informs spring that the user has been authenticated and granted the appropriate authorities.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exploring Spring Secuirty Series: part 13 to part 16]]></title>
<link>http://heraclitusonsoftware.wordpress.com/2008/12/29/exploring-spring-secuirty-series-part-13-to-part-16/</link>
<pubDate>Mon, 29 Dec 2008 14:24:54 +0000</pubDate>
<dc:creator>heraclitusonsoftware</dc:creator>
<guid>http://heraclitusonsoftware.wordpress.com/2008/12/29/exploring-spring-secuirty-series-part-13-to-part-16/</guid>
<description><![CDATA[In spring security series parts 13 to 16, we revert back a bit to take a closer look at how spring s]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In spring security series parts 13 to 16, we revert back a bit to take a closer look at how spring security filters work. We clean up our configuration to allow us to have uri level security and method level security in place by part 16.</p>
<p>In subsequent parts of the series, we will continue on to look at the ACL feature of spring security.</p>
<p><a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-13/">part 13</a><br />
<a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-14/">part 14</a><br />
<a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-15/">part 15</a><br />
<a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-16/">part 16</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exploring Spring Secuirty Series: part 11 &amp; 12]]></title>
<link>http://heraclitusonsoftware.wordpress.com/2008/12/22/exploring-spring-secuirty-series-part-11-12/</link>
<pubDate>Mon, 22 Dec 2008 05:23:17 +0000</pubDate>
<dc:creator>heraclitusonsoftware</dc:creator>
<guid>http://heraclitusonsoftware.wordpress.com/2008/12/22/exploring-spring-secuirty-series-part-11-12/</guid>
<description><![CDATA[In part 11 , we start looking at spring security&#8217;s ACL features. We create the schema and popu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In part 11 , we start looking at spring security&#8217;s ACL features. We create the schema and populate the database with test data as well as the ACL tables.</p>
<p>In part 12 , we add code that enables us to see the data entered into our Projects (domain) table and also the corresponding entries in our ACL tables.</p>
<p>see <a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-11">http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-11</a></p>
<p>see <a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-12/">http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-12/</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exploring Spring Secuirty Series: part 10]]></title>
<link>http://heraclitusonsoftware.wordpress.com/2008/11/26/exploring-spring-secuirty-series-part-10/</link>
<pubDate>Wed, 26 Nov 2008 04:03:57 +0000</pubDate>
<dc:creator>heraclitusonsoftware</dc:creator>
<guid>http://heraclitusonsoftware.wordpress.com/2008/11/26/exploring-spring-secuirty-series-part-10/</guid>
<description><![CDATA[In part 10, we change from using the configuration to declare users to create a database backend usi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div class="entry">
<div class="snap_preview">
<p>In part 10, we change from using the configuration to declare users to create a database backend using (hsqldb) and we add the users and authorities to the schema to allow basic authentication.</p>
<p>We add an initializing bean that is responsible for creating the and populating the schema of the in-memory database on startup.</p>
<p>see <a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-10">http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-10</a></div>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Exploring Spring Security Series: part 9]]></title>
<link>http://heraclitusonsoftware.wordpress.com/2008/11/23/exploring-spring-security-series-part-9/</link>
<pubDate>Sun, 23 Nov 2008 13:56:04 +0000</pubDate>
<dc:creator>heraclitusonsoftware</dc:creator>
<guid>http://heraclitusonsoftware.wordpress.com/2008/11/23/exploring-spring-security-series-part-9/</guid>
<description><![CDATA[In part 9, we use exceptions mappings to control what is displayed when certain exceptions occur wit]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In part 9, we use exceptions mappings to control what is displayed when certain exceptions occur within the application.</p>
<p>see <a href="http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-9/">http://heraclitusonsoftware.wordpress.com/software-development/spring/simple-web-application-with-spring-security-part-9/</a></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
