@Extensible @BrokerExtension @ThreadSafety(level=INTERFACE_THREADSAFE) public abstract class Advice extends java.lang.Object implements UnboundIDExtension, ExampleUsageProvider
dsconfig create-advice \ --advice-name "{name}" \ --type third-party \ --set "advice-id:{advice-code} --set "extension-class:{class-name}" \ --set "extension-argument:{name=value}" \ --set "evaluation-order-index:{index}where "{name}" is a user-friendly name to use for the advice type, "{advice-code}" is a unique advice code that must match the "code" string returned from a policy invocation, and "{class-name}" is the fully-qualified name of the Java class that extends
com.unboundid.directory.sdk.broker.api.Advice
.
"{index}" is an integer from 1 to 9999 that is used to determine the
order in which this type of advice should be invoked relative to other advice
that may be returned from the same policy evaluation.
"{name=value}" pairs specified using extension-arguments are values
that are provided to the advice implementation at initialization time.
If multiple initialization arguments should be provided to the extension,
then the "--set extension-argument:{name=value}
" option
should be provided multiple times.Constructor and Description |
---|
Advice()
No-args constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract HttpRequestResponse |
apply(PolicyRequestDetails requestDetails,
java.util.List<? extends AdviceStatement> statements,
HttpRequestResponse requestResponse)
This method is invoked when the specified Advice type is returned by
policy evaluation.
|
void |
defineConfigArguments(ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments
which may be used by this extension.
|
void |
finalizeAdvice()
Performs any cleanup which may be necessary when this advice
is to be taken out of service.
|
java.util.Map<java.util.List<java.lang.String>,java.lang.String> |
getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for
this extension.
|
abstract java.lang.String[] |
getExtensionDescription()
Retrieves a human-readable description for this extension.
|
abstract java.lang.String |
getExtensionName()
Retrieves a human-readable name for this extension.
|
void |
initializeAdvice(BrokerContext serverContext,
AdviceConfig config,
ArgumentParser parser)
Initializes this Advice implementation.
|
public Advice()
public abstract java.lang.String getExtensionName()
getExtensionName
in interface UnboundIDExtension
public abstract java.lang.String[] getExtensionDescription()
getExtensionDescription
in interface UnboundIDExtension
null
or an empty array if no description should be available.public java.util.Map<java.util.List<java.lang.String>,java.lang.String> getExamplesArgumentSets()
getExamplesArgumentSets
in interface ExampleUsageProvider
null
or empty if there should
not be any example argument sets.public void defineConfigArguments(ArgumentParser parser) throws ArgumentException
defineConfigArguments
in interface Configurable
parser
- The argument parser to be updated with the configuration
arguments which may be used by this extension.ArgumentException
- If a problem is encountered while updating the
provided argument parser.public void initializeAdvice(BrokerContext serverContext, AdviceConfig config, ArgumentParser parser) throws java.lang.Exception
serverContext
- A handle to the server context for the server in
which this extension is running.config
- The general configuration for this Advice.parser
- The argument parser which has been initialized from
the configuration for this Advice.java.lang.Exception
- If a problem occurs while initializing this Advice.public void finalizeAdvice()
public abstract HttpRequestResponse apply(PolicyRequestDetails requestDetails, java.util.List<? extends AdviceStatement> statements, HttpRequestResponse requestResponse) throws NotFulfilledException
requestDetails
- Details of the authorization request that
triggered the advice.statements
- List of advice instances with payload and
attributes containing advice details.requestResponse
- HTTP Request or Response that may be examined or
manipulated by the advice implementation. The
resource details are dependent upon the API method
that requested authorization and the type of request
being authorized. As an example, for a create
operation the request body may represent the
resource the client is attempting to create, while
for a retrieve operation the response body may
represent the resource to be returned to the client.NotFulfilledException
- if the advice cannot be successfully
applied. If the advice is defined to be obligatory, throwing this
exception will cause the requested operation to fail. If the advice is
not obligatory, throwing this exception will cause an error to be logged,
however the requested operation will not otherwise be impacted.