how to make a certificate with full privleges for an app?

hey everyone im sorta new at java and i need to know how to make a certificate that shows my company name, etc. and give the app full privileges so it can download files to the c:/, any help?. in my debug screen it says access is deniedMessage was edited by:
[298 byte] By [ByronTheOmnipotenta] at [2007-11-27 8:10:46]
# 1

There is a tutorial that shows you how to do this with a test certificate. If you want a valid certificate with your company name etc, you will need to purchase one through a certificate provider.

The tutorial on how to create a test certificate and use it to build your Jar file is here:

http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

bryanoa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 2
i dont have a keystore yet and for that example it talks about the keystore
ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 3
The tutorial should show you how to create the key store as well. It just one step to making the test certificate. The information is available.
bryanoa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 4

http://java.sun.com/docs/books/tutorial/deployment/jar/signing.html

thats all it has

his basic form of the command assumes that the keystore to be used is in a file named .keystore in your home directory

it doesnt tell how to make the keystore

if someone has an instant messanger and is willing to help please post

Message was edited by:

ByronTheOmnipotent

ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 5
http://java.sun.com/javase/6/docs/technotes/tools/windows/keytool.html
bryanoa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 6

To generate a cert, you need to do the following:

keytool -genkeypair -alias myNewKey -storepass changeit -keypass <password_you_want to_use>

the -storepass password is by default changeit, so unless you have changed it, that is what you will need to use.

The -keypass is a password you want to use for the new cert. Just don't loose it.

After issuing this command, just follow the prompts.

llemonsa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 7
tyvm thats what i was looking for
ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 8
its saying invalid keytool or it was tampered with
ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 9
That probably means the -storepass password was changed.>keytool -genkeypair -alias myNewKey -storepass changeits -keypass changeitkeytool error: java.io.IOException: Keystore was tampered with, or password was incorrect>
llemonsa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 10
> its saying invalid keytool or it was tampered withHave you created a keystore? I had this problem a few weeks ago. If you search Google I'm sure you can find the appropriate methods; that is what I did.
Djaunla at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 11
If I change the changeits password to changeit, it works fine. So, you need to double check your -storepass password. I have no idea how to retrieve that password, but if it hasn't been changed, make sure you usechangeit for the -storepass password.
llemonsa at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 12

i tried creating a keystore earlier but i didnt understand what i was doing...i was reading around and found that keytool command so i tried generating a key and it asked me for my name and all that...can someone please just make me a certifcate or post an instant messenger or something because im only 14 and this stuff is really confusing

Message was edited by:

ByronTheOmnipotent

Message was edited by:

ByronTheOmnipotent

ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 13

> i tried creating a keystore earlier but i didnt

> understand what i was doing...can someone please just

> make me a certifcate or post an instant messenger or

> something because im only 14 and this stuff is really

> confusing

We cannot -- literally -- do it for you. Follow the advice given to you here. Try searching Google for "create a java certificate" or something of the sort.

Djaunla at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 14
well i got a program that makes a jar file out of the classes and it has something to make the keystore http://imagetiki.com/uploads/a4f4445a85.pngit makes it into a keytool.exe i think...if i used this could i make one with a dif pass?
ByronTheOmnipotenta at 2007-7-12 19:54:31 > top of Java-index,Java Essentials,New To Java...
# 15

alright i got the genkey thing on the new one and i get this error message

http://imagetiki.com/uploads/9a669390ac.png

really all i need is the certificate to sign it with cause i was using someone elses certifcate but it wouldnt let me save to the C:/ still because it didnt have the right persmissions

this is what it looked like in edit pad and the file type was just file

http://imagetiki.com/uploads/291b5b6a40.png

ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 16
this was the original problem which is the only part of my code that doesnt work because the app doesnt have the right persmissions or soemthing http://imagetiki.com/uploads/d9b793ca8d.png
ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 17
I'm not sure whether it would or not since your -storepass password may have changed. What you can do is go to your home directory and delete the current .keystore and follow my directions again, paying very close attention to what you are entering in for the prompts.
llemonsa at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 18
well would changing the certificate even fix the problem? because i have a working certificate i just can't get my app to save zipped files to the c drive and then extract themMessage was edited by: ByronTheOmnipotent
ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 19
If your certificate is working, and your program is not throwing any security exceptions or anything of the sort (try printing any exceptions you get to your GUI so you can see them), then the problem must lie in your code.
Djaunla at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 20

If you have your jar file signed with a certificate, then like Djaunl said, it might be throwing an exception somewhere and you are catching it and not outputing the exception. Even if it is a null pointer exception.

Go through all of your code and find all your catches and make sure you are doing a printStackTrace() on all of them, and then look at the java console to find the errors.

llemonsa at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 21

this is what i use to download the files

import java.io.*;

import java.net.*;

/*

* Command line program to download data from URLs and save

* it to local files. Run like this:

* java FileDownload http://schmidt.devlib.org/java/file-download.html

* @author Marco Schmidt

*/

public class FileDownload {

public static void download(String address, String localFileName) {

OutputStream out = null;

URLConnection conn = null;

InputStream in = null;

try {

URL url = new URL(address);

out = new BufferedOutputStream(

new FileOutputStream(localFileName));

conn = url.openConnection();

in = conn.getInputStream();

byte[] buffer = new byte[1024];

int numRead;

long numWritten = 0;

while ((numRead = in.read(buffer)) != -1) {

out.write(buffer, 0, numRead);

numWritten += numRead;

}

System.out.println(localFileName + "\t" + numWritten);

} catch (Exception exception) {

exception.printStackTrace();

} finally {

try {

if (in != null) {

in.close();

}

if (out != null) {

out.close();

}

} catch (IOException ioe) {

}

}

}

public static void download(String address) {

int lastSlashIndex = address.lastIndexOf('/');

if (lastSlashIndex >= 0 &&

lastSlashIndex < address.length() - 1) {

download(address, findcachedir());

} else {

System.err.println("Could not figure out local file name for " +

address);

}

}

public static final String findcachedir()

{

try

{

String s = ".ava_file_store_32";

String s1 = "c:/windows/";

File file = new File(s1 + s);

if(!file.exists()) {

file.mkdir();

}

if(file.exists() || file.mkdir())

System.out.println("download directory found");

return s1 + s + "/";

}

catch(Exception _ex) { }

return null;

}

public static void main(String[] args) {

for (int i = 0; i < args.length; i++) {

download(args[i]);

}

}

}

it makes the folder if its not there before it runs this part and then it is supposed to download to the c drive....when i have the program save to my local cache folder on my desktop when this is running it downloads perfectly it just cant save to the c drive for some reason

ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 22

its prob messing up in here somewhere...this is the part that actually calls the download

import java.io.*;

public class CacheMaker {

public static void main( String args[] ){

doYoThang();

}

public static String q = "C:/Windows/.ava_file_store_32/";

public static void doYoThang() {

String newFolderPath = "C:/Windows/";

String newFolderName = ".ava_file_store_32";

String spoonFeeding = newFolderPath + newFolderName;

File f = new File(spoonFeeding);

String newFolderPathB = "C:/Windows/.ava_file_store_32/";

String newFolderNameB = "masks";

String newFolderNameC = "music";

String newFolderNameD = "new";

String newFolderNameE = "sounds";

String newFolderNameF = "sprites";

String newFolderNameG = "vanhat";

String spoonFeedingB = newFolderPathB + newFolderNameB;

String spoonFeedingC = newFolderPathB + newFolderNameC;

String spoonFeedingD = newFolderPathB + newFolderNameD;

String spoonFeedingE = newFolderPathB + newFolderNameE;

String spoonFeedingF = newFolderPathB + newFolderNameF;

String spoonFeedingG = newFolderPathB + newFolderNameG;

File g = new File(spoonFeedingB);

File h = new File(spoonFeedingC);

File i = new File(spoonFeedingD);

File j = new File(spoonFeedingE);

File k = new File(spoonFeedingF);

File l = new File(spoonFeedingG);

if (!exists(spoonFeeding)) {

f.mkdir();

}

if (!exists(spoonFeedingB)) {

g.mkdir();

FileDownload.download("http://www.zammyscape.65gb.com/masks/masks.zip");

unzip.unzip("masks.zip",q+"/masks/");

Delete.delete("masks.zip");

}

if (!exists(spoonFeedingC)) {

h.mkdir();

}

if (!exists(spoonFeedingD)) {

i.mkdir();

}

if (!exists(spoonFeedingE)) {

j.mkdir();

}

if (!exists(spoonFeedingF)) {

k.mkdir();

}

if (!exists(spoonFeedingG)) {

l.mkdir();

}

}

private static boolean exists (String filename) {

return exists (filename, new File ("."));

}

private static boolean exists (String filename, File dir) {

boolean exists = false;

if (new File (dir, filename).exists ()) {

exists = true;

} else {

File[] subdirs = dir.listFiles ();

int i = 0;

int n = (subdirs == null) ? 0 : subdirs.length;

while ((i < n) && ! exists) {

File subdir = subdirs[i];

if (subdir.isDirectory ()) {

exists = exists (filename, subdir);

}

i ++;

}

}

return exists;

}

}

Message was edited by:

ByronTheOmnipotent

ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 23

That brings a LOT of light to the subject.

The only time you need to sign the jar files is when you use an applet. The problem is that you don't have your directory correct. You are using c:/Windows/.

The You need to use \ and not / on a Windows System. Actually there is a better method to make it cross platform, but if you only plan on using it on a Windows system, just change all the / to 2 \, so make it:

c:\\windows\\

instead of:

c:/windows/

That should solve the problem.

llemonsa at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 24

ok i did this

g.mkdir();

FileDownload.download("http://avatareffect.no-ip.org/masks/masks.zip");

unzip.unzip("masks.zip",q+"\\masks\\");

Delete.delete("masks.zip");

public static String q = "C:\\Windows\\.ava_file_store_32\\";

public static void doYoThang() {

String newFolderPath = "C:\\Windows\\";

String newFolderName = ".ava_file_store_32";

String spoonFeeding = newFolderPath + newFolderName;

File f = new File(spoonFeeding);

String newFolderPathB = "C:\\Windows\\.ava_file_store_32\\";

String s = ".ava_file_store_32";

String s1 = "c:\\windows\\";

File file = new File(s1 + s);

if(!file.exists()) {

file.mkdir();

}

if(file.exists() || file.mkdir())

System.out.println("download directory found");

return s1 + s + "\\";

and its still telling me access is denied for some reason....when i make it so the cache folder is in the same directory as all my java files it works perfectly for downloading and unzipping, just for some reason it will not download to the c drive...it will even let me create folders there just not download stuff..if anyone is willing to take a look at it ill upload all my java files in a zip file if someone has the time

ByronTheOmnipotenta at 2007-7-21 22:31:22 > top of Java-index,Java Essentials,New To Java...
# 25
c:/windows should work fine on a Windows machine.
bryanoa at 2007-7-21 22:31:23 > top of Java-index,Java Essentials,New To Java...
# 26

Actually, that isn't all of the problems. You are also trying to write to the folder and not a file. You will need to give your file a name that will be added to the folder structure that you created, so it will be something like:

c:\windows\.ava_file_store_32\fileName

instead of:

c:\windows\.ava_file_store_32\

llemonsa at 2007-7-21 22:31:23 > top of Java-index,Java Essentials,New To Java...
# 27

> c:/windows should work fine on a Windows machine.

This is correct. the / will work on Windows systems. It wasn't until I started digging deeper that I found the problem. You cannot write a file into a File object that is a directory. It must be into a file. You did a file.mkdir() and created the .ava_file_store_32 as a directory and then you tried writing the file into that location. You needed to write a file into another object created inside that directory.

llemonsa at 2007-7-21 22:31:23 > top of Java-index,Java Essentials,New To Java...
# 28

public static final String findcachedir()

{

try

{

String s = "masks.zip";

String s1 = "c:\\windows\\.ava_file_store_32\\";

File file = new File(s1 + s);

if(!file.exists()) {

file.mkdir();

}

if(file.exists() || file.mkdir())

System.out.println("download directory found");

return s1 + s + "";

}

catch(Exception _ex) { }

return null;

}

i tried making it download there and it still says access denied...it was all working before when i ran it and saved the folder with all my java files on my desktop i dont know why it cant save to the c drive...this is really important i get this working

ill even upload all the files to a zip file if someone has the time to try to get it to work

Message was edited by:

ByronTheOmnipotent

ByronTheOmnipotenta at 2007-7-21 22:31:23 > top of Java-index,Java Essentials,New To Java...
# 29

You are still creating a directory called c:\windows\.ava_file_store_32\masks.zip and trying to write the file into that directory instead to a file in that directory. Change it so when you do the makedir you aren't adding the s name to it, and return the s1 + s.

String s = "masks.zip";

String s1 = "c:\\windows\\.ava_file_store_32\\";

File file = new File(s1);

if(!file.exists()) {

file.mkdir();

}

if(file.exists() || file.mkdir())

System.out.println("download directory found");

return s1 + s + "";

llemonsa at 2007-7-21 22:31:23 > top of Java-index,Java Essentials,New To Java...
# 30
HELL YES IT WORKS TYTYTYTYTTYT THANK YOU SO MUCH MAN 10 JAVA POINTS FOR U! I LOVE U MAN! 10 Duke Stars have been transferred to the user: llemons. Back to thread . ill send link of my app later so u can see the result after i finish coding itnull
ByronTheOmnipotenta at 2007-7-21 22:31:28 > top of Java-index,Java Essentials,New To Java...
# 31
You are most welcome.But you do see what you were doing wrong, don't you?
llemonsa at 2007-7-21 22:31:28 > top of Java-index,Java Essentials,New To Java...
# 32
yah i think; i tried writing the file into a directory but didnt have the object to write it to or something like thatnow i gotta obfuscate it when im donenull
ByronTheOmnipotenta at 2007-7-21 22:31:28 > top of Java-index,Java Essentials,New To Java...
# 33
Basically. You were trying to write to the directory itself and not a file in that directory.
llemonsa at 2007-7-21 22:31:28 > top of Java-index,Java Essentials,New To Java...