Skip to content

Commit 38bb364

Browse files
Encoded Password
1 parent d342d4b commit 38bb364

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
<artifactId>cloudant</artifactId>
3737
<version>0.9.2</version>
3838
</dependency>
39+
<dependency>
40+
<groupId>com.ibm.websphere.appserver.api</groupId>
41+
<artifactId>com.ibm.websphere.appserver.api.passwordUtil</artifactId>
42+
<version>1.0.95</version>
43+
</dependency>
3944
<!-- Test Dependencies-->
4045
<dependency>
4146
<groupId>org.junit.jupiter</groupId>

src/main/java/io/openliberty/sample/cloudant/CloudantProducer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package io.openliberty.sample.cloudant;
1212

1313
import jakarta.enterprise.context.ApplicationScoped;
14+
import com.ibm.websphere.crypto.PasswordUtil;
1415
import jakarta.enterprise.inject.Produces;
1516
import jakarta.inject.Inject;
1617
import org.eclipse.microprofile.config.inject.ConfigProperty;
@@ -37,7 +38,7 @@ public class CloudantProducer {
3738

3839
@Inject
3940
@ConfigProperty(name = "cloudant.password")
40-
String password;
41+
String encodedPassword;
4142

4243

4344
@Inject
@@ -46,6 +47,7 @@ public class CloudantProducer {
4647

4748
@Produces
4849
public Cloudant createCloudant() {
50+
String password = PasswordUtil.passwordDecode(encodedPassword);
4951
BasicAuthenticator authenticator = new BasicAuthenticator.Builder()
5052
.username(username)
5153
.password(password)

src/main/liberty/config/server.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<webApplication location="CloudantSample.war" contextRoot="/"/>
1414
<variable name="cloudant.username" value="admin"/>
15-
<variable name="cloudant.password" value="password"/>
15+
<variable name="cloudant.password" value="{aes}AEEjCqvh7XAwDxrdYC6BUbqYlwqI8NAxRkWWWq7muxZu"/>
1616
<variable name="cloudant.dbname" value="testdb"/>
1717

1818
</server>

0 commit comments

Comments
 (0)