use of com.evolveum.midpoint.prism.crypto.ProtectorImpl in project midpoint by Evolveum.
the class PrismInternalTestUtil method createProtector.
public static Protector createProtector(String xmlCipher) {
ProtectorImpl protector = new ProtectorImpl();
protector.setKeyStorePassword(KEYSTORE_PASSWORD);
protector.setKeyStorePath(KEYSTORE_PATH);
protector.setEncryptionAlgorithm(xmlCipher);
protector.init();
return protector;
}
use of com.evolveum.midpoint.prism.crypto.ProtectorImpl in project midpoint by Evolveum.
the class ExpressionTestUtil method createInitializedProtector.
public static ProtectorImpl createInitializedProtector(PrismContext prismContext) {
ProtectorImpl protector = new ProtectorImpl();
protector.setKeyStorePath(MidPointTestConstants.KEYSTORE_PATH);
protector.setKeyStorePassword(MidPointTestConstants.KEYSTORE_PASSWORD);
protector.init();
return protector;
}
use of com.evolveum.midpoint.prism.crypto.ProtectorImpl in project midpoint by Evolveum.
the class KeyStoreDumper method execute.
public void execute() {
try {
ApplicationContext context = new ClassPathXmlApplicationContext(CONTEXTS);
Protector protector = context.getBean("protector", Protector.class);
KeyStore keyStore = protector.getKeyStore();
System.out.println("###################################################");
System.out.println("Printing keys from key store");
if (protector instanceof ProtectorImpl) {
ProtectorImpl aesProtector = (ProtectorImpl) protector;
System.out.println("Using key store from location: " + aesProtector.getKeyStorePath());
// System.out.println("Cipher: " + aesProtector.getXmlCipher());
}
Enumeration<String> aliases = keyStore.aliases();
while (aliases.hasMoreElements()) {
String alias = aliases.nextElement();
System.out.println("===== ALIAS: " + alias + "=====");
System.out.println("Creation date: " + keyStore.getCreationDate(alias));
System.out.println("Type: " + keyStore.getType());
if (keyStore.getCertificate(alias) != null) {
System.out.println("Certificate: " + keyStore.getCertificate(alias));
}
if (keyStore.getCertificateChain(alias) != null) {
System.out.println("Certificate chain: " + keyStore.getCertificateChain(alias));
}
ProtectionParameter protParam = new KeyStore.PasswordProtection("midpoint".toCharArray());
Entry entry = keyStore.getEntry(alias, protParam);
if (entry instanceof SecretKeyEntry) {
System.out.println("Secret key entry: ");
SecretKeyEntry skEntry = (SecretKeyEntry) entry;
SecretKey key = skEntry.getSecretKey();
System.out.println(" Algorithm: " + key.getAlgorithm());
System.out.println(" Format: " + key.getFormat());
System.out.println(" Key length: " + key.getEncoded().length * 8);
if (protector instanceof ProtectorImpl) {
System.out.println(" Key name: " + ((ProtectorImpl) protector).getSecretKeyDigest(key));
}
// Cipher cipher = Cipher.getInstance(key.getAlgorithm());
// System.out.println(" Cipher algorithm" + cipher.getAlgorithm());
}
//TODO: add dump also for other types of keys
Provider provider = keyStore.getProvider();
System.out.println("Provder name: " + provider.getName() + "\n");
}
System.out.println("###################################################");
} catch (KeyStoreException ex) {
System.out.println("Failed to print information about keyStore. Reason: " + ex.getMessage());
return;
} catch (UnrecoverableEntryException ex) {
System.out.println("Failed to print information about keyStore. Reason: " + ex.getMessage());
return;
} catch (NoSuchAlgorithmException ex) {
System.out.println("Failed to print information about keyStore. Reason: " + ex.getMessage());
return;
} catch (EncryptionException ex) {
System.out.println("Failed to print information about keyStore. Reason: " + ex.getMessage());
return;
}
}
use of com.evolveum.midpoint.prism.crypto.ProtectorImpl in project midpoint by Evolveum.
the class ConfigurableProtectorFactory method getProtector.
public Protector getProtector() {
ProtectorImpl protector = new ProtectorImpl();
protector.setEncryptionKeyAlias(protectorConfig.getEncryptionKeyAlias());
protector.setKeyStorePassword(protectorConfig.getKeyStorePassword());
protector.setKeyStorePath(protectorConfig.getKeyStorePath());
protector.setEncryptionAlgorithm(protectorConfig.getXmlCipher());
protector.init();
return protector;
}
use of com.evolveum.midpoint.prism.crypto.ProtectorImpl in project midpoint by Evolveum.
the class AbstractScriptTest method setupFactory.
@BeforeClass
public void setupFactory() {
PrismContext prismContext = PrismTestUtil.getPrismContext();
ObjectResolver resolver = new DirectoryFileObjectResolver(OBJECTS_DIR);
Protector protector = new ProtectorImpl();
Collection<FunctionLibrary> functions = new ArrayList<FunctionLibrary>();
functions.add(FunctionLibraryUtil.createBasicFunctionLibrary(prismContext, protector));
scriptExpressionfactory = new ScriptExpressionFactory(resolver, prismContext, protector);
scriptExpressionfactory.setFunctions(functions);
evaluator = createEvaluator(prismContext, protector);
String languageUrl = evaluator.getLanguageUrl();
System.out.println("Expression test for " + evaluator.getLanguageName() + ": registering " + evaluator + " with URL " + languageUrl);
scriptExpressionfactory.registerEvaluator(languageUrl, evaluator);
}
Aggregations