Skip to content

Commit

Permalink
Removed deprecated message factory
Browse files Browse the repository at this point in the history
  • Loading branch information
tpazderka committed Dec 23, 2019
1 parent 0c53a95 commit b93ad90
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 114 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ The format is based on the [KeepAChangeLog] project.
### Added
- [#719] Add support for JWT registration tokens

### Removed
- [#676] Removed deprecated message factory and related stuff

[#719]: https://github.com/OpenIDC/pyoidc/pull/719
[#676]: https://github.com/OpenIDC/pyoidc/pull/676

## 1.1.2 [2019-11-23]

Expand Down
29 changes: 0 additions & 29 deletions src/oic/extension/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import inspect
import sys
from urllib.parse import urlparse

import requests
Expand Down Expand Up @@ -190,34 +189,6 @@ class ClientUpdateRequest(RegistrationRequest):
)


MSG = {
"RegistrationRequest": RegistrationRequest,
"ClientInfoResponse": ClientInfoResponse,
"ClientRegistrationError": ClientRegistrationError,
"ClientUpdateRequest": ClientUpdateRequest,
"TokenRevocationRequest": TokenRevocationRequest,
"TokenIntrospectionRequest": TokenIntrospectionRequest,
"TokenIntrospectionResponse": TokenIntrospectionResponse,
"SoftwareStatement": SoftwareStatement,
"StateJWT": StateJWT,
}


def factory(msgtype):
for _, obj in inspect.getmembers(sys.modules[__name__]):
if inspect.isclass(obj) and issubclass(obj, Message):
try:
if obj.__name__ == msgtype:
return obj
except AttributeError:
pass

# check among standard OAuth2 messages
from oic.oauth2 import message

return message.factory(msgtype)


def make_software_statement(keyjar, iss, **kwargs):
params = list(inspect.signature(JWT.__init__).parameters.keys())

Expand Down
30 changes: 0 additions & 30 deletions src/oic/oauth2/message.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import json
import logging
import warnings
from collections import MutableMapping
from collections import namedtuple
from json import JSONDecodeError
Expand Down Expand Up @@ -1154,35 +1153,6 @@ class ASConfigurationResponse(Message):
c_default = {"version": "3.0"}


MSG = {
"Message": Message,
"ErrorResponse": ErrorResponse,
"AuthorizationErrorResponse": AuthorizationErrorResponse,
"TokenErrorResponse": TokenErrorResponse,
"AccessTokenRequest": AccessTokenRequest,
"AuthorizationRequest": AuthorizationRequest,
"AuthorizationResponse": AuthorizationResponse,
"AccessTokenResponse": AccessTokenResponse,
"NoneResponse": NoneResponse,
"ROPCAccessTokenRequest": ROPCAccessTokenRequest,
"CCAccessTokenRequest": CCAccessTokenRequest,
"RefreshAccessTokenRequest": RefreshAccessTokenRequest,
"ResourceRequest": ResourceRequest,
"ASConfigurationResponse": ASConfigurationResponse,
}


def factory(msgtype):
warnings.warn(
"`factory` is deprecated. Use `OauthMessageFactory` instead.",
DeprecationWarning,
)
try:
return MSG[msgtype]
except KeyError:
raise FormatError("Unknown message type: %s" % msgtype)


MessageTuple = namedtuple("MessageTuple", ["request_cls", "response_cls"])


Expand Down
56 changes: 1 addition & 55 deletions src/oic/oic/message.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import inspect
import json
import logging
import sys
import time
import warnings
from typing import Dict # noqa
from typing import List # noqa
from urllib.parse import urlencode
Expand Down Expand Up @@ -1123,58 +1120,6 @@ class FrontChannelLogoutRequest(Message):
c_param = {"iss": SINGLE_OPTIONAL_STRING, "sid": SINGLE_OPTIONAL_STRING}


MSG = {
"RefreshAccessTokenRequest": RefreshAccessTokenRequest,
"TokenErrorResponse": TokenErrorResponse,
"AccessTokenResponse": AccessTokenResponse,
"UserInfoRequest": UserInfoRequest,
"AuthorizationResponse": AuthorizationResponse,
"AuthorizationErrorResponse": AuthorizationErrorResponse,
"AuthorizationRequest": AuthorizationRequest,
"AccessTokenRequest": AccessTokenRequest,
"AddressClaim": AddressClaim,
"OpenIDSchema": OpenIDSchema,
"RegistrationRequest": RegistrationRequest,
"RegistrationResponse": RegistrationResponse,
"ClientRegistrationErrorResponse": ClientRegistrationErrorResponse,
"IdToken": IdToken,
"RefreshSessionRequest": RefreshSessionRequest,
"RefreshSessionResponse": RefreshSessionResponse,
"CheckSessionRequest": CheckSessionRequest,
"CheckIDRequest": CheckIDRequest,
"EndSessionRequest": EndSessionRequest,
"EndSessionResponse": EndSessionResponse,
"Claims": Claims,
"OpenIDRequest": OpenIDRequest,
"ProviderConfigurationResponse": ProviderConfigurationResponse,
"AuthnToken": AuthnToken,
"UserInfoErrorResponse": UserInfoErrorResponse,
"DiscoveryRequest": DiscoveryRequest,
"DiscoveryResponse": DiscoveryResponse,
"ResourceRequest": ResourceRequest,
# LOGOUT messages
"LogoutToken": LogoutToken,
"BackChannelLogoutRequest": BackChannelLogoutRequest,
"FrontChannelLogoutRequest": FrontChannelLogoutRequest,
}


def factory(msgtype):
warnings.warn(
"`factory` is deprecated. Use `OIDCMessageFactory` instead.", DeprecationWarning
)
for _, obj in inspect.getmembers(sys.modules[__name__]):
if inspect.isclass(obj) and issubclass(obj, Message):
try:
if obj.__name__ == msgtype:
return obj
except AttributeError:
pass

# Fall back to basic OAuth2 messages
return message.factory(msgtype)


class OIDCMessageFactory(MessageFactory):
"""Factory that knows OIDC message types."""

Expand All @@ -1186,6 +1131,7 @@ class OIDCMessageFactory(MessageFactory):

userinfo_endpoint = MessageTuple(UserInfoRequest, Message)
registration_endpoint = MessageTuple(RegistrationRequest, RegistrationResponse)
read_endpoint = MessageTuple(Message, RegistrationResponse)
endsession_endpoint = MessageTuple(EndSessionRequest, EndSessionResponse)
checkid_endpoint = MessageTuple(CheckIDRequest, IdToken)
checksession_endpoint = MessageTuple(CheckSessionRequest, IdToken)
Expand Down

0 comments on commit b93ad90

Please sign in to comment.