Bonjour

J'utilise windev mobile. J'aimerais installer un certificat automatiquement sur ma tablette.
j'ai trouvé le code suivant :
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.Key;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.io.IOException;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.ByteArrayInputStream;
import java.security.spec.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.util.Collection;
 
public class InstallCertificat {
	public static void main(String[] argv) throws Exception {
 
		String certfile = "yourcert.cer"; /*your cert path*/
		FileInputStream is = new FileInputStream("yourKeyStore.keystore");
 
		KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
		keystore.load(is, "yourKeyStorePass".toCharArray());
 
		String alias = "youralias";
		char[] password = "yourKeyStorePass".toCharArray();
 
		//////
 
		CertificateFactory cf = CertificateFactory.getInstance("X.509");
		InputStream certstream = fullStream (certfile);
		Certificate certs =  cf.generateCertificate(certstream);
 
		///
		File keystoreFile = new File("yourKeyStorePass.keystore");
		// Load the keystore contents
		FileInputStream in = new FileInputStream(keystoreFile);
		keystore.load(in, password);
		in.close();
 
		// Add the certificate
		keystore.setCertificateEntry(alias, certs);
 
		// Save the new keystore contents
		FileOutputStream out = new FileOutputStream(keystoreFile);
		keystore.store(out, password);
		out.close();
 
	}
 
	private static InputStream fullStream ( String fname ) throws IOException {
		FileInputStream fis = new FileInputStream(fname);
		DataInputStream dis = new DataInputStream(fis);
		byte[] bytes = new byte[dis.available()];
		dis.readFully(bytes);
		ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
		return bais;
	}
}

J'aimerai le tester sur mon projet.
1 - création d'une collection de procédure globale :"COL_CERTIFICAT"
puis création de deux procédures

java Procédure globale main :
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.security.Key;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.io.IOException;
import java.io.InputStream;
import java.io.DataInputStream;
import java.io.ByteArrayInputStream;
import java.security.spec.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.util.Collection;
 
 
public static void main(String[] argv) throws Exception 
{
 
	String certfile = "certificat.cer"; /*your cert path*/
	FileInputStream is = new FileInputStream("yourKeyStore.keystore");
 
	KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
	keystore.load(is, "yourKeyStorePass".toCharArray());
 
	String alias = "youralias";
	char[] password = "yourKeyStorePass".toCharArray();
 
	//////
 
	CertificateFactory cf = CertificateFactory.getInstance("X.509");
	InputStream certstream = fullStream (certfile);
	Certificate certs =  cf.generateCertificate(certstream);
 
	///
	File keystoreFile = new File("yourKeyStorePass.keystore");
	// Load the keystore contents
	FileInputStream in = new FileInputStream(keystoreFile);
	keystore.load(in, password);
	in.close();
 
	// Add the certificate
	keystore.setCertificateEntry(alias, certs);
 
	// Save the new keystore contents
	FileOutputStream out = new FileOutputStream(keystoreFile);
	keystore.store(out, password);
	out.close();
 
}

puis java Procédure globale InputStream
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
private static InputStream fullStream ( String fname ) throws IOException {
	FileInputStream fis = new FileInputStream(fname);
	DataInputStream dis = new DataInputStream(fis);
	byte[] bytes = new byte[dis.available()];
	dis.readFully(bytes);
	ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
	return bais;
}

J'ai la première ligne en vert pour les deux procédures. Type de retour non valide et type du paramètre non valide des warning en bleu

et si je génère j'ai une fenêtre Echec de la génération :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Echec de la création de l'application Android <K:\eol18\PEC_TIRAT\Exe\Application Android\PecEol.apk>.
 
 
Ligne de commande : "C:\Program Files (x86)\Java\jdk1.7.0\bin\javac.exe" -encoding UTF-16LE -nowarn -source 1.5 -target 1.5 -d bin\classes -bootclasspath "C:\sdkandroid\platforms\android-10\android.jar" gen\fr\etib\peceol\*.java src\fr\etib\peceol\wdgen\*.java -classpath "libs;libs\android-support-v4.jar"
 
 
Erreur retournée :
src\fr\etib\peceol\wdgen\GWDFFEN_Requete.java:3115: error: method main in class GWDCPCOL_Certificat cannot be applied to given types;
GWDCPCOL_Certificat.main();
                   ^
  required: String[]
  found: no arguments
  reason: actual and formal argument lists differ in length
1 error
que dois-je faire?

cordialement Law56100
je connais que le langague windev, j'avoue je ne comprends pas grand chose en java