JEE Webservice basic auth security check with Glassfish

July 8th, 2010

No @RolesAllowed available for Webservices

The JEE specification is growing into a nice and easy to use specification. But some features, like Webservices and RolesAllowed, are not good enough yet. To be more precise. @RolesAllowed is not supported for plain Webservices (not doubling as EJB’s) until version 3.0 in the Servlet Specification.

After much reading on this subject, I have come to the conclusion that a pragmatic solution is required. My solution is just to inspect the principals based upon the logged in user and check myself if the user is allowed to continue. But you can also define the webservice as EJB.
Read the rest of this entry »

Flex: Dynamic binding using a mapping file

January 20th, 2010

Introduction

Binding can be an time consuming task in Flex. If you have a domain model and the DTO’s for your components, you need an easy way to bind the two together. Here you have two options. The first is to write alot of BindingUtils statements in either models. And finally you can write a mapping file in xml, create a custom binder class which uses the mapping file and bind the two models together.

I have chosen the last option, because this gives me some more flexibility handling the bindings.
Read the rest of this entry »

Flex 3 Custom validation of grouped input fields

December 1st, 2009

Introduction

Flex 3 has nicely build-in validation mechanism, but sometimes you wish they had not embedded this so deep into the components, that customization becomes a laborish task. I have also read many articles on customizations of this mechanism, but I have not found a working solution to my specific wish. What I want is validation of single input fields, multiple input and arbitrary placement of errors
besides the tooltip method.

Read the rest of this entry »

How To: Load a spring application from a jar file

August 24th, 2009

Consider the following situation:

Loading 3 application context files in a Swing application. 2 of the context files are in jar-files.
All context files depend on the component-scan option. The Application context gets loaded from my Swing app.
The method I use, is the import resource option in the context file. Read on how to configure this in your application context.
Read the rest of this entry »

Webservices with Spring and Castor

August 17th, 2009

Today, webservices are used primarily to expose some services of an application to the outside world. There are a lot of tools available to consume webservices. Tools like Mule, Axis and Spring.
This article describes a method of exposing Java services as webservices. The technique’s / tools used to accomplice this are; Java, Spring and Castor.
There are many other tools available, like Axis, to expose java services as webservices. The reason I used Spring and Castor is the simplicity in creating webservices. Spring takes care of all boilerplate coding and Castor’s mapping capability takes care of the Object <-> XML mapping without the need to generate any java objects the way Axis does. This way you have clean java code, supported with configuration in Spring and a clean Castor mapping to expose your service as a webservice.
Read the rest of this entry »

Easy JavaScript client-side form validation

June 3rd, 2009

When you are developing a website or an application, there will come a moment that you have to start using Javascript to validate your HTML forms. Here you have 4 options. Option one is not to validate. Although tempting, it is not the best option to use. Option two is to depend on your application framework and hope they have implemented client-side validation into it besides the server-side validation. Option three is to custom code some basic validation scripting yourself.
This is a great way to learn more about Javascript, but also the figurative pain in the butt. Option four and final option is to grab a existing Javascript validation framework from the Net and use it. I would recommend option four which brings me to the actual goal of my post

Many Javascript validation frameworks that are available have one thing in common. You MUST code Javascript to use it. And this is just the thing you are trying to avoid. Spry is a nice example here. Very powerful framework, but you have to know about Javascript to use it. Would it not be nice that u can use a Javascript validation framework without having to know Javascript. I know some designers would love it, since they do not have to depend on other developers for the Javascript. On the other side. I as a developer can spend my time on other issues besides validation coding. That mean that I will have more time if I provide my designer with a non intrusive way to implement client-side Javascript validation.

Read the rest of this entry »