Class AuthDomain
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
AuthDomain.AuthDomainImpl
,AuthDomainBasic
,AuthDomainDigest
A SoupAuthDomain
manages authentication for all or part of a
Server
. To make a server require authentication, first create
an appropriate subclass of SoupAuthDomain
, and then add it to the
server with Server.addAuthDomain(org.gnome.soup.AuthDomain)
.
In order for an auth domain to have any effect, you must add one or more
paths to it (via addPath(java.lang.String)
). To require authentication for
all ordinary requests, add the path "/"
. (Note that this does not include
the special "*"
URI (eg, "OPTIONS *"), which must be added as a separate
path if you want to cover it.)
If you need greater control over which requests should and shouldn't be
authenticated, add paths covering everything you might want authenticated,
and then use a filter (setFilter(org.gnome.soup.AuthDomainFilter)
to bypass
authentication for those requests that don't need it.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
The AuthDomainImpl type represents a native instance of the abstract AuthDomain class.static class
AuthDomain.Builder<B extends AuthDomain.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
ConstructorDescriptionAuthDomain
(MemorySegment address) Create a AuthDomain proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionaccepts
(ServerMessage msg) Checks ifmsg
contains appropriate authorization for this AuthDomain to accept it.protected String
accepts
(ServerMessage msg, String header) void
Addspath
to this AuthDomain.protected AuthDomain
asParent()
Returns this instance as if it were its parent type.static AuthDomain.Builder
<? extends AuthDomain.Builder> builder()
AAuthDomain.Builder
object constructs aAuthDomain
with the specified properties.challenge
(ServerMessage msg) Adds a "WWW-Authenticate" or "Proxy-Authenticate" header tomsg
.boolean
checkPassword
(ServerMessage msg, String username, String password) Checks ifmsg
authenticates to this AuthDomain viausername
andpassword
.boolean
covers
(ServerMessage msg) Checks if this AuthDomain requiresmsg
to be authenticated (according to its paths and filter function).static MemoryLayout
The memory layout of the native struct.getRealm()
Gets the realm name associated with this AuthDomain.static Type
getType()
Get the GType of the AuthDomain classvoid
removePath
(String path) Removespath
from this AuthDomain.void
setFilter
(AuthDomainFilter filter) Addsfilter
as an authentication filter to this AuthDomain.void
setGenericAuthCallback
(AuthDomainGenericAuthCallback authCallback) SetsauthCallback
as an authentication-handling callback for this AuthDomain.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
-
AuthDomain
Create a AuthDomain proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
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. -
accepts
Checks ifmsg
contains appropriate authorization for this AuthDomain to accept it.Mirroring
covers(org.gnome.soup.ServerMessage)
, this does not check whether or not this AuthDomain cares ifmsg
is authorized.This is used by
Server
internally and is probably of no use to anyone else.- Parameters:
msg
- aSoupServerMessage
- Returns:
- the username that
msg
has authenticated as, if in fact it has authenticated.null
otherwise.
-
addPath
Addspath
to this AuthDomain.Requests under
path
on this AuthDomain's server will require authentication (unless overridden byremovePath(java.lang.String)
orsetFilter(org.gnome.soup.AuthDomainFilter)
).- Parameters:
path
- the path to add to this AuthDomain
-
challenge
Adds a "WWW-Authenticate" or "Proxy-Authenticate" header tomsg
.It requests that the client authenticate, and sets
msg
's status accordingly.This is used by
Server
internally and is probably of no use to anyone else.- Parameters:
msg
- aSoupServerMessage
-
checkPassword
Checks ifmsg
authenticates to this AuthDomain viausername
andpassword
.This would normally be called from a
AuthDomainGenericAuthCallback
.- Parameters:
msg
- aSoupServerMessage
username
- a usernamepassword
- a password- Returns:
- whether or not the message is authenticated
-
covers
Checks if this AuthDomain requiresmsg
to be authenticated (according to its paths and filter function).This does not actually look at whether
msg
is authenticated, merely whether or not it needs to be.This is used by
Server
internally and is probably of no use to anyone else.- Parameters:
msg
- aSoupServerMessage
- Returns:
true
if this AuthDomain requiresmsg
to be authenticated
-
getRealm
Gets the realm name associated with this AuthDomain.- Returns:
- this AuthDomain's realm
-
removePath
Removespath
from this AuthDomain.Requests under
path
on this AuthDomain's server will NOT require authentication.This is not simply an undo-er for
addPath(java.lang.String)
; it can be used to "carve out" a subtree that does not require authentication inside a hierarchy that does. Note also that unlike withaddPath(java.lang.String)
, this cannot be overridden by adding a filter, as filters can only bypass authentication that would otherwise be required, not require it where it would otherwise be unnecessary.- Parameters:
path
- the path to remove from this AuthDomain
-
setFilter
Addsfilter
as an authentication filter to this AuthDomain.The filter gets a chance to bypass authentication for certain requests that would otherwise require it. Eg, it might check the message's path in some way that is too complicated to do via the other methods, or it might check the message's method, and allow GETs but not PUTs.
The filter function returns
true
if the request should still require authentication, orfalse
if authentication is unnecessary for this request.To help prevent security holes, your filter should return
true
by default, and only returnfalse
under specifically-tested circumstances, rather than the other way around. Eg, in the example above, where you want to authenticate PUTs but not GETs, you should check if the method is GET and returnfalse
in that case, and then returntrue
for all other methods (rather than returningtrue
for PUT andfalse
for all other methods). This way if it turned out (now or later) that some paths supported additional methods besides GET and PUT, those methods would default to being NOT allowed for unauthenticated users.You can also set the filter by setting the SoupAuthDomain:filter and
AuthDomain:filter-data properties
, which can also be used to set the filter at construct time.- Parameters:
filter
- the auth filter for this AuthDomain
-
setGenericAuthCallback
SetsauthCallback
as an authentication-handling callback for this AuthDomain.Whenever a request comes in to this AuthDomain which cannot be authenticated via a domain-specific auth callback (eg,
AuthDomainDigestAuthCallback
), the generic auth callback will be invoked. SeeAuthDomainGenericAuthCallback
for information on what the callback should do.- Parameters:
authCallback
- the auth callback
-
accepts
-
builder
AAuthDomain.Builder
object constructs aAuthDomain
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withAuthDomain.Builder.build()
.
-