<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-369656091898653083</id><updated>2011-07-08T01:53:36.465-04:00</updated><category term='mvc'/><category term='xml'/><category term='zend'/><category term='java'/><category term='php'/><category term='spring'/><category term='json'/><title type='text'>Life In Code</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ajcoon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ajcoon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>aj</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/-MNWvdR4H6RA/TaO0tr_n43I/AAAAAAAABi4/sJ8EgvHSAfI/s220/Aaron%2BNew.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-369656091898653083.post-910546830057003655</id><published>2009-10-30T12:55:00.013-04:00</published><updated>2009-10-30T13:07:06.122-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='mvc'/><category scheme='http://www.blogger.com/atom/ns#' term='spring'/><title type='text'>Spring Security</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;I'm working on a project using the &lt;a href="http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html"&gt;Spring Web MVC&lt;/a&gt; framework.&amp;nbsp; I was interested in learning more about Spring Security to &lt;b&gt;have it manage authentication and authorization for me&lt;/b&gt;.&amp;nbsp; This way I can avoid &lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;having to write a custom form controller to manage authentication, and coming up with some home-grown ACL strategy.&amp;nbsp; I&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; decided to try out the &lt;a href="http://static.springsource.org/spring-security/site/petclinic-tutorial.html"&gt;petclinic tutorial&lt;/a&gt;.&amp;nbsp; It seemed like after reviewing the information that I would be able to use Spring Security in my project&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;So, I repeated the steps of the tutorial on my own project.&amp;nbsp; But I soon found out that &lt;b&gt;the login page being displayed was not a jsp&lt;/b&gt; found in the petclinic project.&amp;nbsp; Instead, it is generated by the Spring Security library.&amp;nbsp; This won't do.&amp;nbsp; I need a login page that looks like the rest of my application.&amp;nbsp; So, off to Google I go...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Fortunately, I'm not the first person to have this same issue.&amp;nbsp; Thanks to &lt;a href="http://www.mularien.com/blog/"&gt;Peter Mularien&lt;/a&gt; for putting together &lt;a href="http://www.mularien.com/blog/2008/07/07/5-minute-guide-to-spring-security/"&gt;this excellent summary of and expansion on&lt;/a&gt; the petclinic tutorial.&amp;nbsp; The one thing I did differently in my project is that &lt;b&gt;I wanted to enforce concurrent session control&lt;/b&gt;.&amp;nbsp; This is easily accomplished by adding the following to your security:http configuration:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;However, I was experiencing a bad side-effect.&amp;nbsp; Now once my user logged out, they could no longer log back in.&amp;nbsp; After &lt;a href="http://stackoverflow.com/questions/1647855/spring-security-cant-login-after-clicking-logout"&gt;posting a question on Stack Overflow&lt;/a&gt; I discovered my own answer.&amp;nbsp; There is &lt;b&gt;another listener required in the deployment descriptor&lt;/b&gt; to use session control:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;listener&amp;gt;&lt;br /&gt;&amp;lt;listener-class&amp;gt;org.springframework.security.ui.session.HttpSessionEventPublisher&amp;lt;/listener-class&amp;gt;&lt;br /&gt;&amp;lt;/listener&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Once again, I'm left with the feeling that Spring is great, but its lack of documentation for what I would consider to be core features is a chronic issue for me.&amp;nbsp; Spring is not for the faint-hearted or easily-frustrated.&amp;nbsp; One must have the intestinal fortitude to dig in and figure things out on their own...and search Google.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/369656091898653083-910546830057003655?l=ajcoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajcoon.blogspot.com/feeds/910546830057003655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ajcoon.blogspot.com/2009/10/spring-security.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/910546830057003655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/910546830057003655'/><link rel='alternate' type='text/html' href='http://ajcoon.blogspot.com/2009/10/spring-security.html' title='Spring Security'/><author><name>aj</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/-MNWvdR4H6RA/TaO0tr_n43I/AAAAAAAABi4/sJ8EgvHSAfI/s220/Aaron%2BNew.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-369656091898653083.post-4788267275044890218</id><published>2009-10-04T12:22:00.000-04:00</published><updated>2009-10-04T12:22:46.630-04:00</updated><title type='text'>Programming Zen</title><content type='html'>&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;/li&gt;&lt;li&gt;C = an axe: lots of people use it for lots of basic, but serious jobs.&lt;/li&gt;&lt;li&gt;C++ = a double-bladed axe with a graphite handle and a rubber grip:&amp;nbsp; similar, but fewer people use it, and they feel special having held it in their hands.&lt;/li&gt;&lt;li&gt;Java = one of every kind of axe there has ever been, all lined up neatly in a row.&lt;/li&gt;&lt;li&gt;Python = that old stand-by pair of scissors in your top drawer.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/369656091898653083-4788267275044890218?l=ajcoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajcoon.blogspot.com/feeds/4788267275044890218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ajcoon.blogspot.com/2009/10/programming-zen.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/4788267275044890218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/4788267275044890218'/><link rel='alternate' type='text/html' href='http://ajcoon.blogspot.com/2009/10/programming-zen.html' title='Programming Zen'/><author><name>aj</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/-MNWvdR4H6RA/TaO0tr_n43I/AAAAAAAABi4/sJ8EgvHSAfI/s220/Aaron%2BNew.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-369656091898653083.post-492705887178258728</id><published>2009-09-22T10:43:00.008-04:00</published><updated>2009-09-22T15:21:06.913-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='zend'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='json'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>REST Services Supporting XML and JSON Using Zend Framework</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;I have been working on a project to build a RESTful Web service to handle provisioning requests for a PHP web application.&amp;nbsp; The developer working on the web app is using Zend Framework web MVC.&amp;nbsp; I wanted to stick with PHP so I could "hand off" the provisioning API once it is done.&amp;nbsp; After doing some research, it seemed that Zend Framework also had good support for what I wanted to accomplish with REST.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;I have never used Zend before, and my most recent PHP experience was over three years ago, so I was hoping there would be good examples/tutorials.&amp;nbsp; Fat chance.&amp;nbsp; I found several other blogs that gave an account of their own personal trials (and in a couple of cases, successes), but nothing in the order of "official".&amp;nbsp; To give credit, &lt;a href="http://www.chrisdanielson.com/tag/json/"&gt;Chris Danielson's post&lt;/a&gt; was my starting point but left quite a bit out that I needed.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;First, &lt;b&gt;why if I specified &lt;i&gt;"format=xml"&lt;/i&gt; in my URL did the view still get returned as JSON?&lt;/b&gt;&amp;nbsp; This was unnerving to say the least.&amp;nbsp; After doing some digging, I found the answer on the &lt;a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html"&gt;Zend Framework Manual.&lt;/a&gt;&amp;nbsp; Specifically,&amp;nbsp; the section titled "&lt;u&gt;12.8.4.3.1.&amp;nbsp;Default Contexts Available&lt;/u&gt;" mentions that you have to disable automatic JSON serialization.&amp;nbsp; Minor detail?&amp;nbsp; So finally my XML view start working when I ask them to...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Next, &lt;b&gt;how the heck do I access the request body for a POST or PUT request?&lt;/b&gt;&lt;i&gt;&amp;nbsp; &lt;/i&gt;In Chris Danielson's blog, his example shows the following to get an incoming parameter:&lt;/span&gt;&lt;br /&gt;&lt;i&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;getRequest()-&amp;gt;getParam($paramName)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This only works for the query string though!&amp;nbsp; So again, I did some looking, and found this:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;getRequest()-&amp;gt;getRawBody()&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Makes sense...but again, would have been great to see an example of this somewhere.&amp;nbsp;&amp;nbsp; All of the blogs I looked at focused on GET requests...as if POST is never used.&amp;nbsp; :-)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Once I had these issues ironed out, it was just a matter of implementation.&amp;nbsp; But as I got further into development,&lt;b&gt; I saw a pattern forming&lt;/b&gt; that seemed ideal for the Framework to handle.&amp;nbsp; It occurred to me that - for each method handler - I was:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Adding an action handler to context switch for XML and JSON&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Defining a common document structure for the response (view) to be returned, regardless of context.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Wrapping the view in "resolvable" phtml documents that encode the document in the proper context.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Why is all of this necessary?&amp;nbsp; So I asked the experts:&amp;nbsp; &lt;a href="http://framework.zend.com/issues/browse/ZF-7825"&gt;read my proposal for ZF-7825&lt;/a&gt;.&amp;nbsp; As of this posting, the proposal is still under development, but my guess is this will show up in some 2.x release of Zend Framework.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Overall I would say that Zend Framework is a good choice if you're starting a new Web service project with PHP.&amp;nbsp; It  is under active development by numerous contributors and supports a large number of features out-of-the-box.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;You can &lt;a href="http://www.ajcoon.com/blog/attachments/"&gt;download the code here&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;-aj&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/369656091898653083-492705887178258728?l=ajcoon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajcoon.blogspot.com/feeds/492705887178258728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ajcoon.blogspot.com/2009/09/rest-services-supporting-xml-and-json.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/492705887178258728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/369656091898653083/posts/default/492705887178258728'/><link rel='alternate' type='text/html' href='http://ajcoon.blogspot.com/2009/09/rest-services-supporting-xml-and-json.html' title='REST Services Supporting XML and JSON Using Zend Framework'/><author><name>aj</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://3.bp.blogspot.com/-MNWvdR4H6RA/TaO0tr_n43I/AAAAAAAABi4/sJ8EgvHSAfI/s220/Aaron%2BNew.jpg'/></author><thr:total>2</thr:total></entry></feed>
