Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/nexus.h
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     1 /**
       
     2  * @file nexus.h MSN Nexus functions
       
     3  *
       
     4  * purple
       
     5  *
       
     6  * Purple is the legal property of its developers, whose names are too numerous
       
     7  * to list here.  Please refer to the COPYRIGHT file distributed with this
       
     8  * source distribution.
       
     9  *
       
    10  * This program is free software; you can redistribute it and/or modify
       
    11  * it under the terms of the GNU General Public License as published by
       
    12  * the Free Software Foundation; either version 2 of the License, or
       
    13  * (at your option) any later version.
       
    14  *
       
    15  * This program is distributed in the hope that it will be useful,
       
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    18  * GNU General Public License for more details.
       
    19  *
       
    20  * You should have received a copy of the GNU General Public License
       
    21  * along with this program; if not, write to the Free Software
       
    22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
       
    23  */
       
    24 #ifndef MSN_NEXUS_H
       
    25 #define MSN_NEXUS_H
       
    26 
       
    27 #include "internal.h"
       
    28 
       
    29 typedef struct _MsnNexus MsnNexus;
       
    30 typedef struct _MsnTicketToken MsnTicketToken;
       
    31 
       
    32 /* Index into ticket_tokens in nexus.c Keep updated! */
       
    33 typedef enum
       
    34 {
       
    35 	MSN_AUTH_MESSENGER     = 0,
       
    36 	MSN_AUTH_MESSENGER_WEB = 1,
       
    37 	MSN_AUTH_CONTACTS      = 2,
       
    38 	MSN_AUTH_LIVE_SECURE   = 3,
       
    39 	MSN_AUTH_STORAGE       = 4,
       
    40 	MSN_AUTH_WHATSNEW      = 5
       
    41 } MsnAuthDomains;
       
    42 
       
    43 #define MSN_SSO_SERVER	"login.live.com"
       
    44 #define SSO_POST_URL	"/RST.srf"
       
    45 
       
    46 #define MSN_SSO_RST_TEMPLATE \
       
    47 "<wst:RequestSecurityToken xmlns=\"http://schemas.xmlsoap.org/ws/2004/04/trust\" Id=\"RST%d\">"\
       
    48 	"<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
       
    49 	"<wsp:AppliesTo xmlns=\"http://schemas.xmlsoap.org/ws/2002/12/policy\">"\
       
    50 		"<wsa:EndpointReference xmlns=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">"\
       
    51 			"<wsa:Address>%s</wsa:Address>"\
       
    52 		"</wsa:EndpointReference>"\
       
    53 	"</wsp:AppliesTo>"\
       
    54 	"<wsse:PolicyReference xmlns=\"http://schemas.xmlsoap.org/ws/2003/06/secext\" URI=\"%s\"></wsse:PolicyReference>"\
       
    55 "</wst:RequestSecurityToken>"
       
    56 
       
    57 #define MSN_SSO_TEMPLATE "<?xml version='1.0' encoding='utf-8'?>"\
       
    58 "<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
       
    59 	" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
       
    60 	" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
       
    61 	" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
       
    62 	" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
       
    63 	" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
       
    64 	" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
       
    65 	" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
       
    66 	"<Header>"\
       
    67 		"<ps:AuthInfo"\
       
    68 			" xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
       
    69 			" Id=\"PPAuthInfo\">"\
       
    70 			"<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
       
    71 			"<ps:BinaryVersion>4</ps:BinaryVersion>"\
       
    72 			"<ps:UIVersion>1</ps:UIVersion>"\
       
    73 			"<ps:Cookies></ps:Cookies>"\
       
    74 			"<ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>"\
       
    75 		"</ps:AuthInfo>"\
       
    76 		"<wsse:Security>"\
       
    77 			"<wsse:UsernameToken Id=\"user\">"\
       
    78 				"<wsse:Username>%s</wsse:Username>"\
       
    79 				"<wsse:Password>%s</wsse:Password>"\
       
    80 			"</wsse:UsernameToken>"\
       
    81 		"</wsse:Security>"\
       
    82 	"</Header>"\
       
    83 	"<Body>"\
       
    84 		"<ps:RequestMultipleSecurityTokens"\
       
    85 			" xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\""\
       
    86 			" Id=\"RSTS\">"\
       
    87 			"<wst:RequestSecurityToken Id=\"RST0\">"\
       
    88 				"<wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>"\
       
    89 				"<wsp:AppliesTo>"\
       
    90 					"<wsa:EndpointReference>"\
       
    91 						"<wsa:Address>http://Passport.NET/tb</wsa:Address>"\
       
    92 					"</wsa:EndpointReference>"\
       
    93 				"</wsp:AppliesTo>"\
       
    94 			"</wst:RequestSecurityToken>"\
       
    95 			"%s"	/* Other RSTn tokens */\
       
    96 		"</ps:RequestMultipleSecurityTokens>"\
       
    97 	"</Body>"\
       
    98 "</Envelope>"
       
    99 
       
   100 #define MSN_SSO_AUTHINFO_TEMPLATE \
       
   101 "<ps:AuthInfo xmlns:ps=\"http://schemas.microsoft.com/Passport/SoapServices/PPCRL\" Id=\"PPAuthInfo\">"\
       
   102 	"<ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>"\
       
   103 	"<ps:BinaryVersion>4</ps:BinaryVersion>"\
       
   104 	"<ps:UIVersion>1</ps:UIVersion>"\
       
   105 	"<ps:Cookies></ps:Cookies>"\
       
   106 	"<ps:RequestParams>AQAAAAIAAABsYwQAAAA0MTA1</ps:RequestParams>"\
       
   107 "</ps:AuthInfo>"
       
   108 /* Not sure what's editable here, so I'll just hard-code the SHA1 hash */
       
   109 #define MSN_SSO_AUTHINFO_SHA1_BASE64 "d2IeTF4DAkPEa/tVETHznsivEpc="
       
   110 
       
   111 #define MSN_SSO_TIMESTAMP_TEMPLATE \
       
   112 "<wsu:Timestamp xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" Id=\"Timestamp\">"\
       
   113 	"<wsu:Created>%s</wsu:Created>"\
       
   114 	"<wsu:Expires>%s</wsu:Expires>"\
       
   115 "</wsu:Timestamp>"
       
   116 
       
   117 #define MSN_SSO_SIGNEDINFO_TEMPLATE \
       
   118 "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
       
   119 	"<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></CanonicalizationMethod>"\
       
   120 	"<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#hmac-sha1\"></SignatureMethod>"\
       
   121 	"<Reference URI=\"#RST%d\">"\
       
   122 		"<Transforms>"\
       
   123 			"<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
       
   124 		"</Transforms>"\
       
   125 		"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
       
   126 		"<DigestValue>%s</DigestValue>"\
       
   127 	"</Reference>"\
       
   128 	"<Reference URI=\"#Timestamp\">"\
       
   129 		"<Transforms>"\
       
   130 			"<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
       
   131 		"</Transforms>"\
       
   132 		"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
       
   133 		"<DigestValue>%s</DigestValue>"\
       
   134 	"</Reference>"\
       
   135 	"<Reference URI=\"#PPAuthInfo\">"\
       
   136 		"<Transforms>"\
       
   137 			"<Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform>"\
       
   138 		"</Transforms>"\
       
   139 		"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod>"\
       
   140 		"<DigestValue>" MSN_SSO_AUTHINFO_SHA1_BASE64 "</DigestValue>"\
       
   141 	"</Reference>"\
       
   142 "</SignedInfo>"
       
   143 
       
   144 #define MSN_SSO_TOKEN_UPDATE_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
       
   145 "<Envelope"\
       
   146 	" xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\""\
       
   147 	" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2003/06/secext\""\
       
   148 	" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\""\
       
   149 	" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2002/12/policy\""\
       
   150 	" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\""\
       
   151 	" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\""\
       
   152 	" xmlns:wssc=\"http://schemas.xmlsoap.org/ws/2004/04/sc\""\
       
   153 	" xmlns:wst=\"http://schemas.xmlsoap.org/ws/2004/04/trust\">"\
       
   154 	"<Header>"\
       
   155 		MSN_SSO_AUTHINFO_TEMPLATE /* ps:AuthInfo */ \
       
   156 		"<wsse:Security>"\
       
   157 			"<EncryptedData xmlns=\"http://www.w3.org/2001/04/xmlenc#\" Id=\"BinaryDAToken0\" Type=\"http://www.w3.org/2001/04/xmlenc#Element\">"\
       
   158 				"<EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#tripledes-cbc\"></EncryptionMethod>"\
       
   159 				"<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">"\
       
   160 					"<ds:KeyName>http://Passport.NET/STS</ds:KeyName>"\
       
   161 				"</ds:KeyInfo>"\
       
   162 				"<CipherData>"\
       
   163 					"<CipherValue>%s</CipherValue>"\
       
   164 				"</CipherData>"\
       
   165 			"</EncryptedData>"\
       
   166 			"<wssc:DerivedKeyToken Id=\"SignKey\">"\
       
   167 				"<wsse:RequestedTokenReference>"\
       
   168 					"<wsse:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID\" />"\
       
   169 					"<wsse:Reference URI=\"#BinaryDAToken0\" />"\
       
   170 				"</wsse:RequestedTokenReference>"\
       
   171 				"<wssc:Nonce>%s</wssc:Nonce>"\
       
   172 			"</wssc:DerivedKeyToken>"\
       
   173 			"%s" /* wsu:Timestamp */\
       
   174 			"<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"\
       
   175 				"%s" /* SignedInfo */\
       
   176 				"<SignatureValue>%s</SignatureValue>"\
       
   177 				"<KeyInfo>"\
       
   178 					"<wsse:SecurityTokenReference>"\
       
   179 						"<wsse:Reference URI=\"#SignKey\" />"\
       
   180 					"</wsse:SecurityTokenReference>"\
       
   181 				"</KeyInfo>"\
       
   182 			"</Signature>"\
       
   183 		"</wsse:Security>"\
       
   184 	"</Header>"\
       
   185 	"<Body>"\
       
   186 		"%s" /* wst:RequestSecurityToken */ \
       
   187 	"</Body>"\
       
   188 "</Envelope>"
       
   189 
       
   190 struct _MsnTicketToken {
       
   191 	GHashTable *token;
       
   192 	char *secret;
       
   193 	time_t expiry;
       
   194 	GSList *updates;
       
   195 };
       
   196 
       
   197 struct _MsnNexus
       
   198 {
       
   199 	MsnSession *session;
       
   200 
       
   201 	/* From server via USR command */
       
   202 	char *policy;
       
   203 	char *nonce;
       
   204 
       
   205 	/* From server via SOAP stuff */
       
   206 	char *cipher;
       
   207 	char *secret;
       
   208 	MsnTicketToken *tokens;
       
   209 	gsize token_len;
       
   210 };
       
   211 
       
   212 void msn_nexus_connect(MsnNexus *nexus);
       
   213 MsnNexus *msn_nexus_new(MsnSession *session);
       
   214 void msn_nexus_destroy(MsnNexus *nexus);
       
   215 GHashTable *msn_nexus_get_token(MsnNexus *nexus, MsnAuthDomains id);
       
   216 const char *msn_nexus_get_token_str(MsnNexus *nexus, MsnAuthDomains id);
       
   217 void msn_nexus_update_token(MsnNexus *nexus, int id, GSourceFunc cb, gpointer data);
       
   218 
       
   219 #endif /* MSN_NEXUS_H */