Wednesday 1 October 2014

Importing a JSP WebApp into eclipse

Hmm, seems to be a simple thing right, but actually it isn't that easy for beginners :/

First things first, you need to make sure that you have all the right plugins installed, I'd recommend that you rather just use the Eclipse Web Tools platform instead.

After this, you'd think that just using import should do it but it's a little trickier than that!

1. Right Click on the | Projects Explorer View > Dynamic Web Project|
2. Untick the Use default location option that is ticked by default.
3. Click on Browse > Navigate to the path of the existing project.
4. Enter the name of the project that you want to import it as.
5. Select your desired runtime from existing ones or create a new one.
6. Select the required Dynamic web module version.
7. Select the default configuration for the runtime that you've selected.
8. Click finish and you're done!

Seems to be simple but took a little longer than I should have to figure it out.
NOTE- On clicking finish you may get a java.lang.NullPointer error, if you do, just restart the instance of eclipse and it should work for me, happened in my case so just a heads up!

Hope this helps you guys out.

Tuesday 30 September 2014

Configure 802.1X Auth Mechanism using CLI in Linux

 
Connecting to a LAN network that uses 802.1x and EAPOL using the command line interface.

First, you would need to setup a wpa_supplicant.conf config file as shown below.

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=users
ap_scan=0
fast_reauth=1
network={
    key_mgmt=IEEE8021X
    eap=PEAP
    phase2="auth=MSCHAPV2"
    identity="IDENTITY"
    password="PASSWORD"
}

And that's pretty much it! All you need to do now is run this command:
 
wpa_supplicant -D wired -i eth0 -dd -c /path/to/config/file  #Replace eth0 with your ethernet interface

This could take a few seconds to run but should end with an authentication successful message, if not, try to find the place where it fails and try to debug it.

Once this is ready, you need to request for an ip address, run the following command.
 
dhclient eth0
And you're done!

Install Plugins from .zip Eclipse

Sometime, Eclipse doesn't exactly update quickly from update sites for installing plugins. This could be a problem especially when you're stuck behind a proxy! So, here's a way to manually install a plugin from a zip.
Note that most plugin writers don't always include the zip, in that case, you may have to try alternate methods to obtain it.

So these are the steps involved in manually installing the plugin-

1. First unzip the file. If the unzipped folder contains content.jar and artifacts.jar, you must be able to import it directly into eclipse from | Help > Install New Software > Add > Archive | .
2. If the above method fails, which happened in my case, unzip the file into a directory and move the directory into /path/to/eclipse/dropins directory. Name of the unzipped folder does not matter.
3. After moving the folder there, restart your eclipse and the plugin must be working now!

You can verify that the plugin is installed by doing | Help > About Eclipse > Installation Details > Installed Software |.

Hope this helps!

Sunday 29 June 2014

Eventbrite Login and Queries using JS and OAuth

Hey guys, this is my first ever blog post and it's a short tutorial on how to connect your website to Eventbrite and it makes use of the OAuth2 protocol.

I assume that you have a basic idea about web development and I hope that this does not sound too technical to the new developers (if any)!

First, include jquery and the eventbrite js code, eventbrite code can be found at https://raw.github.com/ryanjarvinen/Eventbrite.jquery.js/master/Eventbrite.jquery.js .

Next, using the correct app_key, the key listed in your http://www.eventbrite.com/myaccount/apps/ use this code to login.
<script type="text/javascript">
  $('document').ready(function(){
    // Your API_Key's redirect_uri must be configured correctly at: http://eventbrite.com/api/key
    // Set your API_Key on the line below:
    Eventbrite.prototype.widget.login({'app_key': 'YOUR_API_KEY'}, function(widget_html){
      // Place the resulting Eventbrite login widget code somewhere on your page.
      // This example places the content into an element marked with class="eb_login_box"
      $('.eb_login_box').html(widget_html);
    });
  });
</script>

This code fills the element with class eb_login_box with an eventbrite button to connect to eventbrite.

Make sure that you have the right redirect uri else, it won't work and the callback will not happen properly.

You can look at a working example at http://amoghbl1.kd.io/eventbrite.html

Now, once you've got the access_token after authentication, you can initialize the client using
Eventbrite({'access_token': "USER_ACCESS_TOKEN"}, function(eb_client)
{ //eb_client interaction goes here...
});

After that, you can get the users events by using -
eb_client.user_list_events ( {}, function( response ){
    $( '#target' ).html( eb_client.utils.eventList( response, eb_client.utils.eventListRow ));
});

USEFUL LINKS:
https://github.com/ryanjarvinen/Eventbrite.jquery.js/blob/master/OAUTH2-README.md
https://github.com/ryanjarvinen/Eventbrite.jquery.js (Look at the readme to find all the required api calls and stuff like that!)

Hope this helps!