comparison libpurple/protocols/msn/nexus.h @ 23489:25899ec348a4

Patch 2 from Qulogic, this one adds SSO authentication committer: Ka-Hing Cheung <khc@hxbc.us>
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 26 Dec 2007 00:34:12 +0000
parents 10d27a4be2fd
children 72aa2ccad28d
comparison
equal deleted inserted replaced
23488:75be80ddeca5 23489:25899ec348a4
24 #ifndef _MSN_NEXUS_H_ 24 #ifndef _MSN_NEXUS_H_
25 #define _MSN_NEXUS_H_ 25 #define _MSN_NEXUS_H_
26 26
27 #include "soap.h" 27 #include "soap.h"
28 28
29 /*#define MSN_TWN_SERVER "loginnet.passport.com"*/ 29 /* Index into ticket_tokens in nexus.c Keep updated! */
30 #define MSN_TWN_SERVER "login.live.com" 30 typedef enum
31 {
32 MSN_AUTH_MESSENGER = 0,
33 MSN_AUTH_MESSENGER_WEB = 1,
34 MSN_AUTH_CONTACTS = 2,
35 MSN_AUTH_LIVE_UNKNOWN = 3,
36 MSN_AUTH_SPACES = 4,
37 MSN_AUTH_LIVE_CONTACTS = 5,
38 MSN_AUTH_STORAGE = 6
39 } MsnAuthDomains;
31 40
32 #define TWN_START_TOKEN "<wsse:BinarySecurityToken Id=\"PPToken1\">" 41 #define MSN_SSO_SERVER "login.live.com"
33 #define TWN_END_TOKEN "</wsse:BinarySecurityToken>" 42 #define SSO_POST_URL "/RST.srf"
34 43
35 #define TWN_POST_URL "/RST.srf" 44 #define MSN_SSO_RST_TEMPLATE \
36 #define TWN_ENVELOP_TEMPLATE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"\ 45 "<wst:RequestSecurityToken Id=\"RST%d\">"\
37 "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\ 46 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
38 "<Header>"\ 47 "<wsp:AppliesTo>"\
39 "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">"\ 48 "<wsa:EndpointReference>"\
40 "<ps:HostingApp>{3:B}</ps:HostingApp>"\ 49 "<wsa:Address>%s</wsa:Address>"\
41 "<ps:BinaryVersion>4</ps:BinaryVersion>"\ 50 "</wsa:EndpointReference>"\
42 "<ps:UIVersion>1</ps:UIVersion>"\ 51 "</wsp:AppliesTo>"\
43 "<ps:Cookies></ps:Cookies>"\ 52 "<wsse:PolicyReference URI=\"%s\"></wsse:PolicyReference>"\
44 "<ps:RequestParams>AQAAAAIAAABsYwQAAAAzMDg0</ps:RequestParams>"\ 53 "</wst:RequestSecurityToken>"
45 "</ps:AuthInfo>"\ 54
46 "<wsse:Security>"\ 55 #define MSN_SSO_TEMPLATE "<?xml version='1.0' encoding='utf-8'?>"\
47 "<wsse:UsernameToken Id=\"user\">"\ 56 "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
48 "<wsse:Username>%s</wsse:Username>"\ 57 " xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
49 "<wsse:Password>%s</wsse:Password>"\ 58 " xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
50 "</wsse:UsernameToken>"\ 59 " xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
51 "</wsse:Security>"\ 60 " xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
52 "</Header>"\ 61 " xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
53 "<Body>"\ 62 " xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
54 "<ps:RequestMultipleSecurityTokens xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"RSTS\">"\ 63 " xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
55 "<wst:RequestSecurityToken Id=\"RST0\">"\ 64 "<Header>"\
56 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\ 65 "<ps:AuthInfo"\
57 "<wsp:AppliesTo>"\ 66 " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
58 "<wsa:EndpointReference>"\ 67 " Id=\"PPAuthInfo\">"\
68 "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
69 "<ps:BinaryVersion>4</ps:BinaryVersion>"\
70 "<ps:UIVersion>1</ps:UIVersion>"\
71 "<ps:Cookies></ps:Cookies>"\
72 "<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>"\
73 "</ps:AuthInfo>"\
74 "<wsse:Security>"\
75 "<wsse:UsernameToken Id=\"user\">"\
76 "<wsse:Username>%s</wsse:Username>"\
77 "<wsse:Password>%s</wsse:Password>"\
78 "</wsse:UsernameToken>"\
79 "</wsse:Security>"\
80 "</Header>"\
81 "<Body>"\
82 "<ps:RequestMultipleSecurityTokens"\
83 " xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
84 " Id=\"RSTS\">"\
85 "<wst:RequestSecurityToken Id=\"RST0\">"\
86 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
87 "<wsp:AppliesTo>"\
88 "<wsa:EndpointReference>"\
59 "<wsa:Address>http://Passport.NET/tb</wsa:Address>"\ 89 "<wsa:Address>http://Passport.NET/tb</wsa:Address>"\
60 "</wsa:EndpointReference>"\ 90 "</wsa:EndpointReference>"\
61 "</wsp:AppliesTo>"\ 91 "</wsp:AppliesTo>"\
62 "</wst:RequestSecurityToken>"\ 92 "</wst:RequestSecurityToken>"\
63 "<wst:RequestSecurityToken Id=\"RST1\">"\ 93 "%s" /* Other RSTn tokens */\
64 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\ 94 "</ps:RequestMultipleSecurityTokens>"\
65 "<wsp:AppliesTo>"\ 95 "</Body>"\
66 "<wsa:EndpointReference>"\ 96 "</Envelope>"
67 "<wsa:Address>messenger.msn.com</wsa:Address>"\
68 "</wsa:EndpointReference>"\
69 "</wsp:AppliesTo>"\
70 "<wsse:PolicyReference URI=\"?%s\">"\
71 "</wsse:PolicyReference>"\
72 "</wst:RequestSecurityToken>"\
73 "</ps:RequestMultipleSecurityTokens>"\
74 "</Body>"\
75 "</Envelope>"
76 97
77 #define TWN_LIVE_START_TOKEN "<wsse:BinarySecurityToken Id=\"PPToken1\">" 98 typedef struct _MsnUsrKey MsnUsrKey;
78 #define TWN_LIVE_END_TOKEN "</wsse:BinarySecurityToken>" 99 struct _MsnUsrKey
79 #define TWN_LIVE_ENVELOP_TEMPLATE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"\ 100 {
80 "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\ 101 int size; // 28. Does not count data
81 "<Header>"\ 102 int crypt_mode; // CRYPT_MODE_CBC (1)
82 "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">"\ 103 int cipher_type; // TripleDES (0x6603)
83 "<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\ 104 int hash_type; // SHA1 (0x8004)
84 "<ps:BinaryVersion>4</ps:BinaryVersion>"\ 105 int iv_len; // 8
85 "<ps:UIVersion>1</ps:UIVersion>"\ 106 int hash_len; // 20
86 "<ps:Cookies></ps:Cookies>"\ 107 int cipher_len; // 72
87 "<ps:RequestParams>AQAAAAIAAABsYwQAAAAyMDUy</ps:RequestParams>"\ 108 // Data
88 "</ps:AuthInfo>"\ 109 char iv[8];
89 "<wsse:Security>"\ 110 char hash[20];
90 "<wsse:UsernameToken Id=\"user\">"\ 111 char cipher[72];
91 "<wsse:Username>%s</wsse:Username>"\ 112 };
92 "<wsse:Password>%s</wsse:Password>"\ 113
93 "</wsse:UsernameToken>"\ 114 typedef struct _MsnTicketToken MsnTicketToken;
94 "</wsse:Security>"\ 115 struct _MsnTicketToken {
95 "</Header>"\ 116 GHashTable *token;
96 "<Body>"\ 117 char *secret;
97 "<ps:RequestMultipleSecurityTokens xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"RSTS\">"\ 118 time_t expiry;
98 "<wst:RequestSecurityToken Id=\"RST0\">"\ 119 };
99 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
100 "<wsp:AppliesTo>"\
101 "<wsa:EndpointReference>"\
102 "<wsa:Address>http://Passport.NET/tb</wsa:Address>"\
103 "</wsa:EndpointReference>"\
104 "</wsp:AppliesTo>"\
105 "</wst:RequestSecurityToken>"\
106 "<wst:RequestSecurityToken Id=\"RST1\">"\
107 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
108 "<wsp:AppliesTo>"\
109 "<wsa:EndpointReference>"\
110 "<wsa:Address>messenger.msn.com</wsa:Address>"\
111 "</wsa:EndpointReference>"\
112 "</wsp:AppliesTo>"\
113 "<wsse:PolicyReference URI=\"?%s\"></wsse:PolicyReference>"\
114 "</wst:RequestSecurityToken>"\
115 "<wst:RequestSecurityToken Id=\"RST2\">"\
116 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
117 "<wsp:AppliesTo>"\
118 "<wsa:EndpointReference>"\
119 "<wsa:Address>contacts.msn.com</wsa:Address>"\
120 "</wsa:EndpointReference>"\
121 "</wsp:AppliesTo>"\
122 "<wsse:PolicyReference URI=\"?%s\"></wsse:PolicyReference>"\
123 " </wst:RequestSecurityToken>"\
124 "<wst:RequestSecurityToken Id=\"RST3\">"\
125 "<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
126 "<wsp:AppliesTo>"\
127 "<wsa:EndpointReference>"\
128 "<wsa:Address>voice.messenger.msn.com</wsa:Address>"\
129 "</wsa:EndpointReference>"\
130 " </wsp:AppliesTo>"\
131 "<wsse:PolicyReference URI=\"?%s\"></wsse:PolicyReference>"\
132 "</wst:RequestSecurityToken>"\
133 "</ps:RequestMultipleSecurityTokens>"\
134 "</Body>"\
135 "</Envelope>"
136 120
137 typedef struct _MsnNexus MsnNexus; 121 typedef struct _MsnNexus MsnNexus;
138 122
139 struct _MsnNexus 123 struct _MsnNexus
140 { 124 {
141 MsnSession *session; 125 MsnSession *session;
142 char * challenge_data_str; 126 char *policy;
143 GHashTable *challenge_data; 127 char *nonce;
128
129 MsnTicketToken *tokens;
130 int token_len;
144 }; 131 };
145 132
146 void msn_nexus_connect(MsnNexus *nexus); 133 void msn_nexus_connect(MsnNexus *nexus);
147 MsnNexus *msn_nexus_new(MsnSession *session); 134 MsnNexus *msn_nexus_new(MsnSession *session);
148 void msn_nexus_destroy(MsnNexus *nexus); 135 void msn_nexus_destroy(MsnNexus *nexus);
136 GHashTable *msn_nexus_get_token(MsnNexus *session, MsnAuthDomains id);
137 char *msn_nexus_get_token_str(MsnNexus *session, MsnAuthDomains id);
149 138
150 #endif /* _MSN_NEXUS_H_ */ 139 #endif /* _MSN_NEXUS_H_ */
140