public class AuthUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_HEADER
RFC7235 Authorization header key "Authorization" (RFC 7235 sec 4.2).
|
static String |
AUTHID_HEADER
Header giving user authenticated ID "X-VO-Authenticated" (SSO).
|
static String |
CHALLENGE_HEADER
RFC 7235 challenge header key "WWW-Authenticate" (RFC 7235 sec 4.1).
|
static boolean |
LOG_SECRETS
Global config: if true, passwords etc may be logged by logger.
|
static String |
LOGSECRETS_PROP
Name of system property "auth.logsecrets" which if set "true"
will allow reporting of sensitive information such as passwords
through the logging system.
|
static Charset |
UTF8
UTF-8 charset, guaranteed present.
|
Modifier and Type | Method and Description |
---|---|
static String |
authFailureMessage(HttpURLConnection hconn)
Prepares a short user-readable message indicating the state of a
connection that failed because of auth issues.
|
static byte[] |
base64Encode(byte[] data)
Converts a byte array to its BASE64 encoded form.
|
static String |
cookieLogText(HttpCookie cookie)
Returns a string suitable for reporting through the logging system
to represent a cookie.
|
static String |
getAuthenticatedId(AuthConnection aconn)
Returns the authenticated user ID recorded in the headers of
a URL connection.
|
static Challenge[] |
getChallenges(URLConnection conn)
Extracts challenges from an HTTP response.
|
static int |
getResponseCode(URLConnection conn)
Returns the HTTP response code from a URL connection.
|
static void |
popUiParent()
Restores the parent component of the user interface to its old value.
|
static void |
postForm(HttpURLConnection hconn,
Map<String,String> params)
Posts name=value pairs to an HTTP connection
in
application/x-www-form-urlencoded format. |
static HttpURLConnection |
postForm(URL url,
Map<String,String> params)
Posts name=value pairs over HTTP in
application/x-www-form-urlencoded format. |
static void |
pushUiParent(Component parent)
Replaces the parent component of the user interface currently
installed on the default AuthManager instance.
|
static String |
unNullString(String txt)
Returns the input string, unless it's null, in which case it
returns the empty string.
|
static boolean |
useGacsCapabilitiesHacks(URL url)
Whether to hack around deficiencies known to exist in GACS
/capabilities endpoint for a given URL.
|
static boolean |
useGacsDataHacks(URL url)
Whether to hack around deficiencies known to exist in GACS
DataLink service resources for a given URL.
|
public static final Charset UTF8
public static final String CHALLENGE_HEADER
public static final String AUTH_HEADER
public static final String AUTHID_HEADER
public static final String LOGSECRETS_PROP
public static boolean LOG_SECRETS
public static byte[] base64Encode(byte[] data)
data
- input bufferpublic static int getResponseCode(URLConnection conn)
conn
- URL connectionpublic static Challenge[] getChallenges(URLConnection conn)
conn
- open URL connection (typically, but not necessarily, 401)public static boolean useGacsCapabilitiesHacks(URL url)
url
- URLpublic static boolean useGacsDataHacks(URL url)
url
- URLpublic static String getAuthenticatedId(AuthConnection aconn) throws IOException
aconn
- connection to endpoint expected to yield an auth IDIOException
public static String authFailureMessage(HttpURLConnection hconn)
hconn
- open connection, should usually be 401 or 403public static String unNullString(String txt)
txt
- stringpublic static String cookieLogText(HttpCookie cookie)
LOG_SECRETS
,
it will or will not contain sensitive information.cookie
- cookie to representpublic static void pushUiParent(Component parent)
parent
- new UI parent componentpublic static void popUiParent()
pushUiParent(java.awt.Component)
.public static HttpURLConnection postForm(URL url, Map<String,String> params) throws IOException
application/x-www-form-urlencoded
format.url
- destination URLparams
- map of name->value pairsIOException
public static void postForm(HttpURLConnection hconn, Map<String,String> params) throws IOException
application/x-www-form-urlencoded
format.
The supplied connection can be the result of a call to
URL.openConnection()
, with or without some customization.hconn
- unopened connectionparams
- map of name->value pairsIOException