Skip to content

Commit

Permalink
chore(vertx-http): drop HTTP auth mech synchronous getCredentialTrans…
Browse files Browse the repository at this point in the history
…port
  • Loading branch information
michalvavrik committed Feb 21, 2025
1 parent e701f48 commit 7133be5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,11 @@ default Uni<Boolean> sendChallenge(RoutingContext context) {
/**
* The credential transport, used for finding the best candidate for authenticating and challenging when more than one
* mechanism is installed.
* and finding the best candidate for issuing a challenge when more than one mechanism is installed.
*
* May be null if this mechanism cannot interfere with other mechanisms
*/
@Deprecated(since = "2.8", forRemoval = true)
default HttpCredentialTransport getCredentialTransport() {
throw new UnsupportedOperationException();
}

/**
* The credential transport, used for finding the best candidate for authenticating and challenging when more than one
* mechanism is installed.
*
* May be null if this mechanism cannot interfere with other mechanisms
* May be {@link Uni} with null item if this mechanism cannot interfere with other mechanisms.
*/
default Uni<HttpCredentialTransport> getCredentialTransport(RoutingContext context) {
throw new UnsupportedOperationException();
return Uni.createFrom().nullItem();
}

class ChallengeSender implements Function<ChallengeData, Boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public Uni<? extends ChallengeData> apply(ChallengeData data) {

private Uni<SecurityIdentity> authenticateWithAllMechanisms(SecurityIdentity identity, int i,
RoutingContext routingContext) {
return getCredentialTransport(mechanisms[i], routingContext)
return mechanisms[i].getCredentialTransport(routingContext)
.onItem().transformToUni(new Function<HttpCredentialTransport, Uni<? extends SecurityIdentity>>() {
@Override
public Uni<SecurityIdentity> apply(HttpCredentialTransport httpCredentialTransport) {
Expand Down Expand Up @@ -425,7 +425,7 @@ public Uni<? extends HttpAuthenticationMechanism> apply(HttpAuthenticationMechan

private Uni<HttpAuthenticationMechanism> getPathSpecificMechanism(int index, RoutingContext routingContext,
String pathSpecificMechanism) {
return getCredentialTransport(mechanisms[index], routingContext).onItem()
return mechanisms[index].getCredentialTransport(routingContext).onItem()
.transform(new Function<HttpCredentialTransport, HttpAuthenticationMechanism>() {
@Override
public HttpAuthenticationMechanism apply(HttpCredentialTransport t) {
Expand Down Expand Up @@ -458,15 +458,6 @@ static void selectAuthMechanism(RoutingContext routingContext, String authMechan
routingContext.put(AUTH_MECHANISM, authMechanism);
}

private static Uni<HttpCredentialTransport> getCredentialTransport(HttpAuthenticationMechanism mechanism,
RoutingContext routingContext) {
try {
return mechanism.getCredentialTransport(routingContext);
} catch (UnsupportedOperationException ex) {
return Uni.createFrom().item(mechanism.getCredentialTransport());
}
}

private static void rememberAuthAttempted(RoutingContext routingContext) {
routingContext.put(ATTEMPT_AUTH_INVOKED, TRUE);
}
Expand All @@ -489,7 +480,7 @@ private static boolean authenticatedWithDifferentAuthMechanism(String newAuthMec
* when the selected mechanism is same as the one already used.
*/
private static Uni<HttpCredentialTransport> rememberAuthMechScheme(HttpAuthenticationMechanism mech, RoutingContext event) {
return getCredentialTransport(mech, event)
return mech.getCredentialTransport(event)
.onItem().ifNotNull().invoke(new Consumer<HttpCredentialTransport>() {
@Override
public void accept(HttpCredentialTransport t) {
Expand Down

0 comments on commit 7133be5

Please sign in to comment.