private static void SetAuthorizationEndpoint(LiveIdEnvironment environment) { if (string.IsNullOrEmpty(_authorizationEndpoint)) { _authorizationEndpoint = GetServiceEndpoint(environment); } }
public static string RetrieveTicket(string devicename, string devicepassword, string partner, string username, string password, string policy, LiveIdEnvironment environment, string ticketPath) { if (ticketPath != "") { deviceTokenResponseFilePath = ticketPath + @"\DeviceTokenResponse.xml"; securityTokenResponseFilePath = ticketPath + @"\UserTokenResponse.xml"; } else { deviceTokenResponseFilePath = "DeviceTokenResponse.xml"; securityTokenResponseFilePath = "UserTokenResponse.xml"; } _environment = environment; SetAuthorizationEndpoint(_environment); Guid clientId = Guid.NewGuid(); string token = string.Empty; string str2 = string.Empty; if (TokenExist(securityTokenResponseFilePath, out str2)) { return(str2); } if (!TokenExist(deviceTokenResponseFilePath, out token)) { XmlNodeList list = RegisterMachine(devicename, devicepassword, clientId); token = IssueDeviceToken(devicename, devicepassword); } return(Issue(username, password, partner, policy, clientId, token)); }
private static void SetAuthorizationEndpoint(LiveIdEnvironment environment) { if (String.IsNullOrEmpty(_authorizationEndpoint)) { _authorizationEndpoint = GetServiceEndpoint(environment); return; } //Throw an exception if we can't get the endpoint. }
private static string GetServiceEndpoint(LiveIdEnvironment environment) { XmlDocument document = CallLiveIdServices(federationMetadataUrl[(int)environment], "GET", null); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(document.NameTable); namespaceManager.AddNamespace("fed", "http://schemas.xmlsoap.org/ws/2006/03/federation"); namespaceManager.AddNamespace("wsa", "http://www.w3.org/2005/08/addressing"); return(SelectNode(document, namespaceManager, "//fed:FederationMetadata/fed:Federation/fed:TargetServiceEndpoint/wsa:Address").InnerText.Trim()); }
/// <summary> /// This shows the method to retrieve the WLID ticket for the WLID user /// without using any certificate for authentication. /// </summary> /// <param name="devicename">The random device name to use for this registration. /// Lowercase 12 to 14 ANSI characters. Recommended length is 12 characters.</param> /// <param name="devicepassword">The random device password to use for this registration. /// Characters from the following set. /// <para>"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567891@#$%^*()-_=+;: ,./?`~"</para> /// Between 16 and 24 characters.</param> /// <param name="partner">sitename, i.e. crmapp.www.local-titan.com</param> /// <param name="username">The Windows Live ID for the user.</param> /// <param name="password">The Windows Live ID password for the user.</param> /// <param name="policy">Auth policy, i.e. MBI_SSL</param> /// <param name="environment">Live Id environment i.e. INT/PROD</param> /// <param name="savedTicketPath">The local disc path for saving ticket info.</param> /// <returns></returns> public static String RetrieveTicket(String devicename, String devicepassword, String partner, String username, String password, String policy, LiveIdEnvironment environment, String ticketPath) { if (ticketPath != "") { deviceTokenResponseFilePath = ticketPath + "\\" + deviceTokenResponseFileName; securityTokenResponseFilePath = ticketPath + "\\" + securityTokenResponseFileName; } else { deviceTokenResponseFilePath = deviceTokenResponseFileName; securityTokenResponseFilePath = securityTokenResponseFileName; } _environment = environment; SetAuthorizationEndpoint(_environment); Guid clientId = Guid.NewGuid(); String deviceToken = string.Empty; String ticket = string.Empty; // Check and also retrieve if valid security token already exist // in the SecurityTokenResponse.xml file created during latest run. if (!TokenExist(securityTokenResponseFilePath, out ticket)) { // Check and also retrieve if valid device token already exist // in the DeviceTokenResponse.xml file created during latest run. if (!TokenExist(deviceTokenResponseFilePath, out deviceToken)) { // Do the following once per machine. // Register each machine in the production // environment that you need to authenticate with. XmlNodeList responseNodes = RegisterMachine(devicename, devicepassword, clientId); // Now, authenticate the device. // Once you receive the device token, // you can save it and don't need to auth again until it expires. deviceToken = IssueDeviceToken(devicename, devicepassword); } //Finally, request the ticket itself. ticket = Issue(username, password, partner, policy, clientId, deviceToken); } return(ticket); }
/// <summary> /// This shows the method to retrieve the WLID ticket for the WLID user /// without using any certificate for authentication. /// </summary> /// <param name="devicename">The random device name to use for this registration. /// Lowercase 12 to 14 ANSI characters. Recommended length is 12 characters.</param> /// <param name="devicepassword">The random device password to use for this registration. /// Between 16 to 24 characters allowed from set. /// <para>"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567891@#$%^*()-_=+;: ,./?`~"</para> /// </param> /// <param name="partner">sitename, i.e. crmapp.www.local-titan.com</param> /// <param name="username">The Windows Live ID for the user</param> /// <param name="password">The Windows Live ID password for the user</param> /// <param name="policy">Auth policy, i.e. MBI_SSL</param> /// <param name="environment">Live Id environment i.e. INT/PROD</param> /// <returns></returns> public static String RetrieveTicket(String devicename, String devicepassword, String partner, String username, String password, String policy, LiveIdEnvironment environment) { return(RetrieveTicket(devicename, devicepassword, partner, username, password, policy, environment, "")); }