FrameworkDemoiselle.gov.brCommunity Documentation
A seguir temos alguns exemplos de tarefas normalmente necessárias na utilização do componente.
byte[] result = null;
File file = new File("documento.odp");
FileInputStream is = new FileInputStream(file);
result = new byte[(int) file.length()];
is.read(result);
is.close();
return result;
byte[] conteudo = "este eh um conteudo de arquivo texto".getBytes();
FileOutputStream out = new FileOutputStream(new File("arquivo.txt");
out.write(sign);
out.close();
File file = new File("private_rsa_1024.pkcs8");
fileContent = new byte[(int) file.length()];
is = new FileInputStream(file);
is.read(fileContent);
is.close();
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(fileContent);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PrivateKey chavePrivada = keyFactory.generatePrivate(privateKeySpec);
KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
KeyStore keyStore = keyStoreLoader.getKeyStore("pinnumber");
String certificateAlias = keyStore.aliases().nextElement();
PrivateKey chavePrivada = (PrivateKey)keyStore.getKey(certificateAlias, "pinnumber");
File file = new File("public_rsa_1024.pkcs8");
byte[] fileContent = new byte[(int) file.length()];
is = new FileInputStream(file);
is.read(fileContent);
is.close();
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(fileContent);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PublicKey chavePublica = keyFactory.generatePublic(publicKeySpec);
KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
KeyStore keyStore = keyStoreLoader.getKeyStore();
CertificateLoader certificateLoader = new CertificateLoader();
certificateLoader.setKeyStore(keyStore);
X509Certificate certificate = certificateLoader.loadFromToken();
PublicKey chavePublica = certificate.getPublicKey();
CertificateLoader certificateLoader = new CertificateLoaderImpl();
X509Certificate certificate = certificateLoader.load(new File("certificado.cer");
KeyStoreLoader keyStoreLoader = KeyStoreLoaderFactory.factoryKeyStoreLoader();
KeyStore keyStore = keyStoreLoader.getKeyStore();
CertificateLoader certificateLoader = new CertificateLoaderImpl();
certificateLoader.setKeyStore(keyStore);
X509Certificate certificate = certificateLoader.loadFromToken();