Search This Blog

Wednesday, July 25, 2012

BIRT Report filters with PHP JAVA Bridge



BIRT Report filters with PHP JAVA Bridge 

$report = $birtReportEngine->openReportDesign("${here}/myreport.rptdesign");
$filter = new java("org.eclipse.birt.report.model.api.elements.structures.FilterCondition"); // create a new filter condition object

$filter->setExpr("row['id']");

$filter->setOperator("in"); 
$filter->setValue1('["32","679","333","233"]');
$report->getDesignHandle()->findDataSet("Employees")->addFilter($filter);

Friday, July 6, 2012

How to create a self-signed SSL Certificate

The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.
Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).
SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring that the data only could have come from the server.
If SSL utilizes public key cryptography to encrypt the data stream traveling over the Internet, why is a certificate necessary? The technical answer to that question is that a certificate is not really necessary - the data is secure and cannot easily be decrypted by a third party. However, certificates do serve a crucial role in the communication process. The certificate, signed by a trusted Certificate Authority (CA), ensures that the certificate holder is really who he claims to be. Without a trusted signed certificate, your data may be encrypted, however, the party you are communicating with may not be whom you think. Without certificates, impersonation attacks would be much more common.
Step 1: Generate a Private Key
The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request). It can also be used to generate self-signed certificates which can be used for testing purposes or internal usage.
The first step is to create your RSA Private Key. This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.
openssl genrsa -des3 -out server.key 1024

Generating RSA private key, 1024 bit long modulus
.........................................................++++++
........++++++
e is 65537 (0x10001)
Enter PEM pass phrase:
Verifying password - Enter PEM pass phrase:
Step 2: Generate a CSR (Certificate Signing Request)
Once the private key is generated a Certificate Signing Request can be generated. The CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate Authority, such as Thawte or Verisign who will verify the identity of the requestor and issue a signed certificate. The second option is to self-sign the CSR, which will be demonstrated in the next section.
During the generation of the CSR, you will be prompted for several pieces of information. These are the X.509 attributes of the certificate. One of the prompts will be for "Common Name (e.g., YOUR name)". It is important that this field be filled in with the fully qualified domain name of the server to be protected by SSL. If the website to be protected will be https://public.akadia.com, then enter public.akadia.com at this prompt. The command to generate the CSR is as follows:
openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [GB]:IN
State or Province Name (full name) [Berkshire]:TamilNadu
Locality Name (eg, city) [Newbury]:Chennai
Organization Name (eg, company) [My Company Ltd]:G
Organizational Unit Name (eg, section) []:Information Technology
Common Name (eg, your name or your server's hostname) []:geotekh.com
Email Address []:m*****@gmail.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Step 3: Remove Passphrase from Key
One unfortunate side-effect of the pass-phrased private key is that Apache will ask for the pass-phrase each time the web server is started. Obviously this is not necessarily convenient as someone will not always be around to type in the pass-phrase, such as after a reboot or crash. mod_ssl includes the ability to use an external program in place of the built-in pass-phrase dialog, however, this is not necessarily the most secure option either. It is possible to remove the Triple-DES encryption from the key, thereby no longer needing to type in a pass-phrase. If the private key is no longer encrypted, it is critical that this file only be readable by the root user! If your system is ever compromised and a third party obtains your unencrypted private key, the corresponding certificate will need to be revoked. With that being said, use the following command to remove the pass-phrase from the key:
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
The newly created server.key file has no more passphrase in it.
-rw-r--r-- 1 root root 745 Jun 29 12:19 server.csr
-rw-r--r-- 1 root root 891 Jun 29 13:22 server.key
-rw-r--r-- 1 root root 963 Jun 29 13:22 server.key.org
Step 4: Generating a Self-Signed Certificate
At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate. This temporary certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted.
To generate a temporary certificate which is good for 365 days, issue the following command:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=IN/ST=TamilNadu/L=Chennai/O=*****.,/CN=geotekh.com/emailAddress=m*****@gmail.com
Getting Private key
Step 5: Installing the Private Key and Certificate
When Apache with mod_ssl is installed, it creates several directories in the Apache config directory. The location of this directory will differ depending on how Apache was compiled.
cp server.crt /usr/local/apache/conf/ssl.crt
cp server.key /usr/local/apache/conf/ssl.key
Step 6: Configuring SSL Enabled Virtual Hosts
SSLEngine on
SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
CustomLog logs/ssl_request_log \
   "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Step 7: Restart Apache and Test
/etc/init.d/httpd stop
/etc/init.d/httpd stop
https://geotekh.com

Monday, May 14, 2012

Install a service – windows server 2008

Edit
  1. Run Regedit or Regedt32.
  2. Find the registry entry “HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services”.
  3. Look for the service there and right click on the properties which you want to modify.
Delete
  1. Run Regedit or Regedt32.
  2. Find the registry entry “HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services”.
  3. Look for the service there and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).
Install (via command prompt)
  1. At a command prompt, type: installutil <Path of the Service>
Examples:
  • for .net v1.1:
    C:\> C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe C:\MyService.exe
  • for .net v2.0: 
    C:\>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe
Install (via bat file – .net v2.0 example)
  1. Save the example code as a bat file.
  2. Place the bat file in the same folder as your service exe file.
  3. Run the bat file.
@echo off
echo Starting installation..
pause
REM SET LOGFILENAME=log_%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt
REM date /t >> %LOGFILENAME%
REM time /t >> %LOGFILENAME%
REM pause
echo Current directory..
cd
pause
cls
echo YourServiceName in
cd
pause
C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe YourServiceName.exe
pause
cls
echo Installation completed..
pause

Running JBoss AS 7 as a Windows service

There are a few threads touching this topic but I thought I'd summarize my findings so far in getting JBoss AS 7 up and running as a Windows service.

First of all, grab the appropriate native connectors from http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10 (x86 for 32bit host, x64 for 64bit). Unzip the archive in the JBoss main folder. Then make some modifications to the service.bat file

  1. Rename the SVCNAME, SVCDISP and SVCDESC to something more meaningful. This is optional but if you plan to install multiple servers (e.g. test and production, you want different names.
  2. Modify the JAVA_OPTS to increase memory, service.bat doesn't read any other conf.bat file so it will use default memory settings and will die of memory loss for a mid-sized deployment. Keep the -Xrs setting as I've seen cases where a RDP logout has caused JBoss to shut down. You might also want to add a JAVA_HOME if it's not set as a system wide environment variable
  3. Change all run.bat calls to standalone.bat calls as they are called nowadays
  4. Comment out all "call shutdown" calls and replace then with call jboss-cli.bat --connect command=:shutdown >> shutdown.log 2>&1. This is especially important because the shutdown.bat that was around before is no longer there and it will probably run shutdown.exe from system32 instead, causing a server shutdown. If you run multiple servers you must config the CLI script to connect to the correct management ports set in standalone.xml by adding a --controller=host:mport to the bat call.
  5. Install the service with "service install". You might also want to change the service starting mode to "automatic" and change the "run as" to a normal user. Note that on later Windows-versions, you must run the executing cmd in administrator mode.

Thursday, April 19, 2012

Linux Directory layout

Linux Directory layout

A quick ‘ls‘ command will show you the directory structure of any linux system. Just go to the root directory, ‘cd /‘ and type ‘ls’. In my current system, Ubuntu 8.10 I have:

bin

Bin contains the system binary files that are essential for general operation of your computer. These exectuable files are the next line after the system kernel. Withtout these you can’t do a whole lot of anything on your computer. Some of these include:
  • cp – Copy files to and from
  • ls – Get a directory listing, remember we used this above
  • bash – A popular Linux CLI (shell)

dev

If you are used to other operating systems this will be weird for you. As everything in Linux devices are represented as a directory. This makes it easier for other programs to interact with them. For example mount.
You can use the system binary mount in the /bin folder to interact with a removable hard drive for example.

lost+found

If you have a system crash and the Linux file system checker (fsck) recovers corrupt files they are placed here.

opt

Opt is reserved for additional software you install; although, most providers don’t use it. This is kind of like ‘Program Files‘ for linux.

sbin

Sbin is similar to /bin with the exception that these ready to run binaries are reserved for root users. That is they typically will only work when executed by root or sudo. Examples would include:
  • mke2fs
  • ifconfig
  • fdisk

tmp

Tmp is a temporary storage folder. Anything that is to be temporarily stored goes here. It is recommended that you don’t delete these manually. If you want to delete them you usually add this to boot up or shutdown procedure since they can contain useful information for programs that are already running.

boot

This folder contains only the files that are absolutely necessary to get a basic Linux system up and going. This folder is not used for programs to run on startup or other user scripts. This folder usually contains Grub information and the Linux kernel.

etc

This folder is the config folder for your entire operating system. Almost everything about configuring your system can be done in here. The general rule of thumb is that these files are static and text based. No binaries should be placed in this folder.
Common config files in here are:
  • /etc/X11 – For configuring X (gui)
  • /etc/apt/sources.list – Configuring apt for Debian based systems
  • /etc/cups – Printer configuration
  • /etc/fstab – Device mounting
  • /etc/httpd – Apache webserver

Media

Traditionally all mounts were stored in the /mnt directory but out of controversy of where to stored removable mounts this directory was born. /media should be used to store mounts for removable devices only, like:
  • CD-Rom
  • DVD-Rom
  • Floppy
  • Flash Disks

proc

Proc is a special virtual directory like /dev that contains process information. It contains runtime system info like: system memory, devices mounted, hardware configuration, etc.

srv

Srv is a serve folder. It holds site specific data to be served by the system for protocols such as, ftp, rsync, www, cvs etc. To be compliant distributions include this folder but I have not seen it used much.

usr

Usr houses all the binaries, documentation, libraries, and header files for all the user applications. Most user binaries will be installed into this folder making this one of the largest folders in the Linux directory.

cdrom

CD-Roms can be mounted to this folder but it is not in the official Linux Filesystem Hierarchy. CD-Roms should be mounted under /media.

home

Home is where you will store all user specific documents and settings. This is similar to Windows, “Documents and Settings”. On most Linux distributions /home will contain a directory with each user’s name or group of users. e.g. /home/mark /home/guests.

lib

Lib contains system library binaries that are required to run the system. In Windows this would be the system folder with .dlls. Only in Linux it is represented by ‘.so‘.

mnt

According to FSSTND version 2.3, ” This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.”
I think of this directory as the place to mount fixed hard drives that I mount with the fstab file, but as described in FSSTND it is primarily for temporary mounts.

root

Root is the “home” directory for root. If this directory doesn’t exist it defaults back to ‘/’. Hence the username root.

sys

This is kinda like /proc it is used for plug and play configuration.

var

This stands for variable. This stores all the files that vary as the system runs. Things like log files, backups, mail, cache, etc..