Class Auth
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Auth.AuthImpl
,AuthBasic
,AuthDigest
,AuthNegotiate
,AuthNTLM
Specific HTTP Authentication mechanisms are implemented by its subclasses, but applications never need to be aware of the specific subclasses being used.
SoupAuth
objects store the authentication data associated with a given bit
of web space. They are created automatically by Session
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
The AuthImpl type represents a native instance of the abstract Auth class.static class
Auth.Builder<B extends Auth.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Auth
asParent()
Returns this instance as if it were its parent type.void
authenticate
(String username, String password) Call this on an auth to authenticate it.static Auth.Builder
<? extends Auth.Builder> builder()
AAuth.Builder
object constructs aAuth
with the specified properties.boolean
Tests if this Auth is able to authenticate by providing credentials to theauthenticate(java.lang.String, java.lang.String)
.void
cancel()
Call this on an auth to cancel it.void
freeProtectionSpace
(SList<MemorySegment> space) Freesspace
.Returns the authority (host:port) that this Auth is associated with.getAuthorization
(Message msg) Generates an appropriate "Authorization" header formsg
.getInfo()
Gets an opaque identifier for this Auth.static MemoryLayout
The memory layout of the native struct.getProtectionSpace
(Uri sourceUri) Returns a list of paths on the server which this Auth extends over.getRealm()
Returns this Auth's realm.soup_auth_get_scheme_name: (attributes org.gtk.Method.get_property=scheme-name) Returns this Auth's scheme name.static Type
getType()
Get the GType of the Auth classboolean
Tests if this Auth has been given a username and password.boolean
Tests if this Auth has been cancelledboolean
Tests whether or not this Auth is associated with a proxy server rather than an "origin" server.boolean
Tests if this Auth is ready to make a request formsg
with.boolean
Updates this Auth with the information frommsg
andauthHeader
, possibly un-authenticating it.protected boolean
update
(Message msg, HashTable<MemorySegment, MemorySegment> authHeader) Updates this Auth with the information frommsg
andauthHeader
, possibly un-authenticating it.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Auth
Create a Auth proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Auth
Creates a newSoupAuth
of typetype
with the information frommsg
andauthHeader
.This is called by
Session
; you will normally not create auths yourself.- Parameters:
type
- the type of auth to create (a subtype ofSoupAuth
)msg
- theSoupMessage
the auth is being created forauthHeader
- the WWW-Authenticate/Proxy-Authenticate header- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
authenticate
Call this on an auth to authenticate it.Normally this will cause the auth's message to be requeued with the new authentication info.
- Parameters:
username
- the username provided by the user or clientpassword
- the password provided by the user or client
-
canAuthenticate
public boolean canAuthenticate()Tests if this Auth is able to authenticate by providing credentials to theauthenticate(java.lang.String, java.lang.String)
.- Returns:
true
if this Auth is able to accept credentials.
-
cancel
public void cancel()Call this on an auth to cancel it.You need to cancel an auth to complete an asynchronous authenticate operation when no credentials are provided (
authenticate(java.lang.String, java.lang.String)
is not called). TheSoupAuth
will be cancelled on dispose if it hans't been authenticated. -
freeProtectionSpace
Freesspace
.- Parameters:
space
- the return value fromgetProtectionSpace(org.gnome.glib.Uri)
-
getAuthority
Returns the authority (host:port) that this Auth is associated with.- Returns:
- the authority
-
getAuthorization
Generates an appropriate "Authorization" header formsg
.(The session will only call this if
isAuthenticated()
returnedtrue
.)- Parameters:
msg
- theSoupMessage
to be authorized- Returns:
- the "Authorization" header, which must be freed.
-
getInfo
Gets an opaque identifier for this Auth.The identifier can be used as a hash key or the like.
SoupAuth
objects from the same server with the same identifier refer to the same authentication domain (eg, the URLs associated with them take the same usernames and passwords).- Returns:
- the identifier
-
getProtectionSpace
Returns a list of paths on the server which this Auth extends over.(All subdirectories of these paths are also assumed to be part of this Auth's protection space, unless otherwise discovered not to be.)
- Parameters:
sourceUri
- the URI of the request that this Auth was generated in response to.- Returns:
- the list of
paths, which can be freed with
freeProtectionSpace(org.gnome.glib.SList<java.lang.foreign.MemorySegment>)
.
-
getRealm
Returns this Auth's realm.This is an identifier that distinguishes separate authentication spaces on a given server, and may be some string that is meaningful to the user. (Although it is probably not localized.)
- Returns:
- the realm name
-
getSchemeName
soup_auth_get_scheme_name: (attributes org.gtk.Method.get_property=scheme-name) Returns this Auth's scheme name. (Eg, "Basic", "Digest", or "NTLM")- Returns:
- the scheme name
-
isAuthenticated
public boolean isAuthenticated()Tests if this Auth has been given a username and password.- Returns:
true
if this Auth has been given a username and password
-
isCancelled
public boolean isCancelled()Tests if this Auth has been cancelled- Returns:
true
if this Auth has been cancelled
-
isForProxy
public boolean isForProxy()Tests whether or not this Auth is associated with a proxy server rather than an "origin" server.- Returns:
true
orfalse
-
isReady
Tests if this Auth is ready to make a request formsg
with.For most auths, this is equivalent to
isAuthenticated()
, but for some auth types (eg, NTLM), the auth may be sendable (eg, as an authentication request) even before it is authenticated.- Parameters:
msg
- aSoupMessage
- Returns:
true
if this Auth is ready to make a request with.
-
update
Updates this Auth with the information frommsg
andauthHeader
, possibly un-authenticating it.As with
Auth(org.gnome.glib.Type, org.gnome.soup.Message, java.lang.String)
, this is normally only used bySession
.- Parameters:
msg
- theSoupMessage
this Auth is being updated forauthHeader
- the WWW-Authenticate/Proxy-Authenticate header- Returns:
true
if this Auth is still a valid (but potentially unauthenticated)SoupAuth
.false
if something aboutauthParams
could not be parsed or incorporated into this Auth at all.
-
update
Updates this Auth with the information frommsg
andauthHeader
, possibly un-authenticating it.As with
Auth(org.gnome.glib.Type, org.gnome.soup.Message, java.lang.String)
, this is normally only used bySession
.- Parameters:
msg
- theSoupMessage
this Auth is being updated forauthHeader
- the WWW-Authenticate/Proxy-Authenticate header- Returns:
true
if this Auth is still a valid (but potentially unauthenticated)SoupAuth
.false
if something aboutauthParams
could not be parsed or incorporated into this Auth at all.
-
builder
AAuth.Builder
object constructs aAuth
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withAuth.Builder.build()
.
-