JAX-RS and RESTful Security
The use of HTTP, as the driving force of SOA can never be exemplified enough. In terms of the usefulness of SOA, I think that RESTful SOA is a no brainer, has some great uses, and I've always been confused at why people adopted SOAP nothingness. Or, should I say, SOAP wrappers that achieve nothing. RESTfulness, on it's basic level, having no required integrated security, is great for
- public information
- lookups of information that should be readily available for many systems, but does not contain user's private information (without a proper authentication/authorization model in place), etc
- systems not requiring proper/secure authentication and authorization
From a private personal data and security perspective (not that I'm an expert on security, by any means), the RESTful method of SOA really doesn't define much in the way of security. After all, any authentication method, unless it's directly or indirectly tied to the front end user's credentials, and also propagating those credentials to the back end REST service, with stateful authentication, is not adequate security. Having a certificate for example, is great to prevent sniffers, but not hackers that have compromised a client web server system.
What is JAXB and JAXB Example Code
I thought it may be nice for those googlers that want to know about JAXB, to have a quick working example to use. So, that is the purpose of this post.
ZK AJAX Status Bar
Seeing that my research project is a mini accounting system, I thought it necessary to be able to display items in a status bar, like a real application. It is very slightly unfortunate that ZK doesn't have something integrated right in for this purpose. But, given the versatility of ZK, it's easy enough to resolve.
ZK Exception Handling and Error Popup
Once I had some basic functionality in my mini accounting system that I'm writing (for research purposes), one of my goals was to have an adequate error display for the user, that was the same every time. Suffice it to say, I was completely thrilled to find out that ZK could do exactly what I wanted to do, and I didn't have to write an once of code. All I did was write some ZUL, which wrapped a JSP inside of a ZK window. I share how I did that in this post.
ZK AJAX Framework Introduction
I am in the process of working with and researching ZK as an AJAX framework to integrate into Java Web Development that I do. So far, AJAX looks really amazing, and is fully integrated into the J2EE framework. It is an event driven framework that has the option of hooking directly into existing JSP, or entirely writing ZK event handlers to do the processing. There is no wonder that ZK won the Project of the Month Source Forge award.
RMI Pitfalls and Problems
In this post, I plan on laying out multiple common problems with RMI, that a developer can run into. I hope that this will be a concise guide to fixing the common RMI problems that beginners run into. As I come up with more, I will edit this post, rather than creating a new one. I will then post a comment on this entry; if you are subscribed to the comments (RSS feed), you will get notification when there is an update.
Also, if you are having some sort of RMI trouble, post a comment, and I will let you know if I know the solution. I may also add the solution directly to this post, if it happens to actually be an RMI related issue.
EJB3 @RolesAllowed, annotation type not applicable to this kind of declaration
I'm just learning EJB3, and I'm stumbling here and there. When developing an EJB object, I had a problem where the compiler was giving me an error that says "annotation type not applicable to this kind of declaration". It was on a line like the following...
@RolesAllowed({"admin", "entryclerk"})
Obviously this is normal to use on a method. Unfortunately, I had it defined on not just any method, but the constructor method of my Java class. It took me awhile to figure out why it was happening, so I thought would spare others a bit of grief.
XSL Break or Wrap String on Word Boundary
I've searched all over the Internet for this, and was unable to find anything reasonable. I found an example somewhere, of how to break a string at a specific location, but it breaks whether there is a word there or not. So, either you have to re-compose the XML elements without a space, and hope every system you interact with does the same thing as you, or re-compose them with a space, and a word may then be broken up in the end result.
In my example below, I break a string on a word boundary, outputting to an XML element called "NoteMessage" from the PESC standard. This is dependant on Java, but you could use any language that has a useful lastIndexOf function. In the case of Java, with zero based string index, we need to compensate for the one based string index that XSL has. So, we add one to the result of the lastIndexOf() call.
<!-- Example... java -cp target/dependency/xml-util-0.1.3-SNAPSHOT.jar:/usr/share/xalan/lib/xalan.jar \ org.apache.xalan.xslt.Process -XSL target/classes/xsl/notemessage.xsl \ -PARAM testString "This is a test to break a string into multiple note messages, \ automatically, without programming." --> <xsl:stylesheet version="1.0" xmlns:String="http://xml.apache.org/xalan/java/java.lang.String" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="${xml.indent}" method="xml" omit-xml-declaration="yes"/> <xsl:param name="testString"/> <xsl:variable name="break-at" select="'76'"/> <xsl:template match="/"> <xsl:call-template name="note-message"> <xsl:with-param name="string" select="$testString"/> </xsl:call-template> </xsl:template> <xsl:template name="note-message"> <xsl:param name="string"/> <xsl:choose> <xsl:when test="string-length($string) <= $break-at"> <xsl:element name="NoteMessage"> <xsl:value-of select="$string"/> </xsl:element> </xsl:when> <xsl:otherwise> <!-- call method to find word boundary index --> <xsl:variable name="truncString" select="String:new(substring($string, 1, $break-at))"/> <xsl:variable name="lastSpaceIndex" select="String:lastIndexOf($truncString, ' ') + 1"/> <xsl:element name="NoteMessage" namespace=""> <xsl:value-of select="substring(string($truncString), 1, $lastSpaceIndex)"/> </xsl:element> <xsl:call-template name="note-message"> <xsl:with-param name="string" select="substring($string, $lastSpaceIndex + 1)"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
Java, Xalan, JAXP, xml transformations from Java String
I racked my head against the wall over and over again for several hours, unable to determine why I was getting a prolog error, when I knew dang well my XML was well formed.
I'm using JAXP, which is detecting and using xalan as my transformation implementation. I'm not sure who's fault it is, but when I create a new StreamSource for my transformation, and I ask it to load the xml-stylesheet from the processing instruction, it simply doesn't work. I keep getting one of two errors, depending on the format of the java String.
The first error I was getting was "javax.xml.transform.TransformerException: Content is not allowed in prolog". The other error I was getting, once I put my xml declaration at the beginning of the string, was "javax.xml.transform.TransformerException: The markup in the document following the root element must be well-formed". Of course, none of these are meaningful in any way. Neither one tells me that I'm not allowed to ask xalan to resolve my xml-stylesheet automatically, while using XML from a Java String object.
arduino interfacing with the HD44780 LCD
It became time for me to interface an LCD with my Arduino. I need to generate a handy report of what my various sensors are picking up. The following is an account of my notes on twisting up my HD44780 compatible LCD on the Arduino. Please enjoy.
I'm staring at my LCD module. I can hear it saying, "hook me up!", but I'll have to read a bit first.