diff --git a/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java b/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java index 49cbc38b..dee68fd5 100644 --- a/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java +++ b/code/app/com/feth/play/module/pa/providers/wwwauth/WWWAuthenticateProvider.java @@ -15,6 +15,8 @@ */ package com.feth.play.module.pa.providers.wwwauth; +import java.util.Optional; + import com.feth.play.module.pa.PlayAuthenticate; import com.feth.play.module.pa.exceptions.AuthException; import com.feth.play.module.pa.providers.AuthProvider; @@ -99,11 +101,12 @@ private Result deny(Context context) { @Override public Object authenticate(Context context, Object payload) throws AuthException { - String auth = context.request().header("Authorization").get(); + Optional authHeader = context.request().header("Authorization"); - if (auth == null) { + if (!authHeader.isPresent()) { return deny(context); } + String auth = authHeader.get(); int ix = auth.indexOf(32); if (ix == -1 || !authScheme().equalsIgnoreCase(auth.substring(0,ix))) { return deny(context);