May 31, 2012

How to install install and configure SSL on JBoss 5.1

The reason for installing SSL (Secure Socket Layer) is to protected the data received and sent to be read in clear text and instead received and sent encrypted.

The first you need is a Server Certificate. You can get a valid Certificate from Certification Authority (CA) like Thwate, Verisign and many more. But here I will use a self-signed certificate but the process is quite similar for the ones from a Certification Authority (CA).
$ keytool -genkey -alias rsatest -keyalg RSA -keystore server.keystore -keysize 2048 -validity 60
...
Is CN=localhost, OU=MSC, O=MSC, L=Stockholm, ST=Stockholm, C=SE correct?
  [no]:  yes
Remember that the first and last name should be either your domain address or machine name.

And to view your self-signed certificate:
$ keytool -list -v -keystore server.keystore
Now you need configure your HTTPS Connector.

$JBOSS_HOME/server/$JBOSS_CONF/deploy/jbossweb.sar/server.xml:
    <Connector protocol="HTTP/1.1" SSLEnabled="true" 
        port="8443" address="${jboss.bind.address}" 
        scheme="https" secure="true" clientAuth="false"
        keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
        keystorePass="changeit" sslProtocol="TLS" />
There are several more configuration for the Connector which you can read more about here for JBoss 5.1:
http://docs.jboss.org/jbossweb/2.1.x/config/http.html

And the latest documentation is found here:
http://docs.jboss.org/jbossweb/latest/config/http.html

The last thing we need is a test application I will leave that as a practice, but I will show one interesting part and that is the web.xml
<web-app>

    ...

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Security Demo</web-resource-name>
            <url-pattern>/*</url-pattern>
            <!-- Do not specify http-method, since then only specified 
                 http-method will be authenticated, not e.g. JUNK (attack) -->
        </web-resource-collection>

        <auth-constraint>
            <description>These are the roles who have access.</description>
            <role-name>ROLE_FOO</role-name>
        </auth-constraint>

        <user-data-constraint>
            <description>This is how the user data must be transmitted.</description>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>


    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>foo-realm</realm-name>
    </login-config>

    <security-role>
        <role-name>ROLE_FOO</role-name>
    </security-role>

    <session-config>
        <!-- Session timeout after X MINUTES after no user interaction. -->
        <session-timeout>15</session-timeout>
        <cookie-config>
            <!-- XSS attack: make sure that cookie cannot be accessed via 
                 client side scripts -->
            <http-only>true</http-only>
            <!-- CSRF attack, session hijack attack: require cookie can 
                 only be used for SSL communication. -->
            <secure>true</secure>
        </cookie-config>
        <!-- Do not use URL, since then it can be stored in numerous places: 
             browser history, proxy server log, referrer logs, web logs, etc. -->
        <tracking-mode>COOKIE</tracking-mode>
    </session-config>

    ...

</web-app>


Now open you web browser and test your application. To do the same for Tomcat is quite similiar, read more about it in my next blog - http://magnus-k-karlsson.blogspot.se/2012/06/how-to-install-install-and-configure.html.

May 19, 2012

How to find out which version of Ubuntu

From a Terminal (Applications → Accessories → Terminal)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
And to find out if you are running a 32 or 64-bit OS.

$ uname -a
Linux magnus-HP-ProBook-6550b 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

For 64-bit you will see: x86_64
and for 32-bit: i686

Top Things After Installing Ubuntu 12.04 Practical Precise

1. First update your system.


$ sudo apt-get update && sudo apt-get upgrade

2. Enable Restricted drivers available

Open Additional Drivers and select Recommended driver.





3. Remove overlay bar:


$ sudo apt-get remove overlay-scrollbar liboverlay-scrollbar3-0.2-0 liboverlay-scrollbar-0.2-0


4. Add Medibuntu Repository



http://medibuntu.org/repository.php

5. Install Common Codecs



$ sudo apt-get install non-free-codecs libxine1-ffmpeg gxine mencoder totem-mozilla icedax tagtool easytag id3tool lame nautilus-script-audio-convert libmad0 mpg321


6. To play encrypted DVDs



$ sudo apt-get install libdvdcss2  
$ sudo /usr/share/doc/libdvdread4/./install-css.sh


7. Install Non Open Source Programs



$ sudo apt-get install ubuntu-restricted-extras


8. Install Video Player



$ sudo apt-get install vlc


9. Video Editor

There are several easy to use video editors out there: Here are two:
  • Avidemux
  • Openshot
You install both from Ubuntu Software Center.

10. Torrents client - qBittorrent

A Simple to use Bittorrent client is qBittorrent. You install it easily from Ubuntu Software Center.

11. Manage Unity - MyUnity

If you are not happy with the dock you can easily change it's appearance with MyUnity. You install from Ubuntu Software Center.

12. Oracle Java 6 

If think the best way to install Oracle Java SDK is to do it manually. An easy to use guide is here https://help.ubuntu.com/community/Java.

13. Set $JAVA_HOME

I have previously describe how to set the Java environment home variable here: http://magnus-k-karlsson.blogspot.se/2012/04/how-to-set-javahome-environment.html
 

14.Keyboard Shortcut 




15. New Launcher (Shortcut) in Dock

I have previously described it here:
http://magnus-k-karlsson.blogspot.se/2012/01/how-to-make-launcher-shortcut-in-new_31.html

16. LibreOffice

If you need to install more language for spelling checking, first download the wanted

http://extensions.libreoffice.org/extension-center?getCategories=Dictionary&getCompatibility=any&sort_on=positive_ratings&path=%2FLibreOffice-Extensions-and-Templates%2Fextension-center&portal_type=PSCProject&SearchableText=swedish

How to install:

http://wiki.documentfoundation.org/Documentation/HowTo/install_extension

Restart.

Check installation under Tools -> Options -> Language Settings -> Writing Aids and Edit Module.