!securitylevel.equalsIgnoreCase(SECURITY_ENCRYPTED) &&
!securitylevel.equalsIgnoreCase(SECURITY_SIGNEDENCRYPTED)){
throw new Exception("Invalid SecurityLevel: "+securitylevel);
}
if(securitylevel.equalsIgnoreCase(SECURITY_SIGNED) || securitylevel.equalsIgnoreCase(SECURITY_SIGNEDENCRYPTED)){
RAKeyStore rakeystore = new RAKeyStore(args[ARG_KEYSTOREPATH], args[ARG_PASSWORD]);
Certificate[] chain = rakeystore.getKeyStore().getCertificateChain(rakeystore.getAlias());
cAChain = new Vector();
for(int i=0; i< chain.length ; i++){
if(((X509Certificate) chain[i]).getBasicConstraints() != -1){
cAChain.add(chain[i]);
}
}
raKey = (PrivateKey) rakeystore.getKeyStore().getKey(rakeystore.getAlias(), args[ARG_PASSWORD].toCharArray());
raCert = (X509Certificate) rakeystore.getKeyStore().getCertificate(rakeystore.getAlias());
}
if(securitylevel.equalsIgnoreCase(SECURITY_ENCRYPTED) || securitylevel.equalsIgnoreCase(SECURITY_SIGNEDENCRYPTED)){
CertificateFactory cf = CertTools.getCertificateFactory();
encCert = (X509Certificate) cf.generateCertificate(new FileInputStream(args[ARG_ENCRYPTIONCERT]));
}