Package org.oa4mp.server.proxy
Class ProxyUtils
- java.lang.Object
-
- org.oa4mp.server.proxy.ProxyUtils
-
public class ProxyUtils extends Object
Class with shared proxy utilities. The client uses this to send requests via the proxy. The server hosting the proxy uses the RFC8628 servlets to process these.Created by Jeff Gaynor
on 3/4/22 at 4:55 PM
-
-
Field Summary
Fields Modifier and Type Field Description static String
LOCAL_DF_CONSENT_XA
For device flows, if requiring local consent is enabled, this is the parameter that is sent.static String
NO_PROXY_SCOPES
-
Constructor Summary
Constructors Constructor Description ProxyUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static OA2CLCCommands
createCLC(OA2SE oa2SE, OA2ServiceTransaction t)
Create a completely new CLC and load the configuration into it.protected static void
doProxy(OA2SE oa2SE, AbstractAuthenticationServlet.AuthorizedState state)
protected static void
doProxy(OA2SE oa2SE, RFC8628AuthenticationServer.PendingState pendingState)
protected static void
doProxyClaimsRefresh(OA2SE oa2SE, OA2ServiceTransaction t)
Attempt to do a refresh of the claims from the proxy server.static X509Certificate[]
getCerts(OA2SE oa2SE, OA2ServiceTransaction t)
protected static OA2CLCCommands
getCLC(OA2SE oa2SE, OA2ServiceTransaction t)
Get the fully functional CLC (Command Line Client) associated with this transaction.protected static void
getProxyAccessToken(OA2SE oa2SE, OA2ServiceTransaction t)
Gets the access token from the Proxy.protected static Collection<String>
getRequestScopes(OA2ServiceTransaction t, OA2CLCCommands clcCommands)
This will take the various bits and determine the actual scopes that should be in the request to the proxy.protected static void
setClaimsFromProxy(OA2ServiceTransaction t, net.sf.json.JSONObject proxyClaims, edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugger)
Takes the claims returned fromthe proxy and adds them to the transactionprotected static void
startProxyAuthCodeFlow(OA2SE oa2SE, OA2ServiceTransaction t, javax.servlet.http.HttpServletResponse response)
Starts the authorization code flow in the proxy.protected static String
startProxyDeviceFlow(OA2SE oa2SE, OA2ServiceTransaction t, RFC8628State rfc8628State)
Starts device flow with proxy and populates theRFC8628State
with the information from the proxy.protected static OA2ATException
toOA2ATException(edu.uiuc.ncsa.security.servlet.ServiceClientHTTPException serviceClientHTTPException, OA2ServiceTransaction t)
Handles various types of exceptions, transforming them to anOA2ATException
.protected static void
userCodeToProxyRedirect(OA2SE oa2SE, OA2ServiceTransaction t, RFC8628AuthenticationServer.PendingState pendingState)
Takes the verification_uri_complete from the CLC (on the proxy site) and forwards the user's browser so they can log in on the proxy server.
-
-
-
Field Detail
-
LOCAL_DF_CONSENT_XA
public static final String LOCAL_DF_CONSENT_XA
For device flows, if requiring local consent is enabled, this is the parameter that is sent. It is the redirect on the proxy side back to this site's consent machinery.
-
NO_PROXY_SCOPES
public static final String NO_PROXY_SCOPES
- See Also:
- Constant Field Values
-
-
Method Detail
-
doProxy
protected static void doProxy(OA2SE oa2SE, RFC8628AuthenticationServer.PendingState pendingState) throws Throwable
- Throws:
Throwable
-
doProxy
protected static void doProxy(OA2SE oa2SE, AbstractAuthenticationServlet.AuthorizedState state) throws Throwable
- Throws:
Throwable
-
startProxyAuthCodeFlow
protected static void startProxyAuthCodeFlow(OA2SE oa2SE, OA2ServiceTransaction t, javax.servlet.http.HttpServletResponse response) throws Throwable
Starts the authorization code flow in the proxy. It redirects the user's browser. When done, the callback the proxy uses is to theProxyCallbackServlet
's ready endpoint.- Parameters:
oa2SE
-t
-response
-- Throws:
Throwable
-
startProxyDeviceFlow
protected static String startProxyDeviceFlow(OA2SE oa2SE, OA2ServiceTransaction t, RFC8628State rfc8628State) throws Throwable
Starts device flow with proxy and populates theRFC8628State
with the information from the proxy. This returns the proxy's user code.
-
userCodeToProxyRedirect
protected static void userCodeToProxyRedirect(OA2SE oa2SE, OA2ServiceTransaction t, RFC8628AuthenticationServer.PendingState pendingState) throws Throwable
Takes the verification_uri_complete from the CLC (on the proxy site) and forwards the user's browser so they can log in on the proxy server.- Parameters:
oa2SE
-t
-- Throws:
Throwable
-
getCLC
protected static OA2CLCCommands getCLC(OA2SE oa2SE, OA2ServiceTransaction t) throws Throwable
Get the fully functional CLC (Command Line Client) associated with this transaction. Note that if you update the client, you must save the state
-
createCLC
protected static OA2CLCCommands createCLC(OA2SE oa2SE, OA2ServiceTransaction t) throws Throwable
Create a completely new CLC and load the configuration into it.
-
getProxyAccessToken
protected static void getProxyAccessToken(OA2SE oa2SE, OA2ServiceTransaction t) throws Throwable
Gets the access token from the Proxy. This then finishes setting up the claims locally.- Parameters:
oa2SE
-t
-- Throws:
Throwable
-
toOA2ATException
protected static OA2ATException toOA2ATException(edu.uiuc.ncsa.security.servlet.ServiceClientHTTPException serviceClientHTTPException, OA2ServiceTransaction t)
Handles various types of exceptions, transforming them to anOA2ATException
.- Parameters:
serviceClientHTTPException
-t
-- Returns:
-
setClaimsFromProxy
protected static void setClaimsFromProxy(OA2ServiceTransaction t, net.sf.json.JSONObject proxyClaims, edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugger)
Takes the claims returned fromthe proxy and adds them to the transaction- Parameters:
t
-proxyClaims
-debugger
-
-
doProxyClaimsRefresh
protected static void doProxyClaimsRefresh(OA2SE oa2SE, OA2ServiceTransaction t) throws Throwable
Attempt to do a refresh of the claims from the proxy server. This is not used yet since there are a lot of policy type decisions to make. For instance, what if the lifetimes of tokens on the proxy are much shorter than on the server? Then there has to be some way to communicate that no updates to the claims are possible.
-
getRequestScopes
protected static Collection<String> getRequestScopes(OA2ServiceTransaction t, OA2CLCCommands clcCommands)
This will take the various bits and determine the actual scopes that should be in the request to the proxy.Logic
- forward scopes to proxy: true
⇒ forward everything allowed - forward scopes to proxy: false
OA2Client.getProxyRequestScopes()
is trivial
⇒ forward full set of configured scopes for the proxy- else
⇒ forward intersection of this list with the configured scopes for the proxy - If the proxy requests scopes contains the reserved scope of
NO_PROXY_SCOPES
, then request no scopes at all from the proxy server.
- Parameters:
t
-clcCommands
-- Returns:
- forward scopes to proxy: true
-
getCerts
public static X509Certificate[] getCerts(OA2SE oa2SE, OA2ServiceTransaction t) throws Throwable
- Throws:
Throwable
-
-