Skip to content

Wss4jHandler: override securement password using the message context #1408

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

Merged

Conversation

cachescrubber
Copy link
Contributor

Wss4jHandler: override securement password using the message context

Analog to the ``securementUsername, allow to override the `securementPassword` using the `MessageContext` in order to efficiently support per-request credentials.

  @Override
  public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
    AlternativeCredentials alternativeCredentials = context.get();
    // override default interceptor username/password using per-request messageContext.
    if (alternativeCredentials != null) {
      messageContext.setProperty(Wss4jSecurityInterceptor.SECUREMENT_USER_PROPERTY_NAME,
          alternativeCredentials.getUsername());
      messageContext.setProperty(Wss4jSecurityInterceptor.SECUREMENT_PASSWORD_PROPERTY_NAME,
          alternativeCredentials.getPassword());
    }
    return super.handleRequest(messageContext);
  }

This is a non breaking change, test are added accordingly.

@corneil
Copy link
Contributor

corneil commented Apr 10, 2024

Thank you @cachescrubber

@corneil corneil merged commit 37662a0 into spring-projects:main Apr 10, 2024
@cachescrubber cachescrubber deleted the wss4j_credentials_override branch April 10, 2024 14:49
@corneil corneil added this to the 4.0.11 milestone May 17, 2024
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.

2 participants