Guest User

Untitled

a guest
Feb 9th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.76 KB | None | 0 0
  1. Public Class Login
  2. Inherits System.Web.UI.Page
  3.  
  4. Private m_objFranchiseInfo As New clsFranchiseInfo
  5.  
  6. Private Sub Login_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
  7. Dim sEmail As String = Request.QueryString("email")
  8. Dim sPswd As String = Request.QueryString("password")
  9.  
  10.  
  11.  
  12. If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then
  13.  
  14. If (sEmail.ToLower = "admin@mysite.com") Then
  15. FormsAuthentication.SetAuthCookie(sEmail, False)
  16. Session("UserName") = sEmail
  17. Session("Password") = sPswd
  18. Else
  19.  
  20. Dim objService As New clsPropertyware
  21. With objService
  22.  
  23. .UserName = sEmail
  24. .Password = sPswd
  25. .Initialize()
  26.  
  27. If .TestConnection = True Then
  28. FormsAuthentication.SetAuthCookie(sEmail, False)
  29. Session("UserName") = sEmail.ToLower
  30. Session("Password") = sPswd
  31. Session("OrgID") = .GetOrgID
  32.  
  33.  
  34. Else
  35. FormsAuthentication.SetAuthCookie("", True)
  36. Session("UserName") = String.Empty
  37. Session("Password") = String.Empty
  38. Session("OrgID") = String.Empty
  39. End If
  40.  
  41. End With
  42.  
  43.  
  44. End If
  45. Else
  46. FormsAuthentication.SignOut()
  47. Session("UserName") = String.Empty
  48. Session("Password") = String.Empty
  49. Session("OrgID") = String.Empty
  50. End If
  51. End Sub
  52.  
  53.  
  54.  
  55. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  56.  
  57. Dim sEmail As String = Request.QueryString("email")
  58. Dim sPswd As String = Request.QueryString("password")
  59.  
  60. If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then
  61.  
  62. If (sEmail.ToLower = "admin@mysite.com") Then
  63. FormsAuthentication.SetAuthCookie(sEmail, False)
  64. Session("UserName") = sEmail
  65. Session("Password") = sPswd
  66. Else
  67.  
  68. Dim objService As New clsPropertyware
  69. With objService
  70.  
  71. .UserName = sEmail
  72. .Password = sPswd
  73. .Initialize()
  74.  
  75. If .TestConnection = True Then
  76. FormsAuthentication.SetAuthCookie(sEmail, False)
  77. Session("UserName") = sEmail.ToLower
  78. Session("Password") = sPswd
  79. Session("OrgID") = .GetOrgID
  80. Response.Redirect("~/default.aspx")
  81. Else
  82. FormsAuthentication.SetAuthCookie("", True)
  83. Session("UserName") = String.Empty
  84. Session("Password") = String.Empty
  85. Session("OrgID") = String.Empty
  86. End If
  87.  
  88. End With
  89.  
  90.  
  91. End If
  92. Else
  93. FormsAuthentication.SignOut()
  94. Session("UserName") = String.Empty
  95. Session("Password") = String.Empty
  96. Session("OrgID") = String.Empty
  97. End If
  98. End Sub
  99.  
  100.  
  101.  
  102. Private Sub LoginUser_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate
  103.  
  104. Dim szUserName As String = CType(LoginUser.FindControl("UserName"), TextBox).Text().Trim()
  105. Dim szPassword As String = CType(LoginUser.FindControl("Password"), TextBox).Text().Trim()
  106.  
  107. If (szUserName.ToLower = "admin@mysite.com") Then
  108. e.Authenticated = True
  109. Session("UserName") = szUserName
  110. Session("Password") = szPassword
  111. Else
  112.  
  113. Dim objService As New clsPropertyware
  114. With objService
  115.  
  116. .UserName = szUserName
  117. .Password = szPassword
  118. .Initialize()
  119.  
  120. If .TestConnection = True Then
  121. e.Authenticated = True
  122. Session("UserName") = szUserName.ToLower
  123. Session("Password") = szPassword
  124. Session("OrgID") = .GetOrgID
  125. Else
  126. e.Authenticated = False
  127. Session("UserName") = String.Empty
  128. Session("Password") = String.Empty
  129. Session("OrgID") = String.Empty
  130. End If
  131.  
  132. End With
  133. End If
  134.  
  135. End Sub
  136.  
  137.  
  138. Private Sub LoginUser_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginUser.LoggedIn
  139.  
  140. If (Session("UserName") = "admin@mysite.com") Then
  141. Response.Redirect("~/UploadValues.aspx")
  142. Else
  143.  
  144. m_objFranchiseInfo.Clear()
  145. If (m_objFranchiseInfo.Load(Session("UserName")) = True) Then
  146. Session("FranchiseAgent") = m_objFranchiseInfo.szAgent
  147. Session("FranchiseAgent2") = m_objFranchiseInfo.szAgent2
  148. Session("FranchiseAddress") = m_objFranchiseInfo.szAddress
  149. Session("FranchiseCity") = m_objFranchiseInfo.szCity
  150. Session("FranchiseState") = m_objFranchiseInfo.szState
  151. Session("FranchiseZip") = m_objFranchiseInfo.szZip
  152. Session("FranchisePhone") = m_objFranchiseInfo.szPhone
  153. Session("FranchiseFax") = m_objFranchiseInfo.szFax
  154. Session("FranchiseEmail") = m_objFranchiseInfo.szEmail
  155. Else
  156. Response.Redirect("~FranchiseInfo.aspx")
  157. End If
  158. End If
  159.  
  160. End Sub
  161. End Class
  162.  
  163. Imports System.Security.Cryptography
  164.  
  165. Public Class Login
  166. Inherits System.Web.UI.Page
  167.  
  168. Private m_objFranchiseInfo As New clsFranchiseInfo
  169.  
  170. Private Sub Login_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
  171. Dim sEmail As String = Request.QueryString("email")
  172. Dim sPswd As String = Request.QueryString("password")
  173.  
  174.  
  175.  
  176. If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then
  177.  
  178. If (sEmail.ToLower = "admin@mysite.com") Then
  179. FormsAuthentication.SetAuthCookie(sEmail, False)
  180. Session("UserName") = sEmail
  181. Session("Password") = sPswd
  182. Else
  183.  
  184. Dim objService As New clsPropertyware
  185. With objService
  186.  
  187. .UserName = sEmail
  188. .Password = sPswd
  189. .Initialize()
  190.  
  191. If .TestConnection = True Then
  192. FormsAuthentication.SetAuthCookie(sEmail, False)
  193. Session("UserName") = sEmail.ToLower
  194. Session("Password") = sPswd
  195. Session("OrgID") = .GetOrgID
  196.  
  197.  
  198. Else
  199. FormsAuthentication.SetAuthCookie("", True)
  200. Session("UserName") = String.Empty
  201. Session("Password") = String.Empty
  202. Session("OrgID") = String.Empty
  203. End If
  204.  
  205. End With
  206.  
  207.  
  208. End If
  209. Else
  210. FormsAuthentication.SignOut()
  211. Session("UserName") = String.Empty
  212. Session("Password") = String.Empty
  213. Session("OrgID") = String.Empty
  214. End If
  215. End Sub
  216.  
  217.  
  218.  
  219. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  220.  
  221. Dim encryptedEmail As String = "myemail@yahoo.com"
  222. Dim decryptEmail As String = DecryptData("myemail@yahoo.com")
  223. Dim encrpytedPassword As String = "password"
  224.  
  225.  
  226.  
  227.  
  228. Dim sEmail As String = Request.QueryString("email")
  229. Dim sPswd As String = Request.QueryString("password")
  230.  
  231. If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then
  232.  
  233. If (sEmail.ToLower = "admin@mysite.com") Then
  234. FormsAuthentication.SetAuthCookie(sEmail, False)
  235. Session("UserName") = sEmail
  236. Session("Password") = sPswd
  237. Else
  238.  
  239. Dim objService As New clsPropertyware
  240. With objService
  241.  
  242. .UserName = sEmail
  243. .Password = sPswd
  244. .Initialize()
  245.  
  246. If .TestConnection = True Then
  247. FormsAuthentication.SetAuthCookie(sEmail, False)
  248. Session("UserName") = sEmail.ToLower
  249. Session("Password") = sPswd
  250. Session("OrgID") = .GetOrgID
  251. Response.Redirect("~/default.aspx")
  252. Else
  253. FormsAuthentication.SetAuthCookie("", True)
  254. Session("UserName") = String.Empty
  255. Session("Password") = String.Empty
  256. Session("OrgID") = String.Empty
  257. End If
  258.  
  259. End With
  260.  
  261.  
  262. End If
  263. Else
  264. FormsAuthentication.SignOut()
  265. Session("UserName") = String.Empty
  266. Session("Password") = String.Empty
  267. Session("OrgID") = String.Empty
  268. End If
  269. End Sub
  270.  
  271.  
  272.  
  273. Private Sub LoginUser_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate
  274.  
  275. Dim szUserName As String = CType(LoginUser.FindControl("UserName"), TextBox).Text().Trim()
  276. Dim szPassword As String = CType(LoginUser.FindControl("Password"), TextBox).Text().Trim()
  277.  
  278. If (szUserName.ToLower = "admin@mysite.com") Then
  279. e.Authenticated = True
  280. Session("UserName") = szUserName
  281. Session("Password") = szPassword
  282. Else
  283.  
  284. Dim objService As New clsPropertyware
  285. With objService
  286.  
  287. .UserName = szUserName
  288. .Password = szPassword
  289. .Initialize()
  290.  
  291. If .TestConnection = True Then
  292. e.Authenticated = True
  293. Session("UserName") = szUserName.ToLower
  294. Session("Password") = szPassword
  295. Session("OrgID") = .GetOrgID
  296. Else
  297. e.Authenticated = False
  298. Session("UserName") = String.Empty
  299. Session("Password") = String.Empty
  300. Session("OrgID") = String.Empty
  301. End If
  302.  
  303. End With
  304. End If
  305.  
  306. End Sub
  307.  
  308.  
  309. Private Sub LoginUser_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginUser.LoggedIn
  310.  
  311. If (Session("UserName") = "admin@mysite.com") Then
  312. Response.Redirect("~/UploadValues.aspx")
  313. Else
  314.  
  315. m_objFranchiseInfo.Clear()
  316. If (m_objFranchiseInfo.Load(Session("UserName")) = True) Then
  317. Session("FranchiseAgent") = m_objFranchiseInfo.szAgent
  318. Session("FranchiseAgent2") = m_objFranchiseInfo.szAgent2
  319. Session("FranchiseAddress") = m_objFranchiseInfo.szAddress
  320. Session("FranchiseCity") = m_objFranchiseInfo.szCity
  321. Session("FranchiseState") = m_objFranchiseInfo.szState
  322. Session("FranchiseZip") = m_objFranchiseInfo.szZip
  323. Session("FranchisePhone") = m_objFranchiseInfo.szPhone
  324. Session("FranchiseFax") = m_objFranchiseInfo.szFax
  325. Session("FranchiseEmail") = m_objFranchiseInfo.szEmail
  326. Else
  327. Response.Redirect("~FranchiseInfo.aspx")
  328. End If
  329. End If
  330.  
  331. End Sub
  332.  
  333. Public Function DecryptData(
  334. ByVal encryptedtext As String) As String
  335.  
  336. ' Convert the encrypted text string to a byte array.
  337. Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext)
  338.  
  339. ' Create the stream.
  340. Dim ms As New System.IO.MemoryStream
  341. ' Create the decoder to write to the stream.
  342. Dim decStream As New CryptoStream(ms,
  343. TripleDES.CreateDecryptor(),
  344. System.Security.Cryptography.CryptoStreamMode.Write)
  345.  
  346. ' Use the crypto stream to write the byte array to the stream.
  347. decStream.Write(encryptedBytes, 0, encryptedBytes.Length)
  348. decStream.FlushFinalBlock()
  349.  
  350. ' Convert the plaintext stream to a string.
  351. Return System.Text.Encoding.Unicode.GetString(ms.ToArray)
  352. End Function
  353.  
  354. Private Function TruncateHash(
  355. ByVal key As String,
  356. ByVal length As Integer) As Byte()
  357.  
  358. Dim sha1 As New SHA1CryptoServiceProvider
  359.  
  360. ' Hash the key.
  361. Dim keyBytes() As Byte =
  362. System.Text.Encoding.Unicode.GetBytes(key)
  363. Dim hash() As Byte = sha1.ComputeHash(keyBytes)
  364.  
  365. ' Truncate or pad the hash.
  366. ReDim Preserve hash(length - 1)
  367. Return hash
  368. End Function
  369.  
  370. Sub New(ByVal key As String)
  371. ' Initialize the crypto provider.
  372. TripleDes.Key = TruncateHash(key, TripleDes.KeySize 8)
  373. TripleDes.IV = TruncateHash("", TripleDes.BlockSize 8)
  374. End Sub
  375.  
  376. Public Function EncryptData(
  377. ByVal plaintext As String) As String
  378.  
  379. ' Convert the plaintext string to a byte array.
  380. Dim plaintextBytes() As Byte =
  381. System.Text.Encoding.Unicode.GetBytes(plaintext)
  382.  
  383. ' Create the stream.
  384. Dim ms As New System.IO.MemoryStream
  385. ' Create the encoder to write to the stream.
  386. Dim encStream As New CryptoStream(ms,
  387. TripleDes.CreateEncryptor(),
  388. System.Security.Cryptography.CryptoStreamMode.Write)
  389.  
  390. ' Use the crypto stream to write the byte array to the stream.
  391. encStream.Write(plaintextBytes, 0, plaintextBytes.Length)
  392. encStream.FlushFinalBlock()
  393.  
  394. ' Convert the encrypted stream to a printable string.
  395. Return Convert.ToBase64String(ms.ToArray)
  396. End Function
  397.  
  398. End Class
Add Comment
Please, Sign In to add comment