cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service

Former Member
0 Kudos

Hi,

I have created a webservice that exposes a method that will do the encryption. I am passing "c:
harsha
javatry
rawdata1.txt" as a request parameter . The encryption method will read the data from the file rawdata1.txt from the above path and will encrypt the data and the encrypted data will be saved in the file Encrypt.txt created by the encryption method and save it the same path.

It is not giving any error. But it is not creating any file in the path that i specified in the encryption method. please provide me the solution for this.....

regards,

shreeharsha

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shreeharsha,

Could you please share the code you are using in application, coz want to confirm few points:are you using file upload UI and trying to write file in the Local machine or in Server.

Deepak!!!

Former Member
0 Kudos

Hi deepak,

i am not using any ui elements to upload. this is a JAVA project not webdynpro project.

below is the code.....

public void encryptData(String rawFile)

{

String algorithm = "DESede";

Provider sunjce = new com.sun.crypto.provider.SunJCE();

byte[] inputBytes = null;

byte[] encryptionBytes=null;

String result1=null;

Cipher c=null;

try {

c = Cipher.getInstance(algorithm);

// SecretKey key=KeyGenerator.getInstance(algorithm).generateKey();

} catch (Exception e) {

// An exception here probably means the JCE provider hasn't

// been permanently installed on this system by listing it

// in the $JAVA_HOME/jre/lib/security/java.security file.

// Therefore, we have to install the JCE provider explicitly.

System.err.println("Installing SunJCE provider.");

sunjce = new com.sun.crypto.provider.SunJCE();

Security.addProvider(sunjce);

}

try{

File dataFile= new File(rawFile);

DataInputStream in = new DataInputStream(new FileInputStream(dataFile));

byte[] rawData = new byte[(int) dataFile.length()];

in.readFully(rawData);

in.close();

Cipher cipher = Cipher.getInstance(algorithm);

SecretKey key=KeyGenerator.getInstance(algorithm).generateKey();

cipher.init(Cipher.ENCRYPT_MODE, key);

encryptionBytes = cipher.doFinal(rawData);

FileOutputStream out= new FileOutputStream("c://harsha//Encrypt.txt");

PrintStream pr= new PrintStream(out);

pr.println(encryptionBytes);

pr.close();

}

catch(Exception e)

{

System.out.print("Exception occured "+e.getLocalizedMessage());

}

finally

{

}

}

with regards,

shreeharsha

Edited by: shreeharshaudupa on Apr 26, 2010 1:58 PM