Wednesday, September 7, 2011

Signer information Does not Match ... in the same package

In this post we will figure the solution for a very common and important issue when you trying to implement some javabeans. ( htmlbutton ,clientinfos,......)
the problem is when you trying to use some javabeans like "clientinfos" that used to get client machine information like " Mac address" , and you are also already using some javabeans that have the same class names . ( the problem will be arisen when your class exist in the same package as the other class in another java bean )

the solution is simply " recreate your java class in your own package or another package"

for oracle developers the target is to recreate the jar file through the following steps :
1- if you have the .java files for you class so you can go to the next step , but if you don't have . java files so you have to download any software to decompile .class files (Dj java decompiler 3.12 software used in this demo and working successfully)
2-open the Jdevloper and create new project
3-inside your project add new java class and name it as the original class exactly ( case sensitive) and make the package name unique name "htmlpackage"
4-paste the source code from .java file to Jdeveloper and edit the first line "package oracle.forms.demos " fore example to your package name
5- after that compile if there are any errors related to missing libraries , go to your project and select properties and then add the required libraries to your project
6-add deployment profile to your project as jar file and name it as you want and select the main class for it
7-go to the jarfile .deploy and select deploy to jar ( your jar file create in deploy path in your project folder)
8- just signing your jar before using
under the JDK \ bin use the following command
jarsigner -storepass ........ -keypass ....... yourjarfile mykey
9- the only change that you will make after that if your jar file name is the same it to change the implementation class property used in your form to your new package fore example instead of oracle.forms.fd.HtmlButton use yourpackagename.HtmlButton

Saturday, May 21, 2011

Dynamic Function To Get Any Description Column By ID

here we will provide a dynamic Function to get any description of any table by only passing the table name , The ID column name , The Description " the value that you want to get" , The unique value for the id
-- you can modify this function to just take the table name and the id value , as you can define the id column in the database and also the description
CREATE OR REPLACE FUNCTION GET_DN(P_TABLE_NAME VARCHAR2,P_CODE VARCHAR2,P_NAME VARCHAR2,P_CODE_VALUE VARCHAR2 )RETURN VARCHAR2 IS
V_sQL VARCHAR2(500);
CURID NUMBER;
V_CODE varchar2(50);
V_NAME varchar2(100);
v_count number;

BEGIN
v_sql:='select '||P_CODE ||' ,'||P_NAME ||' from '||P_TABLE_NAME || ' WHERE '||P_CODE||'='||''''||P_CODE_VALUE||'''';
curid:=dbms_Sql.open_cursor;
dbms_sql.parse(curid,v_sql,dbms_sql.native);
v_count:=DBMS_SQL.execute(curid);
--return v_count;
dbms_sql.define_column(curid,1,v_CODE,50);
dbms_sql.define_column(curid,2,v_NAME,100);
if DBMS_SQL.fetch_rows(curid)>0 then
dbms_sql.column_value(curid,1,v_CODE);
dbms_sql.column_value(curid,2,v_NAME);

DBMS_OUTPUT.PUT(V_NAME);
dbms_sql.close_cursor(curid);

else
v_name:= 'No Rows';

END IF ;

RETURN v_NAME ;
---return v_sql;
END;

Monday, May 2, 2011

JRE Mixing Code Probem " Swing Tree"

as the first using for the JRE will be some of java beans that doesn't work with oracle jinitiator like ( Swing buttons , swing tree , Fully Gradient canvases ) , you may face some problems when trying to implement some of these java beans , this related to jar signing all jar files should be signed , the other problem is the java will raise the following exception " signer information does not match trust level of other classes in the same package"
you can overcome with this issue by setting one parameter in the java in the control panel

go to control panel ---> Java ---> advnced ---> Security --- Mixed code Security verification set its value to disable verification

Sunday, May 1, 2011

Using JRE instead Of Jinitiator to run Oracle Forms

as jinitiator have problems with windows 7 and of course the jinitiator have limited functionality rather than JRE , so you should think strongly replace your calling forms using JRE .
The most important motivator to do this is to know that you will do it very easy while still using the jinitiator in different config :
1- the first step is to create a new config section inside the formsweb.cfg as follow
baseHTML=basejpi.htm
baseHTMLJInitiator=basejpi.htm
baseHTMLjpi=basejpi.htm
baseHTMLie=basejpi.htm
# this parameter control the using of version
jpi_classid=clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA
# this parameter indicate a site specific place to download the jre to the client if the client doesn't already have the jre
# insalled on the client , note that the JREDownload should be defined as virtual directory , and # the exe file should# be existed on the physical location of the
jpi_codebase=http://168.169.1.66:52003/forms/JREDownload/jre16016.exe#Version=1,6,0,16
jpi_mimetype=application/x-java-applet;
jpi_download_page=/forms/jinitiator/us/jinit_download.htm
baseHTMLJInitiator=basejpi.htm
# The archive parameter will be used instead the archive_jini , but note the jar files should be #signed
archive=frmall.jar,frmall_jinit.jar,myappicons.jar
-------------------------------------------------------------------------------
in the forms.conf file you should add the following virtual directory
AliasMatch ^/forms/jre/(..*) "C:\DevSuiteHome_1/forms/jre/$1"
-----------------------------
the final step run your forms using the config jretest

Friday, April 29, 2011

Check Application Password Strength

here basic code to check the strength of your application password if you want to restrict the user by choosing strong password here we just check for the Mixing Characters and the length of the password , you can also append the checking of upper case and lower case mix that is means that the user must enter password that containing mixing case of characters (at least one upper case letter and at least one lower case letter)
create or replace function check_password_stren(p_password varchar2) return number is
0 means the password doesn't meet any requirement
1 means only meet the minimum length
2 means exceed the minimum length
4 means meet the lenght and mixed character and numbers
5 exceed the length and mixed character and numbers
v_min_len number(2):=10 ; --- variable according to your bussiness requirements
v_count number(2);
v_len number(5);
v_mix_state number(5);
begin
v_len:=length(p_password);
if v_len < v_min_len then
v_count:=0;
return v_count;
elsif v_len=v_min_len then
v_count:=1;
else
v_count:=2;
end if ;
v_mix_state:= nvl(length(translate(trim(p_password),'0123456789',' ')),0);
if v_mix_state =0 then ---- it is numbers only
v_count:=v_count+0;
elsif v_mix_state=v_len then -- it is characters only
v_count:=v_count+0;
elsif v_mix_state<>v_len then --- it is mix
v_count:=v_count+3;
end if ;
return v_count ;
end;

Friday, January 21, 2011

Create Encrypted PDF Report from oracle reports


some customers nowadays require to generate PDF reports from oracle that prevent the users from copying its contents or printing this document by the user , so this challenge of course need simple third party that encypt the pdf , but how to implement this soluiton into your application ?

- at first prepare this third party that is $27 ( very cheap ) and monitor one directory for example ( c:\temp) on the application server and make the target directory as any directory inside the apache\htdocs inside the application server , and make other configuration ( password require to open the document yes or no , allow printing yes or no , allow copying contents yes or no , ....)
- after that customize your calling of reports to handle the process , how ?
- before running the report check if the report is encrypted or not , if it is encrypted so make the report file destination to be on the monitored directory ,
after that generate random file name using random package.
- check if the job process is finished , if it is finished so ,create timer of 3 o4 4 seconds ( to allow the third party to finish process )
- after that use web.show_document to show the file (random name) from the target directory

--- note that if you use more than one application server you have to run the third party on each application server , and consider which report server is running to show the document from the right pache\htdocs directory