Skip to content

Commit

Permalink
Change value of BasicAuthenticationInterceptor.PRINCIPAL_KEY (#76)
Browse files Browse the repository at this point in the history
This is a breaking change for applications that are using this library
with basic authentication. The change needed in those applications is to
change the key requested from the message context to the new value of
PRINCIPAL_KEY, which is now "dropwizard.jakarta.xml.ws.principal"

Also, added the current date/time in the output of JavaFirstServiceImpl
and the two HTTP resource classes, so that it is clear that new requests
are being made, e.g. in a browser

Closes #74
  • Loading branch information
sleberknight authored Nov 12, 2023
1 parent dba244c commit fee8cd9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.time.LocalDateTime;

@Path("/mtomclient")
@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -39,7 +40,8 @@ public String getFoo() {

try {
return "Hello response: " + hr.getTitle() + ", " +
IOUtils.readStringFromStream(hr.getBinary().getInputStream());
IOUtils.readStringFromStream(hr.getBinary().getInputStream()) +
" at " + LocalDateTime.now();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import ws.example.ws.xml.jakarta.dropwizard.kiwiproject.org.wsdlfirstservice.ObjectFactory;
import ws.example.ws.xml.jakarta.dropwizard.kiwiproject.org.wsdlfirstservice.WsdlFirstService;

import java.time.LocalDateTime;

/**
* A Dropwizard resource that invokes WsdlFirstService SOAP web service.
*
Expand All @@ -35,6 +37,6 @@ public String getFoo() {

EchoResponse er = wsdlFirstServiceClient.echo(e);

return "Echo response: " + er.getValue();
return "Echo response: " + er.getValue() + " at " + LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.xml.ws.WebServiceContext;

import java.security.Principal;
import java.time.LocalDateTime;

@WebService(name = "JavaFirstService",
serviceName = "JavaFirstService",
Expand All @@ -26,7 +27,7 @@ public String echo(String in) throws JavaFirstServiceException {
throw new JavaFirstServiceException("Invalid parameter");
}

Principal user = (Principal) wsContext.getMessageContext().get("dropwizard.jaxws.principal");
return in + "; principal: " + user.getName();
Principal user = (Principal) wsContext.getMessageContext().get("dropwizard.jakarta.xml.ws.principal");
return in + "; principal: " + user.getName() + " at " + LocalDateTime.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BasicAuthenticationInterceptor extends AbstractPhaseInterceptor<Mes

private static final Logger LOG = LoggerFactory.getLogger(BasicAuthenticationInterceptor.class);

public static final String PRINCIPAL_KEY = "dropwizard.jaxws.principal";
public static final String PRINCIPAL_KEY = "dropwizard.jakarta.xml.ws.principal";

private BasicAuthentication authentication;

Expand Down

0 comments on commit fee8cd9

Please sign in to comment.