try out the java security guide,created the policy file,saved as a examplepolicy in local folder,the go to run the command line that invoke the applet view from sun.
appletviewer -J-Djava.security.policy=examplepolicy http://docs.oracle.com/javase/tutorial/security/tour1/examples/WriteFile.html
if we run the appletviewer from the folder that contains examplepolicy,the applet will be correctly run.oterwise the examplepolicy can not be find,so the applet will fail.
since the default jre\lib\security\java.security has a default item that load the policy from {user_home}\.java.policy,we can save newly created policy into that file,the invoke the applet anywhere,just make sure has the permission to write to that folder.
developers normally set up their JAVA_HOME to a JDK, so make sure change the java.security file in JDK\JRE\lib\security\java.security ,not the file under Program Files\Java\Jre\lib\security\java.security
Monday, December 10, 2012
locally fill a PDF form from FDF file
while open the insurance company online PDF documentation,it should automatically fill the claim form with logged in personal information.but it is downloading a file content call FDF, forms data format file which was used to fill the pdf.
open up the FDF file,found out that the file contains the url of the pdf file,I change that url to pdf file that downloaded previously from the same web site,vola, when double click th FDF file,the pdf was opened and automatically filled with information in FDF file.
take a look at the FDF file,we can also change the information in FDF to fill the PDF form.
open up the FDF file,found out that the file contains the url of the pdf file,I change that url to pdf file that downloaded previously from the same web site,vola, when double click th FDF file,the pdf was opened and automatically filled with information in FDF file.
take a look at the FDF file,we can also change the information in FDF to fill the PDF form.
Friday, November 23, 2012
Outlook Runtime Error -2147221233 The operation failed. An object cannot be found
This error comes out after my windows 7 get updated from microsoft, maybe some for outlook
in my VBA code ,I have following code to move a message to another folder.
Msg.Move objNS.Folders(2).Folders("foldername")
is suddenly pop up the error messages,did some debug,find out that we need change to following code now
Msg.Move objNS.Folders(1).Folders(13)
all index started with 1
objNS.Folders(1) is first folder in my outlook name space
objNS.Folders(1).Folders(13) is the 13th sub folder in previous folder,there is not method to get a sub folder by it's name,maybe a iteration will help to find the folder with specific name,but it is too heavy here,if we do not add new sub folder between first one and 13th,then we will be ok with previous code.
in my VBA code ,I have following code to move a message to another folder.
Msg.Move objNS.Folders(2).Folders("foldername")
is suddenly pop up the error messages,did some debug,find out that we need change to following code now
Msg.Move objNS.Folders(1).Folders(13)
all index started with 1
objNS.Folders(1) is first folder in my outlook name space
objNS.Folders(1).Folders(13) is the 13th sub folder in previous folder,there is not method to get a sub folder by it's name,maybe a iteration will help to find the folder with specific name,but it is too heavy here,if we do not add new sub folder between first one and 13th,then we will be ok with previous code.
Wednesday, November 21, 2012
Installing the IDEA Module in GnuPG
(THIS INFORMATION COMES FROM http://www.spywarewarrior.com)
The "official" Win32 builds of GnuPG do not include support for the IDEA algorithm, which is patented.* This can prove to be a problem when exchanging messages and files with PGP users (esp. PGP 2.6.x users) or importing old PGP keys. This web page explains how to install the IDEA module for GnuPG so that GnuPG can use the IDEA algorithm.
The IDEA module has been distributed as both a source code file (IDEA.C) and a compiled .DLL (IDEA.DLL). Unless you plan to compile the source code yourself, you want the IDEA.DLL, which is placed somewhere in the GnuPG installation directory and loaded with the load-extension option.
Please note that the IDEA module, its location within the GnuPG installation directory, and the method for loading that module with the load-extension option have changed over successive versions of GnuPG:
Please consult the appropriate directions for your version of GnuPG. All of the versions of the IDEA module discussed on this page are available for download from this site -- see the Downloadssection below.
* The IDEA is patented in many countries, including the U.S., and may be used for non-commercial
purposes. For commercial uses you'll need to buy a license from MediaCrypt. For the "official"
explanation of why the IDEA algorithm is not supported in GnuPG by default see HERE.
purposes. For commercial uses you'll need to buy a license from MediaCrypt. For the "official"
explanation of why the IDEA algorithm is not supported in GnuPG by default see HERE.
GnuPG 1.2.0 and later
There were big changes in GnuPG 1.2.0 with respect to the IDEA module. There's a new IDEA.DLL as well as a change from previous versions in the way the IDEA.DLL is loaded.
From the GnuPG 1.2.0 Announcement:
From the GnuPG 1.2.0 Announcement:
* All modules are now linked statically; the --load-extension option is in general not useful anymore. The only exception is to specify the deprecated IDEA cipher plugin. * The IDEA plugin has changed. Previous versions of the IDEA plugin will no longer work with GnuPG. However, the current version of the plugin will work with earlier GnuPG versions.
Files
For "official" versions of GnuPG (from gnupg.org), a new set of IDEA files is available from ftp.gnupg.dk (idea.c.gz & ideadll.zip):
File Size (kb) Notes idea.c 13815/13727 new source (gnupg.org) idea.dll 8192 new Win32 DLL (gnupg.org)
File Size (kb) Notes idea.dll 45056 Disastry's IDEA module
See the Downloads section below for links to these files.
To Install
1. Place the IDEA.DLL in \LIB sub-dir of the GnuPG installation dir.
2. Add the following line to the GPG.CONF file (in previous GnuPG
versions it was in the OPTIONS file):
versions it was in the OPTIONS file):
- load-extension Lib\idea
You can also specify a full path to the IDEA.DLL file:
- load-extension C:\GnuPG\Lib\idea.dll
This GPG.CONF file option line works for both the "official" and
Nullify GnuPG builds.
Nullify GnuPG builds.
Friday, September 21, 2012
Web Service in Windows .Net
I followed a Shiv Pal Singh's post in CodeGuru that create a web service with .net in windows without a studio tools,here is the steps and content that recorded to help me remember.
1) install the IIS from windows 7,after installation the server is up,default page(actually is a html with one picture
embedded with lot of links) can be see in browser.
2) add a default html in server's newly created virtual directory can also be see in browser,but the asmx web service file
can not be see in browser because of the script handler is not properly registered in system
go to c:\windows\Microsoft.NET\Framework64\v.2.0.50727,run following command
ASPNET_REGIIS.exe -I
remember this is 64 bit,not 32,running 32 in 64 will get a error
then stop and start the server:
net stop w3svc
net start w3svc
3) copy following content in to virtual directory,name is as FirstService.asmx, language is CS,not C
<%@ Page Language="C#" %>
<script runat="server">
void runSrvice_Click(Object sender, EventArgs e)
{
FirstService mySvc = new FirstService();
Label1.Text = mySvc.SayHello();
Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
Int32.Parse(txtNum2.Text)).ToString();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<em>First Number to Add </em>:
<asp:TextBox id="txtNum1" runat="server"
Width="43px">4</asp:TextBox>
</p>
<p>
<em>Second Number To Add </em>:
<asp:TextBox id="txtNum2" runat="server"
Width="44px">5</asp:TextBox>
</p>
<p>
<strong><u>Web Service Result -</u></strong>
</p>
<p>
<em>Hello world Service</em> :
<asp:Label id="Label1" runat="server"
Font-Underline="True">Label</asp:Label>
</p>
<p>
<em>Add Service</em> :
& <asp:Label id="Label2" runat="server"
Font-Underline="True">Label</asp:Label>
</p>
<p align="left">
<asp:Button id="runSrvice" onclick="runSrvice_Click"
runat="server" Text="Execute"></asp:Button>
</p>
</form>
</body>
</html>
WSDL http://localhost/WebService/FirstService.asmx?WSDL
this will download the server's WSDl file and create a agent file(C#) called FirstService.cs,use following command to
compile the source code to a DLL,then put this dll in virtual dir\bin folder,IIS looking for this agent at run time.
create source code of the WinApp.cs
using System;
using System.IO;
namespace SvcConsumer{
class SvcEater
{
public static void Main(String[] args)
{
FirstService mySvc = new FirstService();
Console.WriteLine("Calling Hello World Service: " + mySvc.SayHello());
Console.WriteLine("Calling Add(2, 3) Service: " +
mySvc.Add(2, 3).ToString());
}
}
}
using following to compile the client
csc /r:FirstService.dll WinApp.cs
exe file created,it will test our web service created in previous steps
1) install the IIS from windows 7,after installation the server is up,default page(actually is a html with one picture
embedded with lot of links) can be see in browser.
2) add a default html in server's newly created virtual directory can also be see in browser,but the asmx web service file
can not be see in browser because of the script handler is not properly registered in system
go to c:\windows\Microsoft.NET\Framework64\v.2.0.50727,run following command
ASPNET_REGIIS.exe -I
remember this is 64 bit,not 32,running 32 in 64 will get a error
then stop and start the server:
net stop w3svc
net start w3svc
3) copy following content in to virtual directory,name is as FirstService.asmx, language is CS,not C
<%@ WebService language="CS" class="FirstService" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
[WebService(Namespace="http://localhost/WebService/")]
public class FirstService : WebService
{
[WebMethod]
public int Add(int a, int b)
{
return a + b;
}
[WebMethod]
public String SayHello()
{
return "Hello World";
}
}
4) open browser,pointer to http://localhost/WebService/FirstService.asmx
we will get list of operations,use link can test the service,url http://localhost/WebService/FirstService.asmx?WSDL can
return the wsdl file of the web service
now web service serverside is done
following step will test web service from local or another machine by web and standalone windows app
1) create following asp.net web page to test the web service,name it as WebApp.aspx
<%@ Page Language="C#" %>
<script runat="server">
void runSrvice_Click(Object sender, EventArgs e)
{
FirstService mySvc = new FirstService();
Label1.Text = mySvc.SayHello();
Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),
Int32.Parse(txtNum2.Text)).ToString();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<em>First Number to Add </em>:
<asp:TextBox id="txtNum1" runat="server"
Width="43px">4</asp:TextBox>
</p>
<p>
<em>Second Number To Add </em>:
<asp:TextBox id="txtNum2" runat="server"
Width="44px">5</asp:TextBox>
</p>
<p>
<strong><u>Web Service Result -</u></strong>
</p>
<p>
<em>Hello world Service</em> :
<asp:Label id="Label1" runat="server"
Font-Underline="True">Label</asp:Label>
</p>
<p>
<em>Add Service</em> :
& <asp:Label id="Label2" runat="server"
Font-Underline="True">Label</asp:Label>
</p>
<p align="left">
<asp:Button id="runSrvice" onclick="runSrvice_Click"
runat="server" Text="Execute"></asp:Button>
</p>
</form>
</body>
</html>
This client is some code running from server to test web service,then display result in client page
2) standalone windows app,net point to a server that web service stay,we need use WSDL file from server to create a
dll, link this dll with client code will make client test code connect with server and successfully test the operation
use following step to create DLL
this will download the server's WSDl file and create a agent file(C#) called FirstService.cs,use following command to
compile the source code to a DLL,then put this dll in virtual dir\bin folder,IIS looking for this agent at run time.
csc /t:library FirstService.cs
create source code of the WinApp.cs
using System;
using System.IO;
namespace SvcConsumer{
class SvcEater
{
public static void Main(String[] args)
{
FirstService mySvc = new FirstService();
Console.WriteLine("Calling Hello World Service: " + mySvc.SayHello());
Console.WriteLine("Calling Add(2, 3) Service: " +
mySvc.Add(2, 3).ToString());
}
}
}
using following to compile the client
csc /r:FirstService.dll WinApp.cs
exe file created,it will test our web service created in previous steps
Friday, September 14, 2012
easy way to remember the parts of wsdl file
Tags:
definations: Root WSDL element
types: What data types will be transmitted
message:What messages will be transmitted
portType: what operations(functions) will be supported
binding: how will the message be transmitted on the wire? what SOAP-specific details are there.
service: Where is the service located?
definations: Root WSDL element
types: What data types will be transmitted
message:What messages will be transmitted
portType: what operations(functions) will be supported
binding: how will the message be transmitted on the wire? what SOAP-specific details are there.
service: Where is the service located?
Thursday, September 13, 2012
change the cygwin terminal prompt
the prompt controlled by variable PS1,so put following code to .bash_profile or .bashrc sould works
function prompt {
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1=" ${GREEN}\u${CYAN}@${BLUE}\h ${CYAN}\w${GRAY} $ "
}
prompt
function prompt {
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1=" ${GREEN}\u${CYAN}@${BLUE}\h ${CYAN}\w${GRAY} $ "
}
prompt
Subscribe to:
Posts (Atom)