parameters:
    authbucket_oauth2.response_handler:
        code:               AuthBucket\OAuth2\ResponseType\CodeResponseTypeHandler
        token:              AuthBucket\OAuth2\ResponseType\TokenResponseTypeHandler

    authbucket_oauth2.grant_handler:
        authorization_code: AuthBucket\OAuth2\GrantType\AuthorizationCodeGrantTypeHandler
        client_credentials: AuthBucket\OAuth2\GrantType\ClientCredentialsGrantTypeHandler
        password:           AuthBucket\OAuth2\GrantType\PasswordGrantTypeHandler
        refresh_token:      AuthBucket\OAuth2\GrantType\RefreshTokenGrantTypeHandler

    authbucket_oauth2.token_handler:
        bearer:             AuthBucket\OAuth2\TokenType\BearerTokenTypeHandler
        mac:                AuthBucket\OAuth2\TokenType\MacTokenTypeHandler

    authbucket_oauth2.resource_handler:
        model:              AuthBucket\OAuth2\ResourceType\ModelResourceTypeHandler
        debug_endpoint:     AuthBucket\OAuth2\ResourceType\DebugEndpointResourceTypeHandler

services:
    authbucket_oauth2.exception_listener:
        class: AuthBucket\OAuth2\EventListener\ExceptionListener
        tags:
            - { name: kernel.event_listener, event: kernel.exception, method: onKernelException, priority: -8 }

    authbucket_oauth2.response_handler.factory:
        class: AuthBucket\OAuth2\ResponseType\ResponseTypeHandlerFactory
        arguments:
            - "@security.context"
            - "@validator"
            - "@authbucket_oauth2.model_manager.factory"
            - "@authbucket_oauth2.token_handler.factory"
            - "%authbucket_oauth2.response_handler%"

    authbucket_oauth2.grant_handler.factory:
        class: AuthBucket\OAuth2\GrantType\GrantTypeHandlerFactory
        arguments:
            - "@security.context"
            - "@security.user_checker"
            - "@security.encoder_factory"
            - "@validator"
            - "@authbucket_oauth2.model_manager.factory"
            - "@authbucket_oauth2.token_handler.factory"
            - ~
            - "%authbucket_oauth2.grant_handler%"

    authbucket_oauth2.token_handler.factory:
        class: AuthBucket\OAuth2\TokenType\TokenTypeHandlerFactory
        arguments:
            - "@validator"
            - "@authbucket_oauth2.model_manager.factory"
            - "%authbucket_oauth2.token_handler%"

    authbucket_oauth2.resource_handler.factory:
        class: AuthBucket\OAuth2\ResourceType\ResourceTypeHandlerFactory
        arguments:
            - "@http_kernel"
            - "@authbucket_oauth2.model_manager.factory"
            - "%authbucket_oauth2.resource_handler%"

    authbucket_oauth2.oauth2_controller:
        class: AuthBucket\OAuth2\Controller\OAuth2Controller
        arguments:
            - "@security.context"
            - "@validator"
            - "@authbucket_oauth2.model_manager.factory"
            - "@authbucket_oauth2.response_handler.factory"
            - "@authbucket_oauth2.grant_handler.factory"

    authbucket_oauth2.authorize_controller:
        class: AuthBucket\OAuth2\Controller\AuthorizeController
        arguments:
            - "@validator"
            - "@serializer"
            - "@authbucket_oauth2.model_manager.factory"

    authbucket_oauth2.client_controller:
        class: AuthBucket\OAuth2\Controller\ClientController
        arguments:
            - "@validator"
            - "@serializer"
            - "@authbucket_oauth2.model_manager.factory"

    authbucket_oauth2.scope_controller:
        class: AuthBucket\OAuth2\Controller\ScopeController
        arguments:
            - "@validator"
            - "@serializer"
            - "@authbucket_oauth2.model_manager.factory"

    security.authentication.provider.token:
        class: AuthBucket\OAuth2\Security\Authentication\Provider\TokenProvider
        arguments:
            - ~
            - "@authbucket_oauth2.model_manager.factory"

    security.authentication.listener.token:
        class: AuthBucket\OAuth2\Security\Firewall\TokenListener
        arguments:
            - ~
            - "@security.context"
            - "@security.authentication.manager"
            - "@validator"

    security.authentication.provider.resource:
        class: AuthBucket\OAuth2\Security\Authentication\Provider\ResourceProvider
        arguments:
            - ~
            - "@authbucket_oauth2.resource_handler.factory"
            - ~
            - ~
            - ~

    security.authentication.listener.resource:
        class: AuthBucket\OAuth2\Security\Firewall\ResourceListener
        arguments:
            - ~
            - "@security.context"
            - "@security.authentication.manager"
            - "@validator"
            - "@authbucket_oauth2.token_handler.factory"
