<?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-2915243622034068119</id><updated>2011-04-21T15:31:54.280-05:00</updated><category term='login'/><category term='java'/><category term='sso'/><category term='JOSSO'/><title type='text'>Loud Thoughts</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://loud-thoughts.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://loud-thoughts.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ivan Latysh</name><uri>http://www.blogger.com/profile/02743017339299369364</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://bp2.blogger.com/_lFHCV7goWIc/R-CJ9zRhwJI/AAAAAAAAAAo/Y9BXEwUuOZQ/S220/ivan-face-only.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-2915243622034068119.post-8641279641691361011</id><published>2007-10-11T21:50:00.000-05:00</published><updated>2007-10-11T21:53:39.686-05:00</updated><title type='text'>Time Tracking application</title><content type='html'>I recently launched an OpenSource project TimeTicker.&lt;br /&gt;Check it out &lt;a href="http://code.google.com/p/time-ticker/"&gt;http://code.google.com/p/time-ticker/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2915243622034068119-8641279641691361011?l=loud-thoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loud-thoughts.blogspot.com/feeds/8641279641691361011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2915243622034068119&amp;postID=8641279641691361011' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/8641279641691361011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/8641279641691361011'/><link rel='alternate' type='text/html' href='http://loud-thoughts.blogspot.com/2007/10/time-tracking-application.html' title='Time Tracking application'/><author><name>Ivan Latysh</name><uri>http://www.blogger.com/profile/02743017339299369364</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://bp2.blogger.com/_lFHCV7goWIc/R-CJ9zRhwJI/AAAAAAAAAAo/Y9BXEwUuOZQ/S220/ivan-face-only.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2915243622034068119.post-2253392921786879191</id><published>2006-11-15T10:59:00.000-05:00</published><updated>2006-11-15T18:57:42.848-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='login'/><category scheme='http://www.blogger.com/atom/ns#' term='JOSSO'/><category scheme='http://www.blogger.com/atom/ns#' term='sso'/><title type='text'>JOSSO Automatic User Login filter.</title><content type='html'>&lt;div style="text-align: justify;"&gt;I believe that many of us came across the situation when system need to authorize a user based on some custom criteria.&lt;br /&gt;One of use cases is when user has been referred from one portal to another and suddenly you need to allow such user access to certain parts of you system.&lt;br /&gt;So I been exploring possibilities in search of a simple solution.&lt;br /&gt;Requirements are simple - user has been referred to our system from another portal and need to gain access to the certain area.&lt;br /&gt;First what came to my mind is a sort of a gateway that will check referrer and passed parameters and make a decision if this request indeed valid and user can be granted certain privileges or not. This gateway can use passed or preset credentials and authorize user within JOSSO.&lt;br /&gt;A simple Filter can do this job for us quite well.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="overflow: scroll; background-color: silver; height: 600px; color: black;"&gt;&lt;pre&gt;&lt;br /&gt;import javax.servlet.*;&lt;br /&gt;import javax.servlet.http.HttpServletRequest;&lt;br /&gt;import javax.servlet.http.HttpServletRequestWrapper;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Simple filter that allow to examine incoming request and authorize user with JOSSO&lt;br /&gt;* based on analisys.&lt;br /&gt;&lt;br /&gt;* It is useful for the situation when you need to authorize a user that is came from&lt;br /&gt;* some legacy application or from another webapp or portal.&lt;br /&gt;&lt;br /&gt;*&lt;br /&gt;* @author Ivan&lt;br /&gt;* @version 0.1&lt;br /&gt;*/&lt;br /&gt;public class AutoLoginFilter implements Filter {&lt;br /&gt;&lt;br /&gt;/** Referer URL */&lt;br /&gt;protected String referer_url;&lt;br /&gt;/** user name */&lt;br /&gt;protected String josso_username;&lt;br /&gt;/** password */&lt;br /&gt;protected String josso_password;&lt;br /&gt;/** backto URL */&lt;br /&gt;protected String josso_back_to;&lt;br /&gt;&lt;br /&gt;public void destroy() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {&lt;br /&gt;ServletRequest myreq = req;&lt;br /&gt;if (req instanceof HttpServletRequest) {&lt;br /&gt;HttpServletRequest httpServletRequest = (HttpServletRequest) req;&lt;br /&gt;if (null==httpServletRequest.getUserPrincipal()&lt;br /&gt;&amp;&amp;amp; httpServletRequest.getRequestURL().toString().matches(".+usernamePasswordLogin.do")&lt;br /&gt;&amp;&amp;amp; null!=httpServletRequest.getHeader("referer")&lt;br /&gt;&amp;&amp;amp; httpServletRequest.getHeader("referer").equalsIgnoreCase(referer_url)&lt;br /&gt;&amp;&amp;amp; httpServletRequest.getMethod().equalsIgnoreCase("GET")) {&lt;br /&gt;if (isValid(httpServletRequest)) {&lt;br /&gt;  // create new request wrapper&lt;br /&gt;  GuestLoginServletRequestWrapper wrapper = new GuestLoginServletRequestWrapper(httpServletRequest);&lt;br /&gt;  // add additional parameters&lt;br /&gt;  wrapper.parametersMap.put("josso_cmd", "login");&lt;br /&gt;  wrapper.parametersMap.put("josso_username", josso_username);&lt;br /&gt;  wrapper.parametersMap.put("josso_password", josso_password);&lt;br /&gt;  wrapper.parametersMap.put("josso_back_to", josso_back_to);&lt;br /&gt;  // switch request to the wrapper&lt;br /&gt;  myreq = wrapper;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;chain.doFilter(myreq, resp);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void init(FilterConfig config) throws ServletException {&lt;br /&gt;referer_url = config.getInitParameter("referer_url");&lt;br /&gt;if (null== referer_url || referer_url.trim().length()==0) config.getServletContext().log("ERROR: Initial parameter {referer_url} is not defined !");&lt;br /&gt;josso_username = config.getInitParameter("josso_username");&lt;br /&gt;if (null== josso_username || josso_username.trim().length()==0) config.getServletContext().log("ERROR: Initial parameter {josso_username) is not defined !");&lt;br /&gt;josso_password = config.getInitParameter("josso_password");&lt;br /&gt;if (null== josso_password || josso_password.trim().length()==0) config.getServletContext().log("ERROR: Initial parameter {josso_password) is not defined !");&lt;br /&gt;josso_back_to = config.getInitParameter("josso_back_to");&lt;br /&gt;if (null== josso_back_to || josso_back_to.trim().length()==0) config.getServletContext().log("ERROR: Initial parameter {josso_back_to) is not defined !");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Does actual request validation.&lt;br /&gt;* Here we will perform more rigorous testing.&lt;br /&gt;*&lt;br /&gt;* @param request request&lt;br /&gt;* @return &lt;tt&gt;true&lt;/tt&gt; if request is valid and user can be logged in, &lt;tt&gt;false&lt;/tt&gt; otherwise.&lt;br /&gt;*/&lt;br /&gt;private boolean isValid(HttpServletRequest request) {&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Simple request wrapper.&lt;br /&gt;* Allow to add josso parameters to the request&lt;br /&gt;*/&lt;br /&gt;class GuestLoginServletRequestWrapper extends HttpServletRequestWrapper {&lt;br /&gt;protected Map&lt;string,object&gt; parametersMap;&lt;br /&gt;&lt;br /&gt;public GuestLoginServletRequestWrapper(HttpServletRequest httpServletRequest) {&lt;br /&gt;super(httpServletRequest);&lt;br /&gt;// create custom parameter map&lt;br /&gt;parametersMap = new HashMap&lt;string, object=""&gt;(httpServletRequest.getParameterMap());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getParameter(String s) {&lt;br /&gt;Object value = parametersMap.get(s);&lt;br /&gt;if (value instanceof String[]) {&lt;br /&gt;return ((String[]) value)[0];&lt;br /&gt;}&lt;br /&gt;return (String) value;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public Enumeration getParameterNames() {&lt;br /&gt;return new Hashtable&lt;string, object=""&gt;(parametersMap).keys();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String[] getParameterValues(String s) {&lt;br /&gt;Object value = parametersMap.get(s);&lt;br /&gt;if (value instanceof String) {&lt;br /&gt;return new String[]{(String)value};&lt;br /&gt;}&lt;br /&gt;return (String[])value;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public Map getParameterMap() {&lt;br /&gt;return parametersMap;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Now we should configure this filter:&lt;br /&gt;&lt;div style="overflow: scroll; background-color: silver; color: black;"&gt;&lt;pre&gt;&amp;lt;filter&amp;gt;&lt;br /&gt;&amp;lt;filter-name&amp;gt;AutoLoginFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&amp;lt;filter-class&amp;gt;AutoLoginFilter&amp;lt;/filter-class&amp;gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;referer_url&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;http://myserver.com/referer.html&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;josso_username&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;guest&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;josso_password&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;guest&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;josso_back_to&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;/guest&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&amp;lt;/filter&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And map it:&lt;br /&gt;&lt;div style="overflow: scroll; background-color: silver; color: black;"&gt;&lt;pre&gt;&amp;lt;filter-mapping&amp;gt;&lt;br /&gt;&amp;lt;filter-name&amp;gt;AutoLoginFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;&amp;lt;url-pattern&amp;gt;*.do&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&amp;lt;/filter-mapping&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Here you should be careful, this filter should be configured in JOSSO web application and should be mapped to login.do action.&lt;br /&gt;Please use extreme caution with this approach, since referrer url is very easy to fake. You should not rely only on referrer url, use some other meaningful verification algorithm. For instance you can pass encrypted user information with expiration time, etc.&lt;br /&gt;&lt;br /&gt;Now you can customize implementation with your own isValid() method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2915243622034068119-2253392921786879191?l=loud-thoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loud-thoughts.blogspot.com/feeds/2253392921786879191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2915243622034068119&amp;postID=2253392921786879191' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/2253392921786879191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/2253392921786879191'/><link rel='alternate' type='text/html' href='http://loud-thoughts.blogspot.com/2006/11/josso-automatic-user-login-filter.html' title='JOSSO Automatic User Login filter.'/><author><name>Ivan Latysh</name><uri>http://www.blogger.com/profile/02743017339299369364</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://bp2.blogger.com/_lFHCV7goWIc/R-CJ9zRhwJI/AAAAAAAAAAo/Y9BXEwUuOZQ/S220/ivan-face-only.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2915243622034068119.post-330296954391042079</id><published>2006-09-28T13:35:00.000-05:00</published><updated>2006-11-15T10:59:26.363-05:00</updated><title type='text'>Just for starters ...</title><content type='html'>Anything what we do has the beginning and has the end.&lt;br /&gt;And any choice that we make along this journey bring us one step closer to the end.&lt;br /&gt;So let's do this step and mark the beginning of this blog with a hope that the end is still far away.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2915243622034068119-330296954391042079?l=loud-thoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://loud-thoughts.blogspot.com/feeds/330296954391042079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2915243622034068119&amp;postID=330296954391042079' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/330296954391042079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2915243622034068119/posts/default/330296954391042079'/><link rel='alternate' type='text/html' href='http://loud-thoughts.blogspot.com/2006/09/just-for-starters.html' title='Just for starters ...'/><author><name>Ivan Latysh</name><uri>http://www.blogger.com/profile/02743017339299369364</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://bp2.blogger.com/_lFHCV7goWIc/R-CJ9zRhwJI/AAAAAAAAAAo/Y9BXEwUuOZQ/S220/ivan-face-only.jpg'/></author><thr:total>0</thr:total></entry></feed>
