private void AeriaGetBalanceResponse(IAsyncResult asr) { XmlRpcAsyncResult result = (XmlRpcAsyncResult)asr; AuthProxy clientProtocol = (AuthProxy)result.ClientProtocol; clientProtocol.Url = this.EndpointUri; try { XmlRpcRespStruct struct2 = clientProtocol.EndAeriaGetBalance(asr); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode); this.mResponse.Points = struct2.mPoints; } catch (Exception) { this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } try { if (this.FormsControl != null) { this.FormsControl.Invoke(new AuthEndResponseDelegate(this.CallbackMethod.Invoke), new object[] { this, this.Response }); } } catch (Exception exception) { string message = exception.Message; } }
// service authentication // challenge response protocol // check if service account exists // return challenge if exists public short StartServiceAuthentication(string serviceName) { IIdentity identity = Thread.CurrentPrincipal.Identity; WindowsIdentity windowsIdentity = identity as WindowsIdentity; string sessionId = OperationContext.Current.SessionId; Database.usersRequestsDB.Add(sessionId, new UserRequest()); Database.usersRequestsDB[sessionId].Username = Formatter.ParseName(windowsIdentity.Name); Database.usersRequestsDB[sessionId].RequestedService = serviceName; using (authProxy = new AuthProxy(new NetTcpBinding(), "net.tcp://localhost:10000/AuthService")) { try { Database.usersRequestsDB[sessionId].Challenge = authProxy.AuthenticateUser(Database.usersRequestsDB[sessionId].Username); return(Database.usersRequestsDB[sessionId].Challenge); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Message)); } } }
private void SetEmailOptInResponse(IAsyncResult asr) { XmlRpcAsyncResult result = (XmlRpcAsyncResult)asr; AuthProxy clientProtocol = (AuthProxy)result.ClientProtocol; clientProtocol.Url = this.EndpointUri; try { XmlRpcRespStruct struct2 = clientProtocol.EndsetEmailOptIn(asr); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens); } catch (Exception) { this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } try { if (this.FormsControl != null) { this.FormsControl.Invoke(new AuthEndResponseDelegate(this.CallbackMethod.Invoke), new object[] { this, this.Response }); } } catch (Exception exception) { string message = exception.Message; } }
private void GetWorldsResponse(IAsyncResult asr) { XmlRpcAsyncResult result = (XmlRpcAsyncResult)asr; AuthProxy clientProtocol = (AuthProxy)result.ClientProtocol; clientProtocol.Url = this.EndpointUri; try { XmlRpcRespStruct struct2 = clientProtocol.EndGetWorlds(asr); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens, struct2.mVeteranLv1, struct2.mVeteranLv2, struct2.mVeteranLv3, struct2.mVeteranLv4, struct2.mVeteranLv5, struct2.mVeteranLv6, struct2.mVeteranLv7, struct2.mVeteranLv8, struct2.mVeteranLv9, struct2.mVeteranLv10, struct2.mVeteranTotalSeconds, struct2.mVeteranSecondsLeft, struct2.mVeteranCurrentLevel, struct2.mPremiumBox, struct2.mRawShields, struct2.mRawWorlds, struct2.mRawProducts, struct2.mSpecialURL); } catch (Exception exception) { this.mResponse = new XmlRpcAuthResponse(exception.Message, 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } try { if (this.FormsControl != null) { this.FormsControl.Invoke(new AuthEndResponseDelegate(this.CallbackMethod.Invoke), new object[] { this, this.Response }); } } catch (Exception exception2) { string message = exception2.Message; } }
public void AeriaMakePayment(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl) { this.FormsControl = ctrl; this.CallbackMethod = callbackHandler; this.mRequest = (XmlRpcAuthRequest)req; AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>(); proxy.Url = this.EndpointUri; proxy.BeginAeriaMakePayment(this.mRequest.Request, new AsyncCallback(this.AeriaMakePaymentResponse), null); }
private void clientLoginResponse(IAsyncResult asr) { XmlRpcAsyncResult result = (XmlRpcAsyncResult)asr; AuthProxy clientProtocol = (AuthProxy)result.ClientProtocol; clientProtocol.Url = this.EndpointUri; try { int?mIsbigpoint = null; int?mUnviewedOffers = null; XmlRpcRespStruct struct2 = clientProtocol.EndclientLogin(asr); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens, struct2.mVeteranLv1, struct2.mVeteranLv2, struct2.mVeteranLv3, struct2.mVeteranLv4, struct2.mVeteranLv5, struct2.mVeteranLv6, struct2.mVeteranLv7, struct2.mVeteranLv8, struct2.mVeteranLv9, struct2.mVeteranLv10, struct2.mVeteranTotalSeconds, struct2.mVeteranSecondsLeft, struct2.mVeteranCurrentLevel, struct2.mPremiumBox, struct2.mRawShields, struct2.mRawWorlds, struct2.mRawProducts, struct2.mSpecialURL); if (struct2.mIsbigpoint.HasValue) { mIsbigpoint = struct2.mIsbigpoint; } this.mResponse.isBigPoint = (mIsbigpoint.GetValueOrDefault() == 1) && mIsbigpoint.HasValue; if (struct2.mUnviewedOffers.HasValue) { mUnviewedOffers = struct2.mUnviewedOffers; } this.mResponse.hasUnviewedOffers = (mUnviewedOffers.GetValueOrDefault() == 1) && mUnviewedOffers.HasValue; this.mResponse.OnVacation = struct2.mOnVacation; this.mResponse.FacebookFreePack = struct2.mFBFreePack; this.mResponse.VacationsTaken = struct2.mVacationsTaken; this.mResponse.CancelVacation = struct2.mCancelVacation; this.mResponse.VacationSecondsLeft = struct2.mVacationSecondsLeft; this.mResponse.VacationSecondsToCancel = struct2.mVacationSecondsToCancel; this.mResponse.VacationPossible = struct2.mVacationPossible; this.mResponse.RequiresOptInCheck = struct2.mRequiresOptInCheck; } catch (Exception exception) { this.mResponse = new XmlRpcAuthResponse(exception.Message, 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } try { if (this.FormsControl != null) { this.FormsControl.Invoke(new AuthEndResponseDelegate(this.CallbackMethod.Invoke), new object[] { this, this.Response }); } } catch (Exception exception2) { string message = exception2.Message; } }
private void Main_Load(object sender, EventArgs e) { try { IntegrationProxy.ReceiveOrderTracking(new IntegrationService.OrderTrackingRequest() { }); } catch (FaultException <IntegrationService.ValidationExceptionFault> ex) { } var AuthResult = AuthProxy.Authenticate(new AuthService.AuthenticateRequest() { Username = "******", Password = "******", IPAddress = "127.0.0.1" // IP Fixo, a necessidade. }); }
public XmlRpcAuthResponse AeriaMakePayment(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout) { try { this.FormsControl = ctrl; this.CallbackMethod = callbackHandler; this.mRequest = (XmlRpcAuthRequest)req; AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>(); proxy.Url = this.EndpointUri; proxy.Timeout = timeout; XmlRpcRespStruct struct2 = proxy.AeriaMakePayment(this.mRequest.Request); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, struct2.mRawProducts, null); } catch (Exception) { this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } return(this.mResponse); }
public XmlRpcAuthResponse RenameParish(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout) { try { this.FormsControl = ctrl; this.CallbackMethod = callbackHandler; this.mRequest = (XmlRpcAuthRequest)req; AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>(); proxy.Url = this.EndpointUri; proxy.Timeout = timeout; XmlRpcRespStruct struct2 = proxy.RenameParish(this.mRequest.Request); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode); } catch (Exception) { this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } return(this.mResponse); }
private void AuthenticateUserResponse(IAsyncResult asr) { XmlRpcAsyncResult result = (XmlRpcAsyncResult)asr; AuthProxy clientProtocol = (AuthProxy)result.ClientProtocol; clientProtocol.Url = this.EndpointUri; try { int?mIsbigpoint = null; int?mUnviewedOffers = null; XmlRpcRespStruct struct2 = clientProtocol.Endauthenticate(asr); this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens); if (struct2.mIsbigpoint.HasValue) { mIsbigpoint = struct2.mIsbigpoint; } this.mResponse.isBigPoint = (mIsbigpoint.GetValueOrDefault() == 1) && mIsbigpoint.HasValue; if (struct2.mUnviewedOffers.HasValue) { mUnviewedOffers = struct2.mUnviewedOffers; } this.mResponse.hasUnviewedOffers = (mUnviewedOffers.GetValueOrDefault() == 1) && mUnviewedOffers.HasValue; } catch (Exception) { this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null); } try { if (this.FormsControl != null) { this.FormsControl.Invoke(new AuthEndResponseDelegate(this.CallbackMethod.Invoke), new object[] { this, this.Response }); } } catch (Exception exception) { string message = exception.Message; } }
public int AeriaGetBalance(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout, ref XmlRpcAuthResponse response) { try { this.FormsControl = ctrl; this.CallbackMethod = callbackHandler; this.mRequest = (XmlRpcAuthRequest)req; AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>(); proxy.Url = this.EndpointUri; proxy.Timeout = timeout; XmlRpcRespStruct struct2 = proxy.AeriaGetBalance(this.mRequest.Request); int num = 0; num = struct2.mPoints.Value; this.mResponse = new XmlRpcAuthResponse(); this.mResponse.Products = struct2.mRawProducts; response = this.mResponse; return(num); } catch (Exception) { return(0); } }
// service sends an encrypted response // DC forwards it to AS for password validation // after confirmation, forward to TGS public bool SendResponseService(byte[] response) { string sessionId = OperationContext.Current.SessionId; UserRequest userRequest; if (!Database.usersRequestsDB.TryGetValue(sessionId, out userRequest)) { throw new FaultException <SecurityException>(new SecurityException("Domain Controller: Session failed.")); } bool authenticated = false; using (authProxy = new AuthProxy(new NetTcpBinding(), "net.tcp://localhost:10000/AuthService")) { try { authenticated = authProxy.CheckPassword(userRequest, response); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Message)); } } if (!authenticated) { throw new FaultException <SecurityException>(new SecurityException("Authentication Service error: Service failed to authenticate.")); } else { using (tgsProxy = new TGSProxy(new NetTcpBinding(), "net.tcp://localhost:10001/TGService")) { try { string serviceAddress = tgsProxy.GetServiceAddress(userRequest.RequestedService); Console.WriteLine($"Ticket Granting Service: Requested {userRequest.RequestedService} found. Address: {serviceAddress}."); if (tgsProxy.IsServiceOnline(userRequest.RequestedService)) { return(true); } tgsProxy.ActivateService(userRequest.RequestedService, userRequest.Username); Console.WriteLine($"Ticket Granting Service: {userRequest.RequestedService} activated by {userRequest.Username}."); Console.WriteLine($"Ticket Granting Service: Sending confirmation to {serviceAddress}..."); Console.WriteLine(); return(true); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); Console.WriteLine("----------------------------------------------------------------------------------"); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (CommunicationException ex) { Console.WriteLine(ex.Message); Console.WriteLine("----------------------------------------------------------------------------------"); throw new FaultException <SecurityException>(new SecurityException(ex.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("----------------------------------------------------------------------------------"); throw new Exception(ex.Message); } } } }
// SendResponse: gets the response and then compares it to the stored hash in the database public ClientSessionData SendResponse(byte[] response) { string sessionId = OperationContext.Current.SessionId; if (!Database.usersRequestsDB.ContainsKey(sessionId)) { throw new FaultException <SecurityException>(new SecurityException("Domain Controller: Session failed.")); } bool authenticated = false; using (authProxy = new AuthProxy(new NetTcpBinding(), "net.tcp://localhost:10000/AuthService")) { try { authenticated = authProxy.CheckPassword(Database.usersRequestsDB[sessionId], response); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Message)); } } string serviceAddress; // full address of the service string serviceUser; // username of the service account that started the requested service string serviceName = Database.usersRequestsDB[sessionId].RequestedService; //service name if (!authenticated) { throw new FaultException <SecurityException>(new SecurityException("Authentication Service error: User failed to authenticate.")); } else { using (tgsProxy = new TGSProxy(new NetTcpBinding(), "net.tcp://localhost:10001/TGService")) { try { serviceAddress = tgsProxy.GetServiceAddress(serviceName); Console.WriteLine($"Ticket Granting Service: Requested {serviceName} found. Address: {serviceAddress}."); serviceUser = tgsProxy.GetServiceUser(serviceName); Console.WriteLine($"Ticket Granting Service: {serviceName} started by {serviceUser}."); if (!tgsProxy.IsServiceOnline(serviceName)) { throw new FaultException <SecurityException>(new SecurityException($"Ticket Granting Service: {serviceName} is offline")); } Console.WriteLine($"Ticket Granting Service: {serviceAddress} is active."); Console.WriteLine("Ticket Granting Service: Generating session key ..."); key = tgsProxy.GenerateSessionKey(); // encrypting client session key byte[] pwHash = Database.usersDB[Database.usersRequestsDB[sessionId].Username]; Database.usersRequestsDB[sessionId].SessionKey = _3DESAlgorithm.Encrypt(key, pwHash); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(ex.Message); } } } bool keySent = false; EndpointAddress endpointAddressService = new EndpointAddress(new Uri(serviceAddress), EndpointIdentity.CreateUpnIdentity(serviceName)); // first try to send the session key to the service // save confirmation to keySent using (serviceProxy = new ServiceProxy(new NetTcpBinding(), endpointAddressService)) { try { Console.WriteLine("Domain controller: Sending session key to the service..."); // service name and service username would have to be equal //byte[] pwHash = Database.usersDB[Database.usersRequestsDB[sessionId].RequestedService]; // encrypting service session key with the password hash of the service // service name and service username do not need to be equal byte[] pwHash = Database.usersDB[serviceUser]; string user = Database.usersRequestsDB[sessionId].Username; keySent = serviceProxy.SendSessionKey(user, _3DESAlgorithm.Encrypt(key, pwHash)); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (CommunicationException ex) { Console.WriteLine(ex.Message); serviceProxy.Abort(); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(ex.Message); } } // session key successfully sent to the service // return session key to the client if (keySent) { Console.WriteLine("Domain controller: Sending session key and service address to the client..."); Console.WriteLine("----------------------------------------------------------------------------------"); return(new ClientSessionData(Database.usersRequestsDB[sessionId].SessionKey, serviceAddress)); } else { using (tgsProxy = new TGSProxy(new NetTcpBinding(), "net.tcp://localhost:10001/TGService")) { try { Console.WriteLine($"Domain controller: Deactivating {serviceName} service..."); tgsProxy.DeactivateService(serviceName); } catch (FaultException <SecurityException> ex) { Console.WriteLine(ex.Detail.Message); throw new FaultException <SecurityException>(new SecurityException(ex.Detail.Message)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(ex.Message); } } Console.WriteLine("----------------------------------------------------------------------------------"); } throw new FaultException <SecurityException>(new SecurityException("Domain controller: Service not active.")); }