Monday, September 20, 2010

integration of recaptcha in java web application

Step 1. Register your account and get key

First, go to the reCAPTCHA web site and create an account. As part of that account creation process you'll have to specify the domain your reCAPTCHA will be protecting.
The reCAPTCHA site will will give you a key pair for that domain. The key pair allows you to authenticate your reCAPTCHA requests to the reCAPTCHA servers, as we'll see.

Step 2. Put reCAPTCHA JavaScript code in your application

Following JavaScript code you need to put in your JSP / HTML page, This JavaScript will generate the reCAPTCHA box when users request the page:

















You need to put with the public key that you received during the account creation process.
Be careful that you don't use your private key by mistake. If you do that then everybody will be able to see your private key and act like they're you.

Step 3. add a following code in servlet

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {

String challenge = req.getParameter("recaptcha_challenge_field");
String response = req.getParameter("recaptcha_response_field");
String remoteAddr = req.getRemoteAddr(); // code for live
// If you test on local site then need to put ipaddress where you register you site at the time of account creation
// e.g. String remoteAddr=192.168.40.58 // live ip address

ReCaptchaImpl reCaptcha = new ReCaptchaImpl();

reCaptcha.setPrivateKey("");

ReCaptchaResponse reCaptchaResponse =
reCaptcha.checkAnswer(remoteAddr, challenge, response);
boolean valid = reCaptchaResponse.isValid();

String path = null;
if (valid) {
path = "/success.jsp";
} else {
path = "/failure.jsp";
}
res.sendRedirect(req.getContextPath() + path);
}

In above code You need to put with the private key that you received during the account creation process.

Step 4 : Run application

If you are test from localhost/127.0.0.1 then you need to change ip address which is mentioned in above code reCAPTCHA will allow that.

After successfully changes recaptcha works :) enjoy

Wednesday, September 15, 2010

settings for Pentaho BI Server with MySQL DB

 After extracting pentaho-ce-3.5.0.stable.zip on computer then directory structure as follows :
\pentaho\ adminstration-console\
\pentaho\ biserver-ce\

For setting up Pentaho BI Server you need to change in
biserver-ce directory
biserver-ce\
pentaho-solutions\System\applicationContext-spring-security-jdbc.xmlbiserver-ce\pentaho-solutions\System\ applicationContext-spring-security-hibernate.propertiesbiserver-ce\pentaho-solutions\System\ hibernate\hibernate-settings.xmlbiserver-ce\pentaho-solutions\System\ hibernate\ mysql5.hibernate.cfg.xml biserver-ce\tomcat\web-apps\pentaho\WEB-INF\web.xml

biserver-ce\tomcat\META-INF\context.xml

above mentioned file need to change as follows :-

1) applicationContext-spring-security-jdbc.xml For mySQL database you need add Configuration
which is highlight as BOLD
property name="driverClassName" value="com.mysql.jdbc.Driver"
property name="url"
value="jdbc:mysql://localhost:3306/hibernate"
property name="username" value="root"
property name="password" value="root"


2)
applicationContext-spring-security-hibernate.properties

For mySQL database you need add Configuration which is highlight as BOLD jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hibernate
jdbc.username=root
jdbc.password=
root
hibernate.dialect=org.hibernate.dialect.MySQLDialect

3) hibernate-settings.xml
When you opened this file you get following code
system/hibernate/hsql.hibernate.cfg.xmlFor mySQL database you need add Configuration which is highlight as BOLD
system/hibernate/mysql5.hibernate.cfg.xml


5) mysql5.hibernate.cfg.xml

User hibuser - which was created with the script load_sample_users_mysql.sql , If you want to specigy your user you can change in following property

property name="connection.username" rootproperty name="connection.password"
root

and also change same in all above property.


\Tomcat
You have to change in Tomcat directory as location mentioned above.1) web.xml http://localhost:8080/pentaho/
make changes as highlighted in BOLD for Ip address or Domain
http://180.168.10.28:8080/pentaho/
http://www.nilesh.com:8080/pentaho/

2) context.xml

When you open context.xml make following changes for MySQL database


xml version="1.0" encoding="UTF-8"
path="/pentaho" docbase="webapps/pentaho/">
Resource name="jdbc/Hibernate" auth="Container" type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5"
maxWait="10000" username="root" password="root"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/hibernate"
validationQuery="select 1"

Resource name="jdbc/Quartz" auth="Container" type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5"
maxWait="10000" username="root" password="root"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/quartz" validationQuery="select 1"
/Context


I recommend that you resize the command window that displays the Tomcat messages. This will make it easier to read messages that are output by Tomcat.
  • In the top left corner of the Window, click the Java icon.
  • Click Properties.
  • Select the Layout tab.
  • Set the Width = 180
  • Set the Height =300
  • Click OK.

After all successfully changes are done then to start BI server run following bat file

to start BI server :- \biserver-ce-3.5.0.stable\biserver-ce\start-pentaho.bat

to stop BI server :- \biserver-ce-3.5.0.stable\biserver-ce\stop-pentaho.bat

to start administrative console :- biserver-ce-3.5.0.stable\administration-console\start-pac.bat

to stop administrative console :- biserver-ce-3.5.0.stable\administration-console\stop-pac.bat

NOTE

If you are using database as MySQL for BI Server and you are getting (refer forum post)

"PacService.Error_007" error

http://forums.pentaho.com/showthread.php?74727

Well, this tutorial has already taken several hours to write and edit.
I hope I pointed out some of the things that made integration with BI more clear for you. Have fun !

Tuesday, September 14, 2010

Pentaho Business intelligence Server 3.5 stable

Pentaho Business intelligence Server 3.5 stable
  1. most important file you will need to download is the pentaho-ce-3.5.0.stable.zip from sourceforge.
  2. After you have downloaded and extracted the ZIP file in any location of computer. For example I extract zip file on my c: then directory structure as follows :
    c:\pentaho\
    adminstration-console\
    biserver-ce\
  3. We have to do major change in biserver-ce directory.
Note :- when you extract pentaho-ce-3.5.0.stable.zip you also get SQL Script on following location
biserver-ce-3.5.0.stable\biserver-ce\data

Database settings


download the SQL Script Pack for MySQL 5.x and extract in any location of computer.
Following three scripts required to configure pentaho server
  1. create_repository_mysql.sql
  2. create_quartz_mysql.sql
  3. load_sample_users_mysql.sql
If you want examples then install remaining scripts
  1. create_sample_datasource_mysql.sql
  2. sample_data_mysql.sql
After loading above scripts in mySQL database confirm following table list

hibernate
  • authorities
  • datasource
  • granted_authorities
  • users
quartz
  • qrtz_blob_triggers
  • qrtz_calendars
  • qrtz_cron_triggers
  • qrtz_fired_triggers
  • qrtz_job_details
  • qrtz_job_listeners
  • qrtz_locks
  • qrtz_paused_trigger_grps
  • qrtz_scheduler_state
  • qrtz_simple_triggers
  • qrtz_trigger_listeners
  • qrtz_triggers

Pentaho Community Edition 3.5.0

Pentaho Community Edition 3.5.0

The Pentaho BI Suite Community Edition [CE] is an open source business intelligence package that includes ETL, analysis, metadata, and reporting capabilities. The suite is composed of server components and client tools. The server components [also referred to as the BI Platform] consist of the BI Server, the administration console and the user console. The BI server is responsible for management and delivery of reports.


Some of the Pentaho client tools include:


Report Designer: Used to create formatted reports. Report Designer offers far more flexibility and functionality than the ad hoc reporting capabilities of the Pentaho User Console.


Design Studio : An Eclipse-based tool that enables you to hand-edit a report or analysis view xaction file. Generally, people use Design Studio to add modifications to an existing report that cannot be added with Report Designer. Design Studio is also required to enable report scheduling, e-mail distribution, dynamic and static prompting, and more.


Metadata Editor: Enables you to add a custom metadata layer to an existing data source.Usually you would do this for a data source that you intend to use for analysis or reporting; it's not required, but it makes it easier for business users to parse the database when building a query.


Pentaho Data Integration: Also known as Kettle. An extract, transform, and load (ETL) tool, which enables

you to access and prepare data sources for analysis, data mining, or reporting.


Schema Workbench : A graphical tool that helps you create ROLAP schemas for analysis



Required :
  1. version of Java JDK (1.5 or greater) installed on your computer/server.
  2. download SQL Script Pack (MySQL, Oracle 10g or 11g , PostgreSQL 8.x.x) database which you are setting up Pentaho link2 link1
  3. to download is the pentaho-ce-3.5.0.stable.zip
See also
  • http://forums.pentaho.com/showthread.php?72921-Pentaho-3.5-stable-is-now-available-on-SourceForge.

Create MongoDB service in Windows OS

1) Open Command Prompt 2) Create directory for Database and Logs                    mkdir c:\data\db                     mkdir c:\...