/// <summary> /// UseCheckBxCookie 関数 /// </summary> /// <param name="UCheckFlg">保持フラグ</param> /// <param name="userid">ユーザーID</param> public static void UseCheckBxCookie(bool UCheckFlg, string userid) { PCSiteTraceSource.MethodStart(); // ユーザーIDの保持チェックボックスをCookieに反映 HttpCookie kie; PCSiteTraceSource.CheckPoint("UCheckFlg", UCheckFlg.ToString()); try { if (UCheckFlg) { // チェックフラグ kie = new HttpCookie("ckUSEFLG"); kie.Value = "true"; kie.Expires = DateTime.Now.Add(new System.TimeSpan(365, 0, 0, 0)); HttpContext.Current.Response.Cookies.Add(kie); PCSiteTraceSource.CheckPoint("CookiesAdd", "ckUSEFLG"); // ユーザーID kie = new HttpCookie("ckTCONNECTID"); kie.Value = userid; kie.Expires = DateTime.Now.Add(new System.TimeSpan(365, 0, 0, 0)); HttpContext.Current.Response.Cookies.Add(kie); PCSiteTraceSource.CheckPoint("CookiesAdd", "ckTCONNECTID"); } else { kie = new HttpCookie("ckUSEFLG"); kie.Value = ""; kie.Expires = DateTime.Now.Add(new System.TimeSpan(-1, 0, 0, 0)); HttpContext.Current.Response.Cookies.Add(kie); PCSiteTraceSource.CheckPoint("CookiesRemove", "ckUSEFLG"); } } catch (Exception ex) { PCSiteTraceSource.MethodFailure(ex.Message); } PCSiteTraceSource.MethodSuccess(); }
/// <summary> /// GetRoles 関数 /// </summary> /// <returns> /// <dl> /// <dt>ロール文字</dt> /// <dd>戻り値 車載機モデルのロール文字列 /// </dd> /// </dl> /// </returns> private static string GetRoles() { PCSiteTraceSource.MethodStart(); string ret = ""; try { var dataset = HttpContext.Current.Session["Toyota.Gbook.WebSite.UserDataSet"] as Toyota.Gbook.WebSite.Security.DataTransferObject.ResultCDAuthenticationUserDataSet; if (dataset != null) { if (dataset.CarInformation.First().IsTConnectNavi&& HttpContext.Current.Session["Toyota.Gbook.WebSite.IsTerminatedUser"] != null) { if ((bool)HttpContext.Current.Session["Toyota.Gbook.WebSite.IsTerminatedUser"]) { ret = Constants.ROLE.ROLE_TCONNECT_EXIT; return(ret); } else { ret = Constants.ROLE.ROLE_TCONNECT; return(ret); } } } } catch (Exception ex) { PCSiteTraceSource.MethodFailure(ex.Message); } PCSiteTraceSource.CheckPoint("return", ret); PCSiteTraceSource.MethodSuccess(); return(ret); }
/// <summary> /// TicketCookieCreate 関数 /// </summary> public static void TicketCookieCreate() { PCSiteTraceSource.MethodStart(); // 認証チケットの発行 try { // ユーザーのロール文字設定 string roles = GetRoles(); PCSiteTraceSource.CheckPoint("roles", roles); // チケット作成 FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, HttpContext.Current.Session[Constants.PCSiteNameSpace + ".InternalMemberId"].ToString(), DateTime.Now, DateTime.Now.AddMinutes(Convert.ToDouble(Config.Item[Constants.PCSiteNameSpace + ".FormsAuthentication.TicketTime"].ToString())), false, roles); // チケットのCookie暗号化 string encryptedTicket = FormsAuthentication.Encrypt(authTicket); PCSiteTraceSource.CheckPoint("encryptedTicket", encryptedTicket); // チケットのCookie生成 HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); authCookie.Path = FormsAuthentication.FormsCookiePath; HttpContext.Current.Response.Cookies.Add(authCookie); PCSiteTraceSource.CheckPoint("CookiesAdd", FormsAuthentication.FormsCookieName, encryptedTicket, FormsAuthentication.FormsCookiePath); } catch (Exception ex) { PCSiteTraceSource.MethodFailure(ex.Message); } PCSiteTraceSource.MethodSuccess(); }
/// <summary> /// CheckAuthenticationTicket 関数 /// </summary> /// <returns> /// <dl> /// <dt>チケット在りケース</dt> /// <dd>戻り値 暗号解除したFormsAuthenticationTicket /// Cookieから認証チケット名の値を取り出し、暗号解除を行う。 /// </dd> /// /// <dt>チケット無しケース</dt> /// <dd>戻り値 null</dd> /// </dl> /// </returns> public static FormsAuthenticationTicket CheckAuthenticationTicket() { PCSiteTraceSource.MethodStart(); HttpCookie AuthenticationCookie = null; FormsAuthenticationTicket ret = null; // 認証チケット名のCookieを調べる try { AuthenticationCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; } catch (Exception ex) { AuthenticationCookie = null; PCSiteTraceSource.MethodFailure(ex.Message); } if (AuthenticationCookie != null) { // Cookie値を復号化 try { ret = FormsAuthentication.Decrypt(AuthenticationCookie.Value); } catch (Exception ex) { // 不正チケット ret = null; PCSiteTraceSource.MethodFailure(ex.Message); } } PCSiteTraceSource.MethodSuccess(); return(ret); }
// POST: api/ResetPassword public async Task <object> Post(HttpRequestMessage requestMessage, [FromBody] JObject request) { var messageId = requestMessage.GetCorrelationId().ToString(); TraceSources.AddAdditionalLogItem("RequestMessageId", messageId); var emailAddress = ""; try { var personReq = GetRequestJsosn_PersonForRemindPass(request.ToString()); var companyReq = GetRequestJson_CompanyForRemindPass(request.ToString()); var person = personReq.person; var company = companyReq.company; if (person != null) { if (person.member_id == null || person.birthday == null || person.email == null) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "必須要素が存在しない", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } var memberId = person.member_id; var strBirth = person.birthday; emailAddress = person.email; if (memberId.Equals(string.Empty) || memberId.Length > 256) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "会員ID", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } //入力チェック if (emailAddress.Equals(string.Empty) || emailAddress.Length > 256) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "メールアドレス", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } try { DateTime.ParseExact(strBirth, "yyyyMMdd", null); } catch (Exception) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "誕生日", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } //個人の場合I003000213 会員ログイン情報取得を呼びだす var reminder = new Toyota.Gbook.WebSite.Authentication.Control.Reminder(); //パスワード変更の場合はT-ConnectIdを指定しているため取得できうる内部会員IDは常に1件のみ。 var memberInfoList = reminder.CheckPersonalMemberExist(memberId, strBirth, emailAddress)[0]; var token = StoreVerificationData(emailAddress, memberInfoList.InternalMemberId, ReminderConstants.IsPersonalMember); await MailSend(new MailAddress(emailAddress), token); return(requestMessage.CreateResponse(HttpStatusCode.Accepted, new SuccessResponse_MessageId { message_id = messageId })); } else if (company != null) { if (company.member_id == null || company.frame_no == null || company.email == null) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "必須要素が存在しない", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } var memberId = company.member_id; emailAddress = company.email; var vin = company.frame_no; if (memberId.Equals(string.Empty) || memberId.Length > 256) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "会員ID", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } if (emailAddress.Equals(string.Empty) || emailAddress.Length > 256) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "メールアドレス", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } if (vin.Equals(string.Empty) || vin.Length > 20) { PCSiteTraceSource.InvalidRequest_Api("api/reset-password", "VIN", null); return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } //法人の場合00901:テレマサービス汎用操作API.テレマサービス契約情報取得を呼びだす var reminder = new Toyota.Gbook.WebSite.Authentication.Control.Reminder(); var memberInfo = reminder.CheckCompanyMemberExist(memberId, emailAddress, vin); var token = StoreVerificationData(emailAddress, memberInfo.InternalMemberId, ReminderConstants.IsCompanyMember); await MailSend(new MailAddress(emailAddress), token); return(requestMessage.CreateResponse(HttpStatusCode.Accepted, new SuccessResponse_MessageId { message_id = messageId })); } return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } catch (InvalidJsonException) { return(requestMessage.CreateResponse(HttpStatusCode.BadRequest)); } catch (UserNotFoundException) { var encoding = Encoding.GetEncoding("UTF-8"); var emailBytes = encoding.GetBytes(emailAddress); var emailBase64 = System.Convert.ToBase64String(emailBytes); var ex = PCSiteTraceSource.UserNotFound_Api(emailBase64); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.Unauthorized, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (UnexpectedMemberDivisionException) { var encoding = Encoding.GetEncoding("UTF-8"); var emailBytes = encoding.GetBytes(emailAddress); var emailBase64 = System.Convert.ToBase64String(emailBytes); var ex = PCSiteTraceSource.UnexpectedMemberDivision_Api(emailBase64); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.Unauthorized, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (MissingFileOnBlobException mex) { var ex = PCSiteTraceSource.FileMissingOnBlob_Api(mex.FileName, mex); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (UnexpectedResultCodeException uex) { var ex = PCSiteTraceSource.UnexpectedResultCode_Api(uex.api, uex.resultCode); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (GetMemberLoginInfoFailException gex) { var ex = PCSiteTraceSource.NetworkAccessFail_Api("00000_common/Member.svc/rest/GetMemberLoginInformation", gex); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (TelemaServiceGeneralOperationFailException tex) { var ex = PCSiteTraceSource.NetworkAccessFail_Api("00000_common/TelemaServiceGeneralOperation.sv/rest/GetTelemaServiceContract", tex); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (WebApplicationFatalException wex) { var ex = PCSiteTraceSource.MethodFailure(string.Format("パスワードリセットAPIでエラーが発生。URL{0}, レスポンス:{1}", wex.Url, wex.Response)); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } catch (Exception e) { var ex = PCSiteTraceSource.SystemError_Api("パスワードリセットAPIで想定外のエラーが発生", e); var id = 0; ex.TryGetId(out id); return(requestMessage.CreateResponse(HttpStatusCode.InternalServerError, new ErrorResponse { Errors = new Dictionary <string, string> { { "code", id.ToString() } } })); } }