I'm using the generic code that has been pasted here a couple of times to get a password from an alias inside a credstore here in elytron:
(Do ignore all those sysouts, I can't debug normally so I have to use a logger)
String clearTextPswd = null;
System.out.println("Prueba0");
Provider CREDENTIAL_STORE_PROVIDER = new WildFlyElytronCredentialStoreProvider();
Provider PASSWORD_PROVIDER = new WildFlyElytronPasswordProvider();
Security.addProvider(PASSWORD_PROVIDER);
Password storePassword = ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, "StorePassword".toCharArray());
ProtectionParameter protectionParameter = new CredentialSourceProtectionParameter(IdentityCredentials.NONE.withCredential(new PasswordCredential(storePassword)));
System.out.println("prueba1");
System.out.println("prueba2");
CredentialStore credentialStore = null;
System.out.println("prueba3");
try {
credentialStore = CredentialStore.getInstance("KeyStoreCredentialStore", CREDENTIAL_STORE_PROVIDER);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("prueba4");
HashMap<String, String> configuration = new HashMap<String,String>();
configuration.put("location", "mycredstore.cs");
configuration.put("create", "true");
try {
credentialStore.initialize(configuration, protectionParameter);
} catch (CredentialStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(credentialStore.isInitialized());
Password password = null;
try {
password = credentialStore.retrieve("dbPassword", PasswordCredential.class).getPassword();
} catch (UnsupportedCredentialTypeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CredentialStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("prueba5");
clearTextPswd = password.toString();
System.out.println(clearTextPswd);
return clearTextPswd;
}
The code itself should be fine, but here's the deal: I can't launch the application after adding that code. Ever since I added the last Wildfly-elytron version to the dependencies, I get a NoClassDefFoundError from org.wildfly.commons.assert that won't let me use it or debug it. These are my dependencies, could anything be wrong? Have you ever encountered this problem before?
It does not trigger when calling the method, just when it invokes the classes right after launch.
<groupId>org.pushingpixels</groupId>
<artifactId>trident</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.wildfly.security/wildfly-elytron -->
<dependency>
<groupId>org.wildfly.security</groupId>
<artifactId>wildfly-elytron</artifactId>
<version>2.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.picketbox</groupId>
<artifactId>picketbox</artifactId>
<version>5.1.0.Final</version>
</dependency>````