Saturday, October 29, 2011

SpringSocial and Tapestry. Let's be connected.

I've been working with connecting my applications to social services for last week. Didn't here anything about its APIs before. So, I started to look up for information about this and found this posts:
Good articles I want to say. And scibe-java library is a good choice for your application. It is very simple, has a lot of supported APIs and is very flexible(you can generated all needed requests by your own).
But there is an another choice - spring-social. It has not only request-response logic implementation but also full-featured facebook and twitter APIs. E.g. to update facebook status we just need do this:


The only thing we need is to get OAuth access token for needed social service. The way to do this is during application authorization process. All technical details you can find on oauth.net.

Friday, October 21, 2011

Secure application pages with tapestry5

Let's imagine that we have some application with auhentication and users separation by their authorities. There are also a set of allowed pages for every such authority.
E.g. we have such roles: anonymous, user and administrator. Anonymous is unauthorized user and can see only home page, user can see home and some other read-only pages, and administrator can see all pages. But how we can implement such logic to be sure that everybody can acces only allowed pages?
Let's create @Allow annotation that will define all necessary user authorities to access the page.


So our pages will look like this one:


Now the only thing we need is to throw security exception when user tries to acces page that are not allowed for him.