Showing posts with label sakai. Show all posts
Showing posts with label sakai. Show all posts

Monday, 9 July 2012

OAuth protocol

In my previous post I write just a small definition about what OAuth protocol is. Today I'm going to try to explain Oauth Workflow, and therefore the work that I've been doing these last two weeks.

First of all, I am working following the OAuth 2.0. The reasons why I choose to work with the OAuth 2.0 protocol is because OAuth 2.0 is the next evolution of OAuth protocol, a lot of online applications (as Google) considers OAuth 1.0 deprecated, and most of java libs build to work with OAuth, in this case we are using Apache Amber,  do not implement Oauth 1.0.

Now let's take a look at the OAuth protocol basics.

OAuth defines 4 roles, which take part in the protocol:
  • Resource owner: an entity capable of granting access to a protected resource. When the resource owner is a person, it is referred to as an end-user.
  • Resource server: the server hosting the protected resources, capable of accepting and responding to protected resource requests using access tokens.
  • Client: an application making protected resource requests on behalf of the resource owner and with its authorisation. The term client does not imply any particular implementation characteristics (e.g. whether the application executes on a server, a desktop, or other devices).
  • Authorisation server: the server issuing access tokens to the client after successfully authenticating the resource owner and obtaining authorisation.

Let's take a look to OAuth work flow:

OAuth 2.0


The OAuth Client  register itself  in the Authorization Server, as result it will respond with a consumer key and with a shared secret.

The authorization code work flow diagram involves the following steps:
  1. Client obtains request_token: 
    a. The client requests authorization from the resource owner.
    b. The authorization request can be made directly to the resource owner (as shown), or preferably indirectly via the authorization server as an intermediary.
  2. Resource owner authorises request_token:
    c. The client receives an authorization grant which is a credential representing the resource owner's authorization, expressed using one of four grant types defined in this specification or using an extension grant type.
    d. The authorization grant type depends on the method used by the client to request authorization and the types supported by the authorization server.
  3. OAuth Client exchange its request token for access_token:
    e. The client requests an access token by authenticating with the authorization server and presenting the authorization grant.
    f. The authorization server authenticates the client and validates the authorization grant, and if valid issues an access token.
  4. OAuth Client uses its access_token to obtain protected resources:
    The client requests the protected resource from the resource server and authenticates by presenting the access token.
    The resource server validates the access token, and if valid, serves the request.

I've been working with Amber, I had problems trying to include the library in the project and meanwhile I was working the developers changed pretty much the library. The danger of working with a incubator project. Anyway, it's already working.
Sadly I could not find a good documentation about how to write a provider using this library, so if anyone in the community knows about it please share it in the comments, I would be really grateful.

Finally, my mentor, Carl Hall, helped me to understand some principles about OSGi than I had confused. Thanks! :)

I'll keep working in the OAuth Provider, just remember you than you could follow my work at github.
Any comments will be welcome, and any Amber tutorial too. :)

Saturday, 2 July 2011

Sakai CLE mobile application with phoneGap

In my previous post I mentioned how to setup the working environment and useful tools we can use to develop mobile applications using web technologies. Today I am going to present what I learnt during the past few weeks and the status of the CLE mobile application at the moment.
As discussed with my mentor, Steve Swinsberg, the basic requirements of the CLE mobile app. are as follows for the first version also listed here and the UI flows can be found here. (Screens v1.0.1) 

User login
User enters user details to enter the system.

 List of sites
s/he will be directed to a list of sites that they are in (assuming credentials are correct)

 List of tools
User selects a site will navigate them to a tools list of the selected site. Here they can see how many new announcements, assignments and etc are there at a glance.

 Mobile version of each tool
Once they select a particular tool they can view the above details in detail. This will hopefully be a read only tool for the first version of app.

Current status  
List of sites and tools for a selected site done.


















































Both this screens are rendered using JSONP feeds of my local host because JSON feeds did not work due to domain issues. Please find the code here and please add your suggestions.

Try out this in your emulators with phoneGap
If you want to run this in your emulator what you have to do is to create a phoneGap app. following their tutorial and add sites.html to assets/www directory.

To add JSONP support for your local sakai instance you can do the following change to core-providers in entitybroker and deploy *only* it in tomcat.

Checkout entitybroker trunk if you don’t have,

    edit the classes where it says:


    add Formats.JSONP to the end      
    • mvn clean install sakai:deploy (from entitybroker pom level)
    •  re/start Tomcat.
    Yeah that’s it! Now you have JSONP support.

    Here is how to add a customize callback function,


    That's it you should be able to see above screens. :-)

    This is a useful place you can try JS, CSS, HTML http://jsfiddle.net/. Here we don't need to put all code just the snippets work nicely for example http://jsfiddle.net/HQK5w/6/

    Thanks to my mentor, Steve Swinsberg, for the support and directions.

    As always waiting for your comments. 

    Sunday, 29 May 2011

    Cross Platform Mobile Application for Sakai CLE


    First, I would like to introduce myself. I am Kasun Lakpriya Hettige from Sri Lanka, following a computer science and engineering degree in University of Moratuwa. I am willing to do my higher studies in Software Engineering field.

    For those who are not heard of the project here are few links:

    Idea of this project is to build an mobile application for Sakai CLE to use in many kinds of mobile platforms like Android, iOS, BlackBerry and etc. For this we are using a cross platform library called phoneGap. More details about phoneGap http://www.phonegap.com/.

    Tools and technologies
    Though the app is going to be ported with different platforms due to some limitations I am developing for Android to test in emulators. Here are my working environment details:
    • Eclipse (3.5 or higher)
    • Android SDK
    • ADT plug-in
    • MDS AppLaud 1.2 PhoneGap for Android plug-in - This is optional but useful due to its inbuilt,
      • phoneGap support
      • HTML, JS and CSS project support
      • Touch-Optimized UI frame support for popular jQuery mobile and Sencha Touch JS libraries at the moment
      • All in one support is a big plus for me
    NOTE: To use AppLaud you need Eclipse Helios.
    As discussed with mentor I will be moving forward with jQuery mobile for now. Here are few screens of the app. 
    Your ideas, comments are welcome all the time and will really helpful to come up with a nice product. And the best place to collaborate and to get more information about the project would be the above mentioned confluence space. I will be posting here with the progress and the things I will get to know in the meantime. So I hope that anybody who is willing develop mobile apps using these technologies will find this interesting.

    Thanking Charith for helping hand with Photoshop and Avinash for some sample screens! :-)