7
7
from saml2 .saml import NAMEID_FORMAT_EMAILADDRESS
8
8
from saml2 .saml import NAMEID_FORMAT_UNSPECIFIED
9
9
10
+ from satosa .internal import AuthenticationInformation as _AuthenticationInformation
10
11
from satosa .internal import InternalData as _InternalData
11
12
from satosa import util
12
13
@@ -27,6 +28,14 @@ def __init__(self, user_id_hash_type, requester, requester_name=None):
27
28
requester_name = requester_name ,
28
29
)
29
30
31
+ @classmethod
32
+ def from_dict (cls , data ):
33
+ instance = cls (
34
+ user_id_hash_type = data .get ("hash_type" ),
35
+ requester = data .get ("requester" ),
36
+ requester_name = data .get ("requester_name" ),
37
+ )
38
+ return instance
30
39
31
40
32
41
class InternalResponse (_InternalData ):
@@ -36,8 +45,25 @@ def __init__(self, auth_info=None):
36
45
" Use satosa.internal.InternalData class instead."
37
46
)
38
47
_warnings .warn (msg , DeprecationWarning )
48
+ auth_info = auth_info or _AuthenticationInformation ()
39
49
super ().__init__ (auth_info = auth_info )
40
50
51
+ @classmethod
52
+ def from_dict (cls , data ):
53
+ """
54
+ :type data: dict[str, dict[str, str] | str]
55
+ :rtype: satosa.internal_data.InternalResponse
56
+ :param data: A dict representation of an InternalResponse object
57
+ :return: An InternalResponse object
58
+ """
59
+ auth_info = _AuthenticationInformation .from_dict (data .get ("auth_info" ))
60
+ instance = cls (auth_info = auth_info )
61
+ instance .user_id_hash_type = data .get ("hash_type" )
62
+ instance .attributes = data .get ("attributes" , {})
63
+ instance .user_id = data .get ("user_id" )
64
+ instance .requester = data .get ("requester" )
65
+ return instance
66
+
41
67
42
68
class SAMLInternalResponse (InternalResponse ):
43
69
"""
0 commit comments