I recently installed Ubuntu 11.10 with a lot of hesitation. After the upgrade, I realised why I was hesitating. Somewhere in the back of my mind, I had this feeling that something won’t work. To say the least, Unity on Ubuntu 11.10 is rubbish and I absolutely hated it. I thought I will do the same thing that I did previously, revert to the classic desktop. However, the classic desktop is not that nice with Ubuntu 11.10. Long story short, I have moved onto to Xfce 4.8 and I absolutely love it. Clean, classic style.

Coming back to the topic of this post, I needed to install Oracle’s SQL Developer. As I did a clean install of Ubuntu, I first needed to install JDK. I decided to go with Oracle’s JDK 1.7. Here is how I installed it.

For Ubuntu 11.10 64 bit OS, download and extract the right version of JDK for your platform.

http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html

Copy the extracted directory to /usr/lib and follow the steps as shown below:

masud@masud:/opt$ sudo mv jdk1.7.0_01/ jdk1.7.0
masud@masud:/opt$ ls
jdk1.7.0
masud@masud:/opt$ sudo mv jdk1.7.0/ /usr/lib
masud@masud:/opt$ ls
masud@masud:/opt$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jdk1.7.0/bin/java" 1
masud@masud:/opt$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jdk1.7.0/bin/javac" 1
update-alternatives: using /usr/lib/jdk1.7.0/bin/javac to provide /usr/bin/javac (javac) in auto mode.
masud@masud:/opt$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jdk1.7.0/bin/javaws" 1
masud@masud:/opt$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
 1 /usr/lib/jdk1.7.0/bin/java 1 manual mode
 2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jdk1.7.0/bin/java to provide /usr/bin/java (java) in manual mode.
masud@masud:/opt$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
masud@masud:/opt$ sudo update-alternatives --config javac
There is only one alternative in link group javac: /usr/lib/jdk1.7.0/bin/javac
Nothing to configure.
masud@masud:/opt$ sudo update-alternatives --config javaws
There are 2 choices for the alternative javaws (providing /usr/bin/javaws).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/javaws 1061 auto mode
 1 /usr/lib/jdk1.7.0/bin/javaws 1 manual mode
 2 /usr/lib/jvm/java-6-openjdk/jre/bin/javaws 1061 manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jdk1.7.0/bin/javaws to provide /usr/bin/javaws (javaws) in manual mode.
masud@masud:/opt$

Now download the Oracle’s SQL Developer package for your system from the following address.
http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
Now go through the following steps:

masud@masud:~/Downloads$ sudo mv sqldeveloper /usr/lib
masud@masud:~/Downloads$ cd /usr/lib
masud@masud:/usr/lib$ cd sqldeveloper/
masud@masud:/usr/lib/sqldeveloper$ ls
dataminer ide jdbc jdev.label jviews modules readme.html sqldeveloper sqldeveloper.sh timingframework
icon.png j2ee jdev jlib lib rdbms sleepycat sqldeveloper.exe sqlj view-source-paths.lis
masud@masud:/usr/lib/sqldeveloper$ ls -lrt sqldeveloper.sh
-rw-r--r-- 1 masud masud 71 2011-03-25 14:59 sqldeveloper.sh
masud@masud:/usr/lib/sqldeveloper$ chmod +x sqldeveloper.sh
masud@masud:/usr/lib/sqldeveloper$ ./sqldeveloper.sh

Oracle SQL Developer
 Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.

masud@masud:/usr/lib/sqldeveloper$

You may get a message by SQL Developer that version 1.7 of Java is not supported at this time.

Share this:
January 23, 2012 · (No comments)


Today, I was thinking about what the year 2012 will bring for me. Although in the past, I used to make new year resolutions, I have stopped doing that for a couple of years. However, I have decided to set up some S.M.A.R.T goals for myself. These are:

  1. To get PRINCE2 certified.
  2. To get a driving license.
  3. To get my ILR.
  4. To publish, either in the field of library and information sciences or mobile/multi -agent systems or model based testing.
  5. To be a better photographer and learn more about using my Nikon D3100.
  6. To blog more often.

Now these are in no particular order and they may not sound S.M.A.R.T to you at all, but I have done my calculations on what, why, time scales, etc. and I will slowly share my experiences through this blog (goal number 6).

Let the good times begin :)

Share this:
January 22, 2012 · (No comments)


I was recently asked how to write a palindrome function where a string entered in a text box is confirmed as palindrome by changing the background colour of the text box.

Following is the code for that. If you want to see it live in action, click here.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title>jQuery Textbox Colour Demo</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
    <style type="text/css">
        #textbox.green {background-color:green;}
        #textbox.red {background-color:red;}
    </style>

    <script type="text/javascript">

    $(document).ready(function() {

        $("#textbox").keyup(function() {
            if(($("#textbox").val() == "")) {
                $("#textbox").removeClass("red");
                $("#textbox").removeClass("green");
            }
            else {
                if(isPalindrome($("#textbox").val())) {
                    $("#textbox").removeClass("red");
                    $("#textbox").addClass("green");
                }
                else {
                    $("#textbox").removeClass("green");
                    $("#textbox").addClass("red");
                }
            }
        });
    });

    function reverseString(strval){
        var  reversestrval = "";
        var  len = strval.length;
        for (var i = len ; i > 0 ; i--){
            reversestrval += strval.charAt(i-1)
        }
        return reversestrval;
    }

    function isPalindrome(strval)
    {
        if(strval == reverseString(strval)) {
                return true;
            }
            else {
                return false;
            }
    }
    </script>
</head>
<body>
    Enter string: <input type="text" name="query" id="textbox"/>
</body>
</html>
Share this:
August 21, 2011 · (No comments)


I have recently started using log4perl for logging in Perl.  I have used log4j before and was hoping log4perl delivers in a similar fashion and it surely does. I have found it extremely powerful, especially with different logging levels, categories and appenders available. To write a simple logger, one can write a simple configuration file. For example, I have called this file log4perl.conf:

log4perl.logger=INFO, LOGFILE
log4perl.logger.Loggers.MailLogger=ERROR, Mailer

log4perl.appender.LOGFILE = Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename = ../logs/plif.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss} - [%p] Line %L - %m%n

log4perl.appender.Mailer = Log::Dispatch::Email::MailSender
log4perl.appender.Mailer.to = masud.khokhar@bodleian.ox.ac.uk
log4perl.appender.Mailer.from = Masud Khokhar masud.khokhar@gmail.com
log4perl.appender.Mailer.subject = Fatal Error!
log4perl.appender.Mailer.smtp = smtp.ox.ac.uk
log4perl.appender.Mailer.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Mailer.layout.ConversionPattern = %d{dd MMM yyyy HH:mm:ss} - [%p] Line %L - %m%n
log4perl.appender.Mailer.buffer = 0

and initialise it in the code (I use Readonly but that’s not the important part here):

#### For logging
use Log::Log4perl;
use Log::Dispatch;

#### Global logger initialisations
Readonly::Scalar my $LOG_PATH => '../config/log4perl.conf';
Log::Log4perl->init($LOG_PATH);

#### Set up a file logger for logging
Readonly::Scalar my $FILE_LOGGER => Log::Log4perl->get_logger('logger');

#### Set up a mail logger
Readonly::Scalar my $MAIL_LOGGER =>  Log::Log4perl->get_logger('Loggers::MailLogger');

and then you can log to file by using

$FILE_LOGGER->info( 'Processing record:' . $row_ref->{record_id} );

and send an email by using

$MAIL_LOGGER->fatal( 'Error processing record:' . $row_ref->{record_id} );

Tip: If the mail part of your logging is not working, try installing Mail::Sender through CPAN or through other source (e.g. apt-cache search mail sender)

Share this:
April 18, 2011 · (No comments)


I recently attended McShib, a Scottish Federated Access Management Forum held in Edinburgh on the 24th of February, 2011. Well known Shibboleth developers, Chad La Joie, Scott Cantor and Brent Pullman flew from US to provide us with a roadmap and future of Shibboleth, which I found extremely useful. Considering that I recently jumped into the the world of federated access, I could relate to a lot of frustrations and questions that other colleagues were raising. This also made me realise that I am not the only one who went through those challenges. The good news though is that Shibboleth developers are aware of this, and they are trying really hard to overcome these initial obstacles.

I am going to write down some important points from the presentations for people who were unable to attend but are interested in knowing what happened.

  • Revamp of documentation
  • Looking for a new stable home for Shibboleth
  • Enhance attribute resolver functionality in future, which means you can merge attributes at SP, drop scopes, or do some other things with an attribute on the SP side.
  • The audit logs will be revamped, in Apache shortcode styles which you can use. E.g. %D, %u, etc. You can chose whichever detail you want to go in. You can therefore feed that into log analysers, e.g. AWStats.
  • Embedded discovery service (1.0 beta) releasing very soon. Consumes data from SP 2.4+.
  • The centralized discovery service will also have a major release soon. It will use the embedded DS as UI.
  • The centralized DS will also package a Servlet container within itself, so it lowers the learning barrier for that.
  • IdP 3.0 (major release) – separate credential extraction from validation. (As an example, to dig up things easily from a packaged message). This might be useful for sending credentials through software rather than a browser and then digging response from the returned packaged message.
  • SPNEGO support (so you login to active directory means you login to your IdP).
  • Conditional evaluation will be introduced, e.g. if the username is @student, it goes to one LDAP directory, and if the username is @staff, it goes to another.
  • Out of the box attribute consent engine, similar to uApprove (Shib documentation has screenshots for IdP 3.0).
  • Performance metrics will be introduced for IdP, e.g. that filter policy is taking a long time to run, e.g. that LDAP server is not responding in time, etc.
  • IdP 3.0 shipped with installer configured container (again lowers learning barrier).
  • Metadata Aggregator (to overcome the so called national boundaries).
  • ETag and Last-Modified based conditional GETs for metadata. Already supported by UK metadata servers. Not gzip compression yet though.
  • Metadata is now reloaded in a background thread. IdP 2.2 and SP 2.4 supports this.
  • Dynamic metadata retrieval
  • Just in time fetching of metadata by entity ID.
  • As Sha1 becomes weak, rollout of new cryptographic algorithms is becoming an important question. However, rollout can cause problems. Does your relying party support the same, e.g. Sha512.
  • In future, simple string attributes will be supported for release filter policy which is based on entity attributes (e.g. EU, so release the name attribute, US so don’t).
  • For better UI purposes, the metadata has two new extensions.
    • UIInfo – display name, description, logo, keywords, information and privacy URLs
    • DiscoHints – IP Address ranges, domain names, geolocations. This is used for sorting purposes in the discovery services. Discovery service will not automatically pick or remove an IdP on this basis.
  • Regarding SP UI, there should be a focus on Lazy Sessions and use of isPassive (do not disturb the user unless absolutely necessary). True SSO experience.
  • SP UI should use errors that tell a user to contact the support team of the organization in question, not their home organization.
  • Regarding IdP UI, it is recommended that you put your contact information on all pages, including error.jsp, login.jsp and consent pages which are *.jsp. Put your branding on all pages as well.
  • Keep the login page as simple as possible. Keep each page focussed on one job.
  • Detect and trap lack of LoginContext
    • Happens when people bookmark the authn page.
  • Install uApprove
    • Even if consent isn’t required, informing the user is a good thing.
Share this:
March 2, 2011 · (No comments)


Recently I was looking at various web log analysers that I can use with Apache to generate standard and custom statistics. The package that seemed most promising was AWStats. AWStats does a great job, especially with standard statistics. It is also very easy to install.

However, if you want to see performance related attributes in AWStats, you need to use the “Extra Sections” in AWStats. I was interested in the response time parameter for a query in Apache. As a result, my Apache LogFormat looks something like:

LogFormat “%h %u %l %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %T %D” 443_combined

Where %T represents the response time in seconds (useless as most requests are performed in under a second) and %D represents the response time in microseconds.

Equivalent AWStats log format is:

LogFormat=”%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %other %extra1″

And to show the %extra1 parameter in the graphical page, you use the EXTRA SECTIONS.

ExtraSectionName1="Response Time (in microseconds)"
ExtraSectionCodeFilter1="200 304"
ExtraSectionCondition1="URL,\/"
ExtraSectionFirstColumnTitle1="Response Time"
ExtraSectionFirstColumnValues1="extra1,([0-9]*)$"
ExtraSectionFirstColumnFormat1="%s"
ExtraSectionStatTypes1=P
ExtraSectionAddAverageRow1=0
ExtraSectionAddSumRow1=0
MaxNbOfExtra1=200
MinHitExtra1=1

Details of these parameters are in sample AWStats config file.

To configure AWStats to keep the data before Apache logs are rotated, you can write a pre-rotate routine in /etc/logrotate.d/apache2 just above postrotate, e.g.

prerotate
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=/etc/awstats/awstats.YOUR-CONFIG-FILE-NAME.conf

Share this:
February 18, 2011 · 2 comments