home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- import logging
- log = logging.getLogger('msn.soap.services')
- import time
- import datetime
- import urlparse
- import uuid
- import util.network.soap as soap
- import MSNSecurityTokenService.SecurityTokenService_client as STS_Client
- import MSNSecurityTokenService.SecurityTokenService_types as STS_Types
- import msn.SOAP.xml.wsa as wsa
- import msn.SOAP.xml.wst as wst
- import msn.SOAP.xml.wsse as wsse
- import msn.SOAP.xml.wsu_oasis as wsu
- import msn.SOAP.xml.soapenv as soapenv
- import ZSI.schema as Schema
- import ZSI.wstools.Namespaces as NS
- import msn.SOAP.Namespaces as MSNS
-
- def strtime_highres(t = None):
- if t is None:
- t = time.time()
-
- return None(time.strftime + '%Y-%m-%dT%H:%M:%S.0000000' % '%+03d:%02d'(-divmod if time.daylight else time.timezone, 3600), time.gmtime(t))
-
-
- def strptime_highres(s):
- (tz_delim, direction) = None if '+' in s else ('-', -1)
- (tstamp, tz_str) = s.rsplit(tz_delim, 1)
- if 'T' in tz_str:
- tz_offset = 0
- else:
- tz_struct = time.strptime(tz_str, '%H:%M')
- tz_offset = 3600 * tz_struct.tm_hour + 60 * tz_struct.tm_min * direction
- s = tstamp
- if '.' in s:
- (s, micro) = s.split('.', 1)
-
- ts = time.strptime(s, '%Y-%m-%dT%H:%M:%S')
- if ts.tm_year < 1971:
- return 0
- return time.mktime(ts) + tz_offset
-
-
- class SsoDomains:
- Clear = 'messengerclear.live.com'
- STS = 'http://Passport.NET/tb'
- WhatsUp = 'sup.live.com'
- Messenger = 'messenger.msn.com'
- Storage = 'storage.msn.com'
- OfflineIM = 'messengersecure.live.com'
- Contacts = 'contacts.msn.com'
- Spaces = 'spaces.live.com'
-
-
- class AppIDs:
- STS = uuid.UUID('7108E71A-9926-4FCB-BCC9-9A9D3F32E423')
- WhatsUp = uuid.UUID('3B119D87-1D76-4474-91AD-0D7267E86D04')
- AddressBook = uuid.UUID('CFE80F9D-180F-4399-82AB-413F33A1FA11')
- Sharing = uuid.UUID('AAD9B99B-58E6-4F23-B975-D9EC1F9EC24A')
- Storage = 'Messenger Client 9.0'
- Spaces = 'Messenger Client 8.0'
-
-
- class PartnerScenario:
- NONE = 'None'
- Initial = 'Initial'
- Timer = 'Timer'
- BlockUnblock = 'BlockUnblock'
- GroupSave = 'GroupSave'
- GeneralDialogApply = 'GeneralDialogApply'
- ContactSave = 'ContactSave'
- ContactMsgrAPI = 'ContactMsgrAPI'
- MessengerPendingList = 'MessengerPendingList'
- PrivacyApply = 'PrivacyApply'
- NewCircleDuringPull = 'NewCircleDuringPull'
- CircleInvite = 'CircleInvite'
- CircleIdAlert = 'CircleIdAlert'
- CircleStatus = 'CircleStatus'
- CircleSave = 'CircleSave'
- CircleLeave = 'CircleLeave'
- JoinedCircleDuringPush = 'JoinedCircleDuringPush'
- ABChangeNotifyAlert = 'ABChangeNotifyAlert'
- RoamingSeed = 'RoamingSeed'
- RoamingIdentityChanged = 'RoamingIdentityChanged'
-
-
- class ClearService(object):
- SSO = True
- SSO_Domain = SsoDomains.Clear
- SSO_PolicyRef = None
-
-
- class CacheKeyService(object):
- CacheKeyName = None
-
- def __init__(self, *a, **k):
- self.SessionId = None
- self.PreferredHostName = None
-
-
- def add_cachekey(self, client, appheader):
- cachekey = client.get_cachekey(self.CacheKeyName)
- if cachekey is not None:
- appheader.CacheKey = cachekey
-
-
-
- def handleHeaders(self, client, headers):
- log.info('CacheKeyService got soapheaders: %r', headers)
- serviceHeader = headers.get((MSNS.MSWS.ADDRESS, 'ServiceHeader'), None)
- if serviceHeader is None:
- return None
- if serviceHeader.CacheKeyChanged:
- client.set_cachekey(self.CacheKeyName, str(serviceHeader.CacheKey))
-
- if not serviceHeader.SessionId:
- pass
- self.SessionId = self.SessionId
- if not serviceHeader.PreferredHostName:
- pass
- self.PreferredHostName = self.PreferredHostName
-
-
- def getPort(self, *a, **k):
- client = k.get('client')
- name = k.get('soapName')
- locator = k.get('locator')
- getPort = getattr(locator, 'get%sPort' % name, (lambda : pass))
- default_port = getPort()
- default_port_url = getattr(getattr(default_port, 'binding', None), 'url', None)
- if client.get_cachekey(self.CacheKeyName) is None:
- parsed = urlparse.urlparse(default_port_url)
- cachekeyurl = urlparse.urlunparse(('https', self.CacheKeyDomain) + parsed[2:])
- log.info('Changing endpoint of request from %r to %r for cachekey', default_port_url, cachekeyurl)
- return getPort(cachekeyurl)
- return default_port
-
-
-
- class SecurityTokenService(object):
- AppName = 'SecurityTokenService'
- AppId = AppIDs.STS
- Soap = STS_Client
- Locator = STS_Client.SecurityTokenServiceLocator
- SSO = True
- SSO_Domain = SsoDomains.STS
- SSO_PolicyRef = None
-
- def serviceurl_for_user(self, username):
- if username.endswith('msn.com'):
- return 'https://msnia.login.live.com/RST2.srf'
-
-
- def getCredProperty(self, key):
- return getattr(self, 'credProperties', { }).get(key, None)
-
-
- def handleHeaders(self, client, headers):
- self.credProperties = credprops = getattr(self, 'credProperties', { })
- pp = headers.get((MSNS.PPCRL.FAULT, 'pp'), None)
- if pp is not None:
- log.info('SecurityTokenService got pp header: %r', pp)
- for cp in pp.CredProperties.CredProperty:
- name = cp.get_attribute_Name()
- log.info('\tcredProperty: %s = %r', name, str(cp))
- credprops[name] = str(cp)
-
-
-
-
- def serviceHeaders(self, client, actionValue = 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue', toValue = 'HTTPS://login.live.com:443//RST2.srf', *a, **k):
- ai = STS_Types.ps.AuthInfo_Dec().pyclass()
- ai.set_attribute_Id('PPAuthInfo')
- ai.HostingApp = '{' + str(self.AppId).upper() + '}'
- ai.BinaryVersion = 5
- ai.Cookies = ''
- ai.UIVersion = 1
- ai.RequestParams = 'AQAAAAIAAABsYwQAAAAxMDMz'
- sec = wsse.Security()
- sec.UsernameToken = sec.new_UsernameToken()
- sec.UsernameToken.set_attribute_Id('user')
- sec.UsernameToken.Username = sec.UsernameToken.new_Username(client.get_username())
- password = client.get_password()
- sec.UsernameToken.Password = sec.UsernameToken.new_Password(password)
- now = datetime.datetime.utcnow().replace(microsecond = 0)
- ts = sec.Timestamp = sec.new_Timestamp()
- ts.set_attribute_Id('Timestamp')
- ts.Created = ts.new_Created(now.isoformat() + 'Z')
- ts.Expires = ts.new_Expires((now + datetime.timedelta(minutes = 60)).isoformat() + 'Z')
- messageid = wsa.MessageID(str(int(time.time())))
- mustunderstand_attrs = {
- (soapenv.wssoapenv.targetNamespace, 'mustUnderstand'): '1' }
-
- class Action('Action', ()):
- typecode = wsa.wsa.Action_Dec(mixed = True)
- _attrs = mustunderstand_attrs
- _text = actionValue
-
-
- class To('To', ()):
- typecode = wsa.wsa.To_Dec(mixed = True)
- _attrs = mustunderstand_attrs
- _text = toValue
-
- return (Action, To, messageid, ai, sec)
-
-
- def rst_for_service(self, msg, client, service, id):
- domain = service.SSO_Domain
- policyref = service.SSO_PolicyRef
- rtok = msg.new_RequestSecurityToken()
- rtok.set_attribute_Id(id)
- rtok.RequestType = NS.WSTRUST.ISSUE
- at = rtok.AppliesTo = rtok.new_AppliesTo()
- at.EndpointReference = at.new_EndpointReference()
- at.EndpointReference.Address = at.EndpointReference.new_Address(domain)
- if policyref is not None:
- rtok.PolicyReference = rtok.new_PolicyReference()
- rtok.PolicyReference.set_attribute_URI(policyref)
-
- return rtok
-
-
- def RequestSecurityToken(self, msg, client, actionValue = '', toValue = 'HTTPS://login.live.com:443//RST2.srf', service = None, *a, **k):
- if service is None:
- service = self
-
- msg.RequestSecurityToken = rst_for_service(msg, client, service, 'RST1')
-
- RequestSecurityToken = soap.soapcall(STS_Client)(RequestSecurityToken)
-
- def RequestMultipleSecurityTokens(self, msg, client, actionValue = 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue', toValue = 'HTTPS://login.live.com:443//RST2.srf', services = None, *a, **k):
- msg.set_attribute_Id('RSTS')
- tokens = []
- for i, service in enumerate(client.getSsoServices()):
- rtok = self.rst_for_service(msg, client, service, id = 'RST' + str(i))
- tokens.append(rtok)
- msg.RequestSecurityToken = tokens
-
- RequestMultipleSecurityTokens = soap.soapcall(STS_Client)(RequestMultipleSecurityTokens)
-
- import MSNABSharingService.SharingService_client as Sharing_Client
- import MSNABSharingService.SharingService_types as Sharing_Types
-
- class WhatsUpService(object):
- AppName = 'WhatsUpService'
- AppId = AppIDs.WhatsUp
- Soap = Sharing_Client
- Locator = Sharing_Client.WhatsUpServiceLocator
- SSO = True
- SSO_Domain = SsoDomains.WhatsUp
- SSO_PolicyRef = 'MBI'
-
- def serviceHeaders(self, client, *a, **k):
- app = Sharing_Types.WNApplicationHeader()
- app.ApplicationId = app.new_ApplicationId(str(self.AppId).upper())
- auth = Sharing_Types.WNAuthHeader()
- auth.TicketToken = client.get_ticket(self.AppId).token
- return (app, auth)
-
-
- def GetContactsRecentActivity(self, msg, client, cid, count = 10, locales = [
- 'en-US']):
- msg.EntityHandle = msg.new_entityHandle()
- msg.EntityHandle.Cid = cid
- msg.Locales = msg.new_locales()
- msg.Locales.String.extend(locales)
- msg.Count = count
- return True
-
- GetContactsRecentActivity = soap.soapcall(Sharing_Client)(GetContactsRecentActivity)
-
-
- class SharingServiceBase(CacheKeyService):
- CacheKeyName = 'omega'
- CacheKeyDomain = 'byrdr.omega.contacts.msn.com'
-
- def handleHeaders(self, client, headers):
- log.info('SharingService got soapheaders: %r', headers)
- super(SharingServiceBase, self).handleHeaders(client = client, headers = headers)
- self._recv_headers = headers
-
-
- def serviceHeaders(self, client, *a, **k):
- ticket = client.get_ticket(SsoDomains.Contacts)
- app = Schema.GED(MSNS.MSWS.ADDRESS, 'ABApplicationHeader').pyclass()
- app.ApplicationId = app.new_ApplicationId(str(AppIDs.Sharing).upper())
- app.IsMigration = False
- app.PartnerScenario = getattr(PartnerScenario, k.get('PartnerScenario', 'Initial'), 'Initial')
- app.BrandId = getattr(ticket, 'BrandId', 'MSFT')
- self.add_cachekey(client, app)
- auth = Schema.GED(MSNS.MSWS.ADDRESS, 'ABAuthHeader').pyclass()
- auth.TicketToken = ticket.token
- auth.ManagedGroupRequest = False
- return (app, auth)
-
-
-
- class SharingService(SharingServiceBase):
- AppName = 'SharingService'
- AppId = AppIDs.Sharing
- Soap = Sharing_Client
- Locator = Sharing_Client.SharingServiceLocator
- SSO = True
- SSO_Domain = SsoDomains.Contacts
- SSO_PolicyRef = 'MBI'
-
- def FindMembership(self, msg, client, view = 'Full', deltasOnly = False, lastChange = 0, **k):
- msg.View = view
- msg.DeltasOnly = deltasOnly
- msg.LastChange = lastChange
- msg.ServiceFilter = msg.new_serviceFilter()
- msg.ServiceFilter.Types = msg.ServiceFilter.new_Types()
- msg.ServiceFilter.Types.ServiceType.append('Messenger')
-
- FindMembership = soap.soapcall()(FindMembership)
-
- def AddMember(self, msg, client, *a, **k):
- raise NotImplementedError
-
- AddMember = soap.soapcall()(AddMember)
-
- def DeleteMember(self, msg, client, *a, **k):
- raise NotImplementedError
-
- DeleteMember = soap.soapcall()(DeleteMember)
-
- def CreateCircle(self, msg, client, *a, **k):
- raise NotImplementedError
-
- CreateCircle = soap.soapcall()(CreateCircle)
-
-
- class ABService(SharingServiceBase):
- AppName = 'ABService'
- AppId = AppIDs.AddressBook
- Soap = Sharing_Client
- Locator = Sharing_Client.ABServiceLocator
- abId = uuid.UUID(int = 0)
- SSO = True
- SSO_Domain = SsoDomains.Contacts
- SSO_PolicyRef = 'MBI'
-
- def ABFindAll(self, msg, client, view = 'Full', deltas = False, lastChange = 0, **k):
- msg.set_element_abId(msg.new_abId(str(self.abId)))
- msg.AbView = view
- msg.DeltasOnly = deltas
- msg.LastChange = lastChange
-
- ABFindAll = soap.soapcall()(ABFindAll)
-
- def ABFindContactsPaged(self, msg, client, view = 'Full', deltas = False, lastChange = 0, **k):
- msg.set_element_abView('MessengerClient8')
- msg.set_element_extendedContent('AB AllGroups CircleResult')
- fo = msg.new_filterOptions()
- msg.set_element_filterOptions(fo)
- fo.set_element_ContactFilter(fo.new_ContactFilter())
- fo.DeltasOnly = deltas
- fo.LastChanged = lastChange
- fo.ContactFilter.IncludeHiddenContacts = True
-
- ABFindContactsPaged = soap.soapcall()(ABFindContactsPaged)
-
- def ABContactAdd(self, msg, client, **k):
- raise NotImplementedError
-
- ABContactAdd = soap.soapcall()(ABContactAdd)
-
- def ABContactDelete(self, msg, client, **k):
- raise NotImplementedError
-
- ABContactDelete = soap.soapcall()(ABContactDelete)
-
- def ABGroupAdd(self, msg, client, **k):
- raise NotImplementedError
-
- ABGroupAdd = soap.soapcall()(ABGroupAdd)
-
- def ABGroupDelete(self, msg, client, **k):
- raise NotImplementedError
-
- ABGroupDelete = soap.soapcall()(ABGroupDelete)
-
- def ABGroupContactDelete(self, msg, client, **k):
- raise NotImplementedError
-
- ABGroupContactDelete = soap.soapcall()(ABGroupContactDelete)
-
- def ABContactUpdate(self, msg, client, **k):
- raise NotImplementedError
-
- ABContactUpdate = soap.soapcall()(ABContactUpdate)
-
- def ABAdd(self, msg, client, **k):
- raise NotImplementedError
-
- ABAdd = soap.soapcall()(ABAdd)
-
- def UpdateDynamicItem(self, msg, client, **k):
- raise NotImplementedError
-
- UpdateDynamicItem = soap.soapcall()(UpdateDynamicItem)
-
- def CreateContact(self, msg, client, **k):
- raise NotImplementedError
-
- CreateContact = soap.soapcall()(CreateContact)
-
- def ManageWLConnection(self, msg, client, **k):
- raise NotImplementedError
-
- ManageWLConnection = soap.soapcall()(ManageWLConnection)
-
- def BreakConnection(self, msg, client, **k):
- raise NotImplementedError
-
- BreakConnection = soap.soapcall()(BreakConnection)
-
- def AddDynamicItem(self, msg, client, **k):
- raise NotImplementedError
-
- AddDynamicItem = soap.soapcall()(AddDynamicItem)
-
- import MSNStorageService.StorageService_client as Storage_Client
- import MSNStorageService.StorageService_types as Storage_Types
-
- class StorageService(CacheKeyService):
- CacheKeyName = 'storage'
- CacheKeyDomain = 'tkrdr.storage.msn.com'
- SSO = True
- SSO_PolicyRef = 'MBI'
- SSO_Domain = SsoDomains.Storage
- AppName = 'StorageService'
- AppId = AppIDs.Storage
- Soap = Storage_Client
- Locator = Storage_Client.StorageServiceLocator
-
- def serviceHeaders(self, client, scenario = 'Initial', **k):
- App = Schema.GED(MSNS.MSWS.STORAGE, 'StorageApplicationHeader').pyclass()
- User = Schema.GED(MSNS.MSWS.STORAGE, 'StorageUserHeader').pyclass()
- Affinity = Schema.GED(MSNS.MSWS.STORAGE, 'AffinityCacheHeader').pyclass()
- App.ApplicationID = self.AppId
- App.Scenario = scenario
- User.Puid = 0
- User.TicketToken = client.get_ticket(self.SSO_Domain).token
- self.add_cachekey(client, Affinity)
- return (App, User, Affinity)
-
-
- def FindDocuments(self, msg, client, **k):
- raise NotImplementedError
-
- FindDocuments = soap.soapcall()(FindDocuments)
-
- def CreateProfile(self, msg, client, **k):
- raise NotImplementedError
-
- CreateProfile = soap.soapcall()(CreateProfile)
-
- def GetProfile(self, msg, client, scenario, **k):
- ph = msg.ProfileHandle = msg.new_profileHandle()
- alias = ph.Alias = ph.new_Alias()
- alias.NameSpace = 'MyCidStuff'
- alias.Name = str(client.contact_list.owner.CID)
- ph.RelationshipName = 'MyProfile'
- pa = msg.ProfileAttributes = msg.new_profileAttributes()
- pa.ResourceID = True
- pa.DateModified = True
- expattr = pa.ExpressionProfileAttributes = pa.new_ExpressionProfileAttributes()
- for attr in ('DateModified', 'DateModifiedSpecified', 'DisplayName', 'DisplayNameLastModified', 'DisplayNameLastModifiedSpecified', 'DisplayNameSpecified', 'Flag', 'FlagSpecified', 'PersonalStatus', 'PersonalStatusLastModified', 'PersonalStatusLastModifiedSpecified', 'PersonalStatusSpecified', 'Photo', 'PhotoSpecified', 'Attachments', 'AttachmentsSpecified', 'ResourceID', 'ResourceIDSpecified', 'StaticUserTilePublicURL', 'StaticUserTilePublicURLSpecified'):
- setattr(expattr, attr, True)
-
-
- GetProfile = soap.soapcall()(GetProfile)
-
- def CreateRelationships(self, msg, client, **k):
- raise NotImplementedError
-
- CreateRelationships = soap.soapcall()(CreateRelationships)
-
- def UpdateProfile(self, msg, client, **k):
- raise NotImplementedError
-
- UpdateProfile = soap.soapcall()(UpdateProfile)
-
- def ShareItem(self, msg, client, **k):
- raise NotImplementedError
-
- ShareItem = soap.soapcall()(ShareItem)
-
- def UpdateDocument(self, msg, client, **k):
- raise NotImplementedError
-
- UpdateDocument = soap.soapcall()(UpdateDocument)
-
- def CreateDocument(self, msg, client, **k):
- raise NotImplementedError
-
- CreateDocument = soap.soapcall()(CreateDocument)
-
- def DeleteRelationships(self, msg, client, **k):
- raise NotImplementedError
-
- DeleteRelationships = soap.soapcall()(DeleteRelationships)
-
- import MSNSpaceService.SpaceService_client as Spaces_Client
- import MSNSpaceService.SpaceService_types as Spaces_Types
-
- class SpacesService(object):
- AppName = 'SpaceService'
- SSO = True
- SSO_PolicyRef = 'MBI'
- SSO_Domain = SsoDomains.Spaces
- AppId = AppIDs.Spaces
- Soap = Spaces_Client
- Locator = Spaces_Client.SpaceServiceLocator
-
- def serviceHeaders(self, client, *a, **k):
- ticket = client.get_ticket(SsoDomains.Contacts)
- auth = Schema.GED(MSNS.MSWS.SPACES, 'AuthTokenHeader').pyclass()
- auth.Token = ticket.token
- return (auth,)
-
-
- def GetXmlFeed(self, msg, client, CID, **k):
- ri = msg.RefreshInformation = msg.new_refreshInformation()
- ri.Cid = CID
- ri.StorageAuthCache = ''
- ri.Market = 'en-US'
- ri.Brand = ''
- ri.MaxElementCount = 15
- ri.MaxCharacterCount = 200
- ri.MaxImageCount = 6
- ri.ApplicationId = 'Messenger Client 8.0'
- ri.UpdateAccessedTime = False
- import datetime
- yesterday = time.mktime((datetime.datetime.today() - datetime.timedelta(1)).timetuple())
- ri.SpaceLastViewed = yesterday
- ri.ProfileLastViewed = yesterday
- ri.ContactProfileLastViewed = yesterday
- ri.IsActiveContact = False
-
- GetXmlFeed = soap.soapcall()(GetXmlFeed)
-
-