Sunday, April 5, 2015

Configuring SSL in Apache Web server

 SSL certificates to enable HTTPS.

The following documents the steps required to generate the SSL certificate and install/configure it in Wildfly.

You can get some cheap SSL certificates here: https://www.ssls.com or godaddy.com

First you need to create a CSR (certificate signing request). It’s recommended to use at least a 2048 bit key and you can generate one with the following command:


1  openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.com.key -out yourdomain.com.csr
The output will be similar to the following:

Generating a 2048 bit RSA private key
...............................................................................+++
...........+++
writing new private key to 'yourdomain.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Next answer the questions you are prompted for:

Country Name (2 letter code) [AU]:NZ
State or Province Name (full name) [Some-State]:Canterbury
Locality Name (eg, city) []:Christchurch
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Dark Horse Software
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:yourdomain.com
Email Address []:<a valid email address> (I use ssl@yourdomain.com)

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:<secret password>
An optional company name []:

Finally you are ready to request your SSL certificate. Go and purchase a certificate from any trusted SSL certificate provider. A standard certificate is probably all you need for basic security. I get mine from: https://www.ssls.com.

After purchasing you will need to activate your certificate. Your provider will ask you to copy and paste in the CSR you created above. Copy everything in that file.

~$ cat yourdomain.com.csr
-----BEGIN CERTIFICATE REQUEST-----
<Random characters in here>
-----END CERTIFICATE REQUEST-----

After your certificate is issued download it (and unzip if needed).

<VirtualHost *:443>
    ServerName yourservername
    SSLEngine on
    SSLCertificateFile /etc/httpd/ssl/daebd1197e697cdd.crt
    SSLCertificateKeyFile /etc/httpd/ssl/opentap.in.key
    #modjk mount
   <Location />
      JkMount node1
      Order deny,allow
      Allow from all
  </Location>
</VirtualHost>

Saturday, April 4, 2015

Configuring SSL in JBOSS Wildfly 8

   I’ve just set up a couple of servers running Wildfly 8 and they needed SSL certificates to enable HTTPS. The following documents the steps required to generate the SSL certificate and install/configure it in Wildfly.

You can get some cheap SSL certificates here: https://www.ssls.com or godaddy.com

First you need to create a CSR (certificate signing request). It’s recommended to use at least a 2048 bit key and you can generate one with the following command:


1  openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.com.key -out yourdomain.com.csr
The output will be similar to the following:

Generating a 2048 bit RSA private key
...............................................................................+++
...........+++
writing new private key to 'yourdomain.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Next answer the questions you are prompted for:

Country Name (2 letter code) [AU]:NZ
State or Province Name (full name) [Some-State]:Canterbury
Locality Name (eg, city) []:Christchurch
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Dark Horse Software
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:yourdomain.com
Email Address []:<a valid email address> (I use ssl@yourdomain.com)

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:<secret password>
An optional company name []:

Finally you are ready to request your SSL certificate. Go and purchase a certificate from any trusted SSL certificate provider. A standard certificate is probably all you need for basic security. I get mine from: https://www.ssls.com.

After purchasing you will need to activate your certificate. Your provider will ask you to copy and paste in the CSR you created above. Copy everything in that file.

~$ cat yourdomain.com.csr
-----BEGIN CERTIFICATE REQUEST-----
<Random characters in here>
-----END CERTIFICATE REQUEST-----

After your certificate is issued download it (and unzip if needed). You will also need the CA (Certificate Authority) root bundle. This is basically the SSL certificate providers credentials proving they are trusted. Once you have these you need to create a Java keystore file. This is a two step process. First creating a pkcs12 file from your SSL certificate and then importing that into a keystore file.

Step 1

openssl pkcs12 -export -in yourdomain.com.crt -inkey yourdomain.com.key -out yourdomain.com.p12 -name default -CAfile your_provider_bundle.crt -caname root

Step 2
keytool -importkeystore -deststorepass <secret password> -destkeypass <secret password> -destkeystore yourdomain.com.jks -srckeystore yourdomain.com.p12 -srcstoretype PKCS12 -srcstorepass <secret password used in csr> -alias default

Copy the new keystore file to the your Wildfly configuration directory

sudo cp yourdomain.com.jks /usr/local/wildfly/wildfly-8.1.0.Final/standalone/configuration/


Insert the following into your standalone.xml in the <profile></profile> section.

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
            <buffer-cache name="default"/>
            <server name="default-server">
               <!-- <http-listener name="default" socket-binding="http"/> -->
                <https-listener name="https" socket-binding="https" security-realm="UndertowRealm"/>
                <host name="default-host" alias="localhost">
                    <location name="/" handler="welcome-content"/>
                    <filter-ref name="server-header"/>
                    <filter-ref name="x-powered-by-header"/>
                </host>
            </server>
            <servlet-container name="default">
                <jsp-config/>
            </servlet-container>
            <handlers>
                <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
            </handlers>
            <filters>
                <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
                <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
            </filters>
        </subsystem>

insert the following lines in

<security-realms> </security-realms> section in standalone.xml
<security-realm name="UndertowRealm">
<server-identities>
<ssl>
<keystore path="yourdomain.com.jks" relative-   to="jboss.server.config.dir" keystore-password="<secret password>"/>
</ssl>
      </server-identities>
</security-realm>

Commands for restarting the wildfly

stop command: from wildfly bin dir ./jboss-cli.sh --connect command=:shutdown

Start command: nohup ./standalone.sh

You are done. now you can access the server by https

Installing SVN Repository in Linux

Steps for installing SVN repository installation in linux

1. Update pre-installed software:
# sudo yum update -y

2. If Apache is not installed (guide):
    # sudo yum groupinstall "Web Server" "MySQL Database" "PHP Support"
    # sudo yum install php-mysql
    # sudo service httpd start

3. Install subversion and mod_dav_svn (should see a long list of all changes):
# sudo yum install mod_dav_svn
# sudo yum install subversion

4. Edit the Apache configuration file for subversion:
# sudo vi /etc/httpd/conf.d/httpd.conf
    include the following lines

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<VirtualHost *:70>
 <Location /repos>
DAV svn
SVNParentPath /var/www/svn
SVNListParentPath On
SVNPathAuthz On
AuthType Basic
AuthName "Subversion"
AuthUserFile /var/www/svn-auth/passwd
AuthzSVNAccessFile  /var/www/svn-auth/access
Require valid-user
Order deny,allow
Allow from all
  </Location>
</VirtualHost>

5. Modify the DocumentRoot and Listen port
DocumentRoot "/var/www"
Listen 70

6. Create the directory which will contain the subversion repository:
# sudo mkdir /var/www/svn

7. Create the directory which will contain the permissions files.
# sudo mkdir /var/www/svn-auth

Create the permission file:
# sudo vi /var/www/svn-auth/access
And fill it with (replace Eswar, Rajasekar, Simbu with your usernames):
[/]
Eswar = rw
Rajasekar = rw
Simbu = rw

8. Create and add to the password file (use -c the first time to create)
# sudo htpasswd -cb /var/www/svn-auth/passwd Eswar pwd
# sudo htpasswd -b /var/www/svn-auth/passwd Rajasekar pwd
# sudo htpasswd -b /var/www/svn-auth/passwd Simbu pwd

9. Create a repository (REPONAME is the name of your repository eg projectrepo):
    # cd /var/www/svn
    # sudo svnadmin create REPONAME

10. Change files authorization (again after creating new repos too):
# sudo chown -R apache.apache /var/www/svn /var/www/svn-auth
# sudo chmod 600 /var/www/svn-auth/access /var/www/svn-auth/passwd

11. Start apache web server:
    # sudo service httpd restart

Verify the subversion repo by opening in a browser:

http://YOUR_INSTANCE_IP/repos/REPONAME

You are done! Connect via Tortoise svn client using the url above.

Linux Commands

To open bundle zip files :

  delete source        : bzip2 -d file.bz2
  keep the source    : bzip2 -dk file.bz2


To extract the tar files:

     tar -xvf myfile.tar
     tar -xzf myfile.tar.gz

To Check the linux version:

     cat /etc/redhat-release

To find the size of particular file:

      find . -name () -exec ls -l {} \;
      find . -name ReflectionUtil.class -exec ls -l {} \;
      find . -name my.cnf -exec ls -l {} \;

SONAR setup

Please follow below given steps for setting up SONAR in local dev environment:

1. Download Sonar from following link: http://dist.sonar.codehaus.org/sonar-3.5.1.zip
2. Unzip and save the downloaded sonar zip in localfile system.
3. Navigate to sonar bin path for example C:\Softwares\sonar-3.5.1\bin\windows-x86-64
4. Execute StartSonar.bat. In this step sonar is started. leave the comand prompt as it is.
5. Go to  Browser and access  sonar by http://localhost:9000
6. We can login to sonar using the login and password admin:admin
7. Go to Settings->Quality Profiles. Click on "Restore Profile" on the top right and select the            Sonar_Rules.xml which is attached below. Now you should see new Quality Profile "Sonar_Rules".    Set it as default.
8. Go to Settings->Configuration->Exclusions. Add following exclusions to Source File Exclusions section. This is to exclude unnecessary source files in metric calculations.
com/compname/project/**/model/**/*.java
com/compname/project/**/*Constant*.java
com/compname/project/**/*Exception.java
9. Navigate to root of your project path using windows command prompt and run: mvn sonar:sonar - In this step, our project build will be deployed in sonar
10. We can see our project listed on the Home screen. we can see the sonar report generated during ST build 

Creating a jar file in Command Prompt

The following are the steps to create the jar from command prompt
1.  Start Command Prompt.
        Navigate to the folder that holds your class files:
        C:\>cd \myproject
2.  Ignore this step if you already set the java path in environment variables
    To Check if it is already done run the below command
        echo %path
Set path to include JDK’s bin.  For example:
        C:\myproject> path c:\Program Files\Java\jdk1.7.0_25\bin;%path%                            
3.  Compile your class(es):
        C:\myproject> javac *.java
4.  Create a manifest file and your jar file:
        C:\myproject> echo Main-Class: MyMainClass >manifest.txt
        C:\myproject> jar cvfm MyJar.jar manifest.txt *.class
        - c for creating jar
        - v for verbos for displaying jar information on command prompt while jar itself
        - f for jar name
        - m for referring manifiest file                            
5.  Test your jar:
        c:\myproject> java -jar MyJar.jar

Sunday, December 15, 2013

refresh parent window while closing child popup window using javascript


parent script:
===========
win = window.open(mypage,myname,settings);

in child window code:
 ==============
window.onunload = function() {              
    window.opener.location.reload();
};

or

window.onbeforeunload  = function() {               
  window.opener.location.reload(); 
};

Difference between onunload and onbeforeunload is

using window.onunload , able to get an event called when user navigates to a different page from onepage to another . However nothing happens when the tab is closed from the minimized view (X)

Using window.onbeforeunload, I neither get an an event called even if the user navigates to a different page from onepage to another OR if he closes the tab (X) from the minimized view.

Friday, November 2, 2012

Reset Lost/Forgotten root password for MySQL

The following are the steos to restore MySQL root password that is lost/forgotten.

Step 1: Stop MySQL daemon if it is currently running    
     Command to find the MySQL Pid and kill the MySQL process
                ps –ax|grep mysql
                kill -9 pid
Step 2: Run MySQL safe daemon with skipping grant tables
                 mysqld_safe --skip-grant-tables & 
Step 3: Login to MySQL as root with no password
                 mysql -u root mysql
Step 4: Run UPDATE query to reset the root password
          UPDATE user SET password=PASSWORD("ualue=42") WHERE user="root";
      FLUSH PRIVILEGES; 
Step 5: Stop MySQL safe daemon
         Command to find the MySQL safe daemon Pid and kill the MySQL process
               ps –ax|grep mysqld_safe
               kill -9 pid
Step 6: Start MySQL
                            /etc/init.d/mysql start
Step 7: Login into MySQL using root password                          
                           mysql -uroot -proot
 

Thursday, August 16, 2012

Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules”


    While Adding/Removing the projects in tomcat server from eclipse , I am getting issue as “ Tomcat version 6.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 Web modules”. We are unable to add the project in server.
Its occuring since mismatch of jst version.

  

Solution

In project, “.settings” folder, find this file “org.eclipse.wst.common.project.facet.core.xml“, change the version of facet="jst.web" to 2.4 or 2.5.
File : org.eclipse.wst.common.project.facet.core.xml



<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.6"/>
<installed facet="jst.web" version="2.5"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>



"There are no resources that can be added or removed from the server eclipse tomcat"


      I have created the Appfuse project . Its running fine in maven jetty server. I would like to run this project in tomcat server. I have added the tomcat server in eclipse and I have tried by right clicking tomcat server and Add remove..., it says "There is no resources that can be added or removed from the server".

Solution:

      I think eclipse is not recognizing our project as a Dynamic Web Application.
I have followed the following steps for fixing this issue.

    Select Project ==> Properties ==> Project Facets and make sure Dynamic Web Module check box is checked


 

Monday, July 30, 2012

org.codehaus.mojo:buildnumber-maven-plugin:maven-plugin:1.0-beta-1-SNAPSHOT - ubuntu 11.10

      A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

    org.codehaus.mojo:buildnumber-maven-plugin:maven-plugin:1.0-beta-1-SNAPSHOT

Problem:

       if ubuntu and Ant tool version is mismatch, we could not download the maven repository.

Solution:

          Use the following latest Ant dependency version and try.
       <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.2</version>
<scope>compile</scope>
</dependency>

 

libglib2.0-0 : Breaks: gnome-control-center (< 1:3) but 1:2.32.1-0ubuntu15 is to be installed E: Broken packages

    I got the following error while installing mysql-server in ubuntu 11 version

   The following packages have unmet dependencies:  libglib2.0-0 : Breaks: gnome-control-center (< 1:3) but 1:2.32.1-0ubuntu15 is to be installed E: Broken packages

Solution:
    
         sudo apt-get install gnome-control-center

Wednesday, July 25, 2012

Tamil Font support in Google Chrome Browser in ubuntu.

Go to freefont directory
  cd /usr/share/fonts/truetype/freefont/

Remove the following fonts

  rm -rf FreeSans.ttf
  rm -rf FreeSerif.ttf

Monday, July 23, 2012

(13)Permission denied: make_sock: could not bind to address

   In apache, this type of error occurs at the time of starting the service after editing the httpd.conf file to listen to a particular port number. The reason is apache allows only specified http port numbers, and the one you have given is not available in http port list

   We can check the http port list whether our port is available or not using the command given below.

semanage port -l|grep http

If the port number is not in the list (ex: 4080), add by using,
semanage port -a -t http_port_t -p tcp 4080


Now restart apache.

Stored Procedure for reading data from CSV file

    The following are the sample Stored Procedure for reading the data from CSV file and insert into database table.

    DELIMITER //
DROP PROCEDURE IF EXISTS `CHECKSERIALNUMBER`;
DROP TABLE IF EXISTS `SERIAL_NUMBER_TEMP_TABLE`;
CREATE TABLE `SP_TEST`.`SERIAL_NUMBER_TEMP_TABLE`(`ID` INT(5) NOT NULL ,`SERIAL_NUMBER` VARCHAR(255));
LOAD DATA LOCAL INFILE '/home/eswar/file.csv' INTO TABLE `SP_TEST`.`SERIAL_NUMBER_TEMP_TABLE`
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 LINES;
CREATE PROCEDURE `CHECKSERIALNUMBER`()
BEGIN
DECLARE _COUNT INT;
DECLARE _I INT DEFAULT 1;
DECLARE _SNO VARCHAR(255);
DECLARE _SNOEXIST VARCHAR(255);
SELECT COUNT(*) INTO _COUNT FROM `SERIAL_NUMBER_TEMP_TABLE`;
WHILE _COUNT >= _I DO
SELECT `SERIAL_NUMBER` INTO _SNO FROM `SERIAL_NUMBER_TEMP_TABLE` WHERE ID=_I;
SELECT `SERIAL_NUMBER` INTO _SNOEXIST FROM `RT_TEST__TABLE` WHERE `SERIAL_NUMBER`=_SNO;
IF _SNOEXIST IS NULL THEN
SELECT _SNO,'Not Exist';
ELSE
SELECT _SNO,'Exist';
END IF;
SET _I=_I+1;
SET _SNOEXIST = null;
END WHILE;
END //
DELIMITER ; 



Friday, July 20, 2012

"Please enter your secure storage password" in Eclipse Helios.

      This alert prompt will be appearing and killing us while installing any plugin in eclipse.
if we forgot the password then no need to explain the situation. To get rid from this we have to disable completely the secure storage password of Eclipse Helios

need to delete this folder from home directory and restart the eclipse:

    ../.eclipse/org.eclipse.equinox.security


Tuesday, July 17, 2012

Upload a file in a single click using jQuery as in gmail attachement

In older days, user wants to browse the button, choose the file and click the upload button for attaching the file.

Nowadays user does not like more mouse click operation. They all are would like to perform all operations within a single click.

The following jquery script is used to upload a file in single click.


<a id='uploader' href='javascript:void(0)'>Add Attachment</a>

   upclick(
     {
      element: uploader,
      action: '/file/fileUpload.action?method=fileUpload,
      dataname:'upload',
      oncomplete:
        function(response_data)
        {
            alert('Data has been sent successfully');
        }
     });
 }


* note: Have to include the attached js file

Monday, July 16, 2012

Problem in compiling and installing a simple maven project

While running “mvn install” We may receive the following error:

Error installing artifact's metadata: Error installing metadata:
Error updating group repository metadata
input contained no data


Reason:


      The problem here was an empty/corrupted maven-metadata-local.xml in our local repository of the artifact wanted to install.


Solution:

   Find the maven-metadata-local.xml using below given command

   sudo find / -name maven-metadata-local.xml -empty -print


   Remove the file maven-metadata-local.xml from that location and run "mvn install". This will work perfectly.