public UserAuthorizationResponse SaveSurvey(SurveyOne oSurveyOne) { LogEngine.Default.Log("[SaveSurvey Start =" + DateTime.Now + "]", null); string jsonResponse = string.Empty; UserAuthorizationResponse oUserLoginResponseDomain = new UserAuthorizationResponse(); oUserLoginResponseDomain.isUserAuthenticated = false; string exception = ""; try { LogEngine.Default.Log("[SaveSurvey Object =" + DateTime.Now + "]", oSurveyOne); oUserLoginResponseDomain.isUserAuthenticated = true; var deserializer = new JavaScriptSerializer(); oUserLoginResponseDomain = deserializer.Deserialize <UserAuthorizationResponse>(oUserLoginResponseDomain.isUserAuthenticated.ToString()); } catch (Exception ex) { oUserLoginResponseDomain.isUserAuthenticated = false; exception = ex.Message; LogEngine.Default.Log("[User_Number=" + "oUserLoginRequestDomain.userName" + "][Exception=" + exception + "], Exception", null); } return(oUserLoginResponseDomain); }
protected void AllowAccessButton_Click(object sender, EventArgs e) { if (UserContext.OAuthAuthorizationSecret != OAuthAuthorizationSecToken.Value) { throw new ArgumentException(Resources.OAuthControl_InvalidAuthorizationSecret); // Probably someone trying to hack in. } string token = ((ITokenContainingMessage)m_PendingRequest).Token; TokenProvider.Current.AuthorizeRequestToken(token); TokenProvider.SetTokenCookie(null); UserContext.OAuthAuthorizationSecret = null; // Clear one time use secret. MainMultiView.ActiveViewIndex = 1; using (ServiceProvider provider = new ServiceProvider()) { UserAuthorizationResponse response = provider.PrepareAuthorizationResponse(m_PendingRequest); if (response != null) { provider.Channel.Send(response); } else { if (m_PendingRequest.IsUnsafeRequest) { VerifierMultiView.ActiveViewIndex = 1; } else { VerificationCodeLiteral.Text = string.Format(CultureInfo.InvariantCulture, Resources.OAuthControl_VerificationCodeLiteral_Text, TokenProvider.Current.UpdateRequestTokenVerifier(token)); } } } }
public UserAuthorizationResponse AuthenticateUser(UserAuthorizationDomain oUserAuthorizationDomain) { UserAuthorizationResponse oUserAuthorizationResponse = UserManagementRepository.AuthenticateUser(oUserAuthorizationDomain); try { // Generate an Encrypted Token and Pass in Message, if OTP Successfully Validated // This new Token is passed for Security Purposes for APP, so that OTP Screen cannot be ByPassed if (oUserAuthorizationResponse.isUserAuthenticated) { oUserAuthorizationResponse.message = "User authenticated successfully."; } else { oUserAuthorizationResponse.message = "User name or password is incorrect."; } } catch (Exception ex) { oUserAuthorizationResponse.isUserAuthenticated = false; oUserAuthorizationResponse.message = "Error authenticating user : " + ex.Message; } return(oUserAuthorizationResponse); }
public UserAuthorizationResponse AuthenticateUser(UserAuthorizationDomain oUserAuthorizationDomain) { LogEngine.Default.Log("[AuthenticateUser Start =" + DateTime.Now + "]", null); string jsonResponse = string.Empty; UserAuthorizationResponse oUserAuthorizationResponse = new UserAuthorizationResponse(); oUserAuthorizationResponse.isUserAuthenticated = false; string exception = ""; try { /* * if (oUserAuthorizationDomain.userName.ToUpper() == "WAQAS") * oUserAuthorizationResponse.isUserAuthenticated = true; * else * oUserAuthorizationResponse.isUserAuthenticated = false; */ UserManagementApplication oUserManagementApplication = new UserManagementApplication(); oUserAuthorizationResponse = oUserManagementApplication.AuthenticateUser(oUserAuthorizationDomain); var deserializer = new JavaScriptSerializer(); oUserAuthorizationResponse = deserializer.Deserialize <UserAuthorizationResponse>(oUserAuthorizationResponse.isUserAuthenticated.ToString()); } catch (Exception ex) { oUserAuthorizationResponse.isUserAuthenticated = false; exception = ex.Message; LogEngine.Default.Log("[User_Number=" + oUserAuthorizationDomain.userName + "][Exception=" + exception + "], Exception", null); } return(oUserAuthorizationResponse); }
/// <summary> /// Analyzes an incoming request message payload to discover what kind of /// message is embedded in it and returns the type, or null if no match is found. /// </summary> /// <param name="recipient">The intended or actual recipient of the request message.</param> /// <param name="fields">The name/value pairs that make up the message payload.</param> /// <returns> /// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can /// deserialize to. Null if the request isn't recognized as a valid protocol message. /// </returns> /// <remarks> /// The request messages are: /// UserAuthorizationResponse /// </remarks> public virtual IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary <string, string> fields) { MessageBase message = null; if (fields.ContainsKey("oauth_token")) { Protocol protocol = fields.ContainsKey("oauth_verifier") ? Protocol.V10a : Protocol.V10; message = new UserAuthorizationResponse(recipient.Location, protocol.Version); } if (message != null) { message.SetAsIncoming(); } return(message); }
public UserAuthorizationResponse PrepareAuthorizationResponse(UserAuthorizationRequest request, Uri callback) { Requires.NotNull(request, "request"); Requires.NotNull(callback, "callback"); var authorization = new UserAuthorizationResponse(callback, request.Version) { RequestToken = request.RequestToken, }; if (authorization.Version >= Protocol.V10a.Version) { authorization.VerificationCode = CreateVerificationCode(VerificationCodeFormat.IncludedInCallback, VerifierCodeLength); } return(authorization); }
public UserAuthorizationResponse PrepareAuthorizationResponse(UserAuthorizationRequest request) { ErrorUtilities.VerifyArgumentNotNull(request, "request"); if (request.Callback != null) { var authorization = new UserAuthorizationResponse(request.Callback) { RequestToken = request.RequestToken, }; return(authorization); } else { return(null); } }
public UserAuthorizationResponse PrepareAuthorizationResponse(UserAuthorizationRequest request, Uri callback) { Contract.Requires <ArgumentNullException>(request != null); Contract.Requires <ArgumentNullException>(callback != null); var authorization = new UserAuthorizationResponse(callback, request.Version) { RequestToken = request.RequestToken, }; if (authorization.Version >= Protocol.V10a.Version) { authorization.VerificationCode = CreateVerificationCode(VerificationCodeFormat.IncludedInCallback, VerifierCodeLength); } return(authorization); }
/// <summary> /// Analyzes an incoming request message payload to discover what kind of /// message is embedded in it and returns the type, or null if no match is found. /// </summary> /// <param name="recipient">The intended or actual recipient of the request message.</param> /// <param name="fields">The name/value pairs that make up the message payload.</param> /// <returns> /// A newly instantiated <see cref="IProtocolMessage"/>-derived object that this message can /// deserialize to. Null if the request isn't recognized as a valid protocol message. /// </returns> /// <remarks> /// The request messages are: /// UserAuthorizationResponse /// </remarks> public virtual IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary <string, string> fields) { ErrorUtilities.VerifyArgumentNotNull(recipient, "recipient"); ErrorUtilities.VerifyArgumentNotNull(fields, "fields"); MessageBase message = null; if (fields.ContainsKey("oauth_token")) { message = new UserAuthorizationResponse(recipient.Location); } if (message != null) { message.SetAsIncoming(); } return(message); }
public static UserAuthorizationResponse AuthenticateUser(UserAuthorizationDomain oUserAuthorizationDomain) { MySqlCommand command = null; UserAuthorizationResponse oUserAuthorizationResponse = new UserAuthorizationResponse(); try { #region "Validate User" using (command = SurveyDB.GetStoredProcCommand("PRC_Authenticate_User")) { //command.CommandType = CommandType.StoredProcedure; MySqlParameter userNameParameter = new MySqlParameter(); userNameParameter.ParameterName = "pi_username"; userNameParameter.Value = oUserAuthorizationDomain.userName; userNameParameter.MySqlDbType = MySqlDbType.VarChar; userNameParameter.Size = 100; userNameParameter.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(userNameParameter); MySqlParameter passwordParameter = new MySqlParameter(); passwordParameter.ParameterName = "pi_password"; passwordParameter.Value = oUserAuthorizationDomain.userPassword; passwordParameter.MySqlDbType = MySqlDbType.VarChar; passwordParameter.Size = 100; passwordParameter.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(passwordParameter); MySqlParameter tokenParameter = new MySqlParameter(); tokenParameter.ParameterName = "pi_token"; tokenParameter.Value = oUserAuthorizationDomain.token; tokenParameter.MySqlDbType = MySqlDbType.VarChar; tokenParameter.Size = 100; tokenParameter.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(tokenParameter); MySqlParameter imeiParameter = new MySqlParameter(); imeiParameter.ParameterName = "pi_imei"; imeiParameter.Value = oUserAuthorizationDomain.imei; imeiParameter.MySqlDbType = MySqlDbType.VarChar; imeiParameter.Size = 30; imeiParameter.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(imeiParameter); MySqlParameter iccidParameter = new MySqlParameter(); iccidParameter.ParameterName = "pi_iccid"; iccidParameter.Value = oUserAuthorizationDomain.iccid; iccidParameter.MySqlDbType = MySqlDbType.VarChar; iccidParameter.Size = 30; iccidParameter.Direction = System.Data.ParameterDirection.Input; command.Parameters.Add(iccidParameter); MySqlParameter poMsgParameter = new MySqlParameter(); poMsgParameter.ParameterName = "po_msg"; poMsgParameter.MySqlDbType = MySqlDbType.VarChar; iccidParameter.Size = 10; poMsgParameter.Direction = System.Data.ParameterDirection.Output; command.Parameters.Add(poMsgParameter); SurveyDB.ExecuteNonQuery(command); if (command.Parameters["po_msg"].Value.ToString().ToLower() == "true") { oUserAuthorizationResponse.isUserAuthenticated = true; oUserAuthorizationResponse.token = Guid.NewGuid().ToString(); } else if (command.Parameters["po_result"].Value.ToString().ToLower() == "false") { oUserAuthorizationResponse.isUserAuthenticated = false; oUserAuthorizationResponse.token = ""; } else { oUserAuthorizationResponse.isUserAuthenticated = false; oUserAuthorizationResponse.token = ""; } } #endregion } catch (Exception ex) { oUserAuthorizationResponse.isUserAuthenticated = false; //entity.Message = ex.Message; } finally { DisposeCommand(command); } return(oUserAuthorizationResponse); }