Skip to content

Conversation

evandongen
Copy link
Contributor

@evandongen evandongen commented May 1, 2025

closes #8879

@evandongen evandongen changed the title closes #8879 Fix multiple credential providers May 1, 2025
@@ -263,8 +263,9 @@ This guide assumes that you are using IntelliJ Ultimate, because application ser
- Set the context to `/iaf-test`.
__NB__: This is very important, otherwise a lot of tests will fail!
- Set the following VM options:
`-Ddtap.stage=LOC -DauthAliases.expansion.allowed=testalias -Dweb.port=8080 -DcredentialFactory.class=org.frankframework.credentialprovider.FileSystemCredentialFactory -DcredentialFactory.filesystem.root=/<path to source>/frankframework/test/src/main/secrets`
- In the "On Update" section, select "Update Classes and Resources", so classes can be automatically updated and reloaded after project build (providing this is supported by your JDK)
`-Ddtap.stage=LOC -DauthAliases.expansion.allowed=testalias -Dweb.port=8080
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De filesystem credentials zijn een half jaar geleden verwijderd, maar de docs waren niet bijgewerkt.

/**
* Performs a 'safe' lookup of credentials.
*/
private CredentialFactory getCredentials(FrankResource resource) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alias werd hier resolved, maar werd hierboven eigenlijk niet meer gebruikt


String userName;
String passWord;
try {
CredentialFactory cf = new CredentialFactory(authAlias);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Door mijn wijziging kan dit al een nosuchelementexception throwen.

@@ -59,6 +59,9 @@ public PipeRunResult doPipe(Message message, PipeLineSession session) throws Pip
result += "username does not match target";
}
if (!getTargetPassword().equals(cf.getPassword())) {
if (!StringUtils.isEmpty(result)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zonder deze change kwam hier username does not match targetpassword does not match target uit als beide niet klopten

@@ -83,7 +84,7 @@ public boolean hasCredentials(String alias) {
}

@Override
public ICredentials getCredentials(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) {
public ICredentials getCredentials(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) throws NoSuchElementException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback van vorige pr

* @throws ConfigurationException
*/
@Test
void testCertificateSettingsCanBeSet() throws ConfigurationException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bewijst dat alles netjes geset en configured kan wordne

@evandongen evandongen requested review from nielsm5 and tnleeuw May 1, 2025 12:02
@evandongen evandongen requested a review from tnleeuw May 2, 2025 10:17
Comment on lines 134 to 147
String alias = resource.getAuthalias();
if(StringUtils.isNotEmpty(alias)) {
alias = StringResolver.substVars(alias, APP_CONSTANTS);
}
String username = resource.getUsername();
if(StringUtils.isNotEmpty(username)) {
username = StringResolver.substVars(username, APP_CONSTANTS);
if(StringUtils.isNotEmpty(resource.getUsername())) {
mergedProps.setProperty("user", StringResolver.substVars(resource.getUsername(), APP_CONSTANTS));
}
String password = resource.getPassword();
if(StringUtils.isNotEmpty(password)) {
password = StringResolver.substVars(password, APP_CONSTANTS);
if(StringUtils.isNotEmpty(resource.getPassword())) {
mergedProps.setProperty("password", StringResolver.substVars(resource.getPassword(), APP_CONSTANTS));
}

return new CredentialFactory(alias, username, password);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alias wordt toch meegegeven aan de CredentialFactory ?

Comment on lines 726 to 743
private static class CredentialSettings {
private CredentialFactory credentialFactory;
private @Setter String password;
private @Getter String authAlias;

public void setAuthAlias(String authAlias) {
this.authAlias = authAlias;
this.credentialFactory = new CredentialFactory(authAlias);
}

public String getPassword() {
if (credentialFactory == null) {
return password;
}

return credentialFactory.getPassword();
}
}
Copy link
Member

@nielsm5 nielsm5 May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waarom gebruik je niet 3 class fields?

	private @Getter String authAlias;
	private @Getter String username;
	private @Getter String password;

En in de configure v/d class credentialFactory = new CredentialFactory(authAlias, username, password); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wat bedoel je met configure class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

van de*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dan heb ik 9 class fields nodig, op deze manier (dat was ook feedback van Tim), houden we het nog een beetje netjes. Gebruik van een credential factory gaat mis zonder auth alias, vandaar deze wijziging

Copy link
Member

@nielsm5 nielsm5 May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dan kan je toch beter dit, geniek hier oplossen:

public CredentialFactory(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) {
credentials = org.frankframework.credentialprovider.CredentialFactory.getCredentials(alias, defaultUsernameSupplier, defaultPasswordSupplier);
}

Zet daar om alias een mooie if, die een https://github.com/frankframework/frankframework/blob/master/credentialProvider/src/main/java/org/frankframework/credentialprovider/Credentials.java teruggeeft zonder alias?

@evandongen evandongen requested review from nielsm5 and tnleeuw May 6, 2025 16:56
@evandongen evandongen requested a review from a team as a code owner May 7, 2025 09:57
Copy link

sonarqubecloud bot commented May 7, 2025

@@ -45,10 +46,13 @@ public CredentialFactory(String alias, String defaultUsername, String defaultPas
}

public CredentialFactory(String alias, Supplier<String> defaultUsernameSupplier, Supplier<String> defaultPasswordSupplier) {
credentials = org.frankframework.credentialprovider.CredentialFactory.getCredentials(alias, defaultUsernameSupplier, defaultPasswordSupplier);
if (alias == null) {
credentials = new Credentials(alias, defaultUsernameSupplier, defaultPasswordSupplier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja dit is nu wat voorheen op CredentialFactory (in cf module) op regel 130 stond!

@nielsm5 nielsm5 changed the title Fix multiple credential providers Fix the use of multiple credential providers May 7, 2025
@nielsm5 nielsm5 merged commit 4b4fc26 into master May 7, 2025
32 of 33 checks passed
@nielsm5 nielsm5 deleted the issue/8879-support-multiple-credential-providers branch May 7, 2025 13:09
evandongen added a commit that referenced this pull request May 15, 2025
(cherry picked from commit 4b4fc26)

# Conflicts:
#	core/src/main/java/org/frankframework/pipes/CredentialCheckingPipe.java
#	credentialProvider/src/main/java/org/frankframework/credentialprovider/delinea/DelineaCredentialFactory.java
evandongen added a commit that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to load credentials from secondary CredentialFactory when first delegate throws an exception
3 participants