Class AuthDomain
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
AuthDomain.AuthDomain$Impl,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
Nested ClassesModifier and TypeClassDescriptionstatic classThe AuthDomain$Impl type represents a native instance of the abstract AuthDomain class.static classstatic classAuthDomain.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
ConstructorsConstructorDescriptionCreates a new AuthDomain.AuthDomain(MemorySegment address) Create a AuthDomain proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescription@Nullable Stringaccepts(ServerMessage msg) Checks ifmsgcontains appropriate authorization for this AuthDomain to accept it.protected Stringaccepts(ServerMessage msg, String header) voidAddspathtodomain.protected AuthDomainasParent()Returns this instance as if it were its parent type.challenge(ServerMessage msg) Adds a "WWW-Authenticate" or "Proxy-Authenticate" header tomsg.booleancheckPassword(ServerMessage msg, String username, String password) Checks ifmsgauthenticates to this AuthDomain viausernameandpassword.booleancovers(ServerMessage msg) Checks if this AuthDomain requiresmsgto be authenticated (according to its paths and filter function).static MemoryLayoutThe memory layout of the native struct.getRealm()Gets the realm name associated withdomain.static @Nullable TypegetType()Get the GType of the AuthDomain classvoidremovePath(String path) Removespathfromdomain.voidsetFilter(@Nullable AuthDomainFilter filter) Addsfilteras an authentication filter todomain.voidsetGenericAuthCallback(@Nullable AuthDomainGenericAuthCallback authCallback) SetsauthCallbackas an authentication-handling callback fordomain.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
AuthDomain
public AuthDomain()Creates a new AuthDomain.
-
-
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 Javasuperkeyword, 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 ifmsgcontains appropriate authorization for this AuthDomain to accept it.Mirroring
covers(org.gnome.soup.ServerMessage), this does not check whether or not this AuthDomain cares ifmsgis authorized.This is used by
Serverinternally and is probably of no use to anyone else.- Parameters:
msg- aSoupServerMessage- Returns:
- the username that
msghas authenticated as, if in fact it has authenticated.nullotherwise.
-
addPath
Addspathtodomain.Requests under
pathondomain'sserver 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'sstatus accordingly.This is used by
Serverinternally and is probably of no use to anyone else.- Parameters:
msg- aSoupServerMessage
-
checkPassword
Checks ifmsgauthenticates to this AuthDomain viausernameandpassword.This would normally be called from a
AuthDomainGenericAuthCallback.- Parameters:
msg- aSoupServerMessageusername- a usernamepassword- a password- Returns:
- whether or not the message is authenticated
-
covers
Checks if this AuthDomain requiresmsgto be authenticated (according to its paths and filter function).This does not actually look at whether
msgis authenticated, merely whether or not it needs to be.This is used by
Serverinternally and is probably of no use to anyone else.- Parameters:
msg- aSoupServerMessage- Returns:
trueif this AuthDomain requiresmsgto be authenticated
-
getRealm
-
removePath
Removespathfromdomain.Requests under
pathondomain'sserver 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
Addsfilteras an authentication filter todomain.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
trueif the request should still require authentication, orfalseif authentication is unnecessary for this request.To help prevent security holes, your filter should return
trueby default, and only returnfalseunder 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 returnfalsein that case, and then returntruefor all other methods (rather than returningtruefor PUT andfalsefor 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
SetsauthCallbackas an authentication-handling callback fordomain.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. SeeAuthDomainGenericAuthCallbackfor information on what the callback should do.- Parameters:
authCallback- the auth callback
-
accepts
-