Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoded Password #29

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<artifactId>cloudant</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver.api</groupId>
<artifactId>com.ibm.websphere.appserver.api.passwordUtil</artifactId>
<version>1.0.95</version>
</dependency>
<!-- Test Dependencies-->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package io.openliberty.sample.cloudant;

import jakarta.enterprise.context.ApplicationScoped;
import com.ibm.websphere.crypto.PasswordUtil;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
Expand All @@ -37,7 +38,7 @@ public class CloudantProducer {

@Inject
@ConfigProperty(name = "cloudant.password")
String password;
String encodedPassword;


@Inject
Expand All @@ -46,6 +47,7 @@ public class CloudantProducer {

@Produces
public Cloudant createCloudant() {
String password = PasswordUtil.passwordDecode(encodedPassword);
BasicAuthenticator authenticator = new BasicAuthenticator.Builder()
.username(username)
.password(password)
Expand Down
2 changes: 1 addition & 1 deletion src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<webApplication location="CloudantSample.war" contextRoot="/"/>
<variable name="cloudant.username" value="admin"/>
<variable name="cloudant.password" value="password"/>
<variable name="cloudant.password" value="{aes}AEEjCqvh7XAwDxrdYC6BUbqYlwqI8NAxRkWWWq7muxZu"/>
<variable name="cloudant.dbname" value="testdb"/>

</server>