Class GrantAuthorizer
- All Implemented Interfaces:
Authorizer
public class GrantAuthorizer extends Object implements Authorizer
This Authorizer
implementation grants permission
for a set of operations defined at construction time.
If the operation does not match, it ignores the authorization request.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cometd.bayeux.server.Authorizer
Authorizer.Operation, Authorizer.Result
-
Field Summary
Fields Modifier and Type Field Description static GrantAuthorizer
GRANT_ALL
GrantsAuthorizer.Operation.CREATE
,Authorizer.Operation.SUBSCRIBE
andAuthorizer.Operation.PUBLISH
authorizationstatic GrantAuthorizer
GRANT_CREATE
GrantsAuthorizer.Operation.CREATE
authorizationstatic GrantAuthorizer
GRANT_CREATE_SUBSCRIBE
GrantsAuthorizer.Operation.CREATE
andAuthorizer.Operation.SUBSCRIBE
authorizationstatic GrantAuthorizer
GRANT_NONE
Grants no authorization, the authorization request is ignoredstatic GrantAuthorizer
GRANT_PUBLISH
GrantsAuthorizer.Operation.PUBLISH
authorizationstatic GrantAuthorizer
GRANT_SUBSCRIBE
GrantsAuthorizer.Operation.SUBSCRIBE
authorizationstatic GrantAuthorizer
GRANT_SUBSCRIBE_PUBLISH
GrantsAuthorizer.Operation.SUBSCRIBE
andAuthorizer.Operation.PUBLISH
authorization -
Method Summary
Modifier and Type Method Description Authorizer.Result
authorize(Authorizer.Operation operation, ChannelId channel, ServerSession session, ServerMessage message)
Callback invoked to authorize the givenoperation
on the givenchannel
.String
toString()
-
Field Details
-
GRANT_CREATE
GrantsAuthorizer.Operation.CREATE
authorization -
GRANT_SUBSCRIBE
GrantsAuthorizer.Operation.SUBSCRIBE
authorization -
GRANT_PUBLISH
GrantsAuthorizer.Operation.PUBLISH
authorization -
GRANT_CREATE_SUBSCRIBE
GrantsAuthorizer.Operation.CREATE
andAuthorizer.Operation.SUBSCRIBE
authorization -
GRANT_SUBSCRIBE_PUBLISH
GrantsAuthorizer.Operation.SUBSCRIBE
andAuthorizer.Operation.PUBLISH
authorization -
GRANT_ALL
GrantsAuthorizer.Operation.CREATE
,Authorizer.Operation.SUBSCRIBE
andAuthorizer.Operation.PUBLISH
authorization -
GRANT_NONE
Grants no authorization, the authorization request is ignored
-
-
Method Details
-
authorize
public Authorizer.Result authorize(Authorizer.Operation operation, ChannelId channel, ServerSession session, ServerMessage message)Description copied from interface:Authorizer
Callback invoked to authorize the given
operation
on the givenchannel
.Additional parameters are passed to this method as context parameters, so that it is possible to implement complex logic based on the
ServerSession
andServerMessage
that are requesting the authorization.Note that the message channel is not the same as the
channelId
parameter. For example, for subscription requests, the message channel isChannel.META_SUBSCRIBE
, while thechannelId
parameter is the channel for which the subscription is requested.Note that for
create operation
, the channel instance does not yet exist: it will be created only after the authorization is granted.- Specified by:
authorize
in interfaceAuthorizer
- Parameters:
operation
- the operation to authorizechannel
- the channel for which the authorization has been requestedsession
- the session that is requesting the authorizationmessage
- the message that triggered the authorization request- Returns:
- the result of the authorization
-
toString
-