Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.79 KB | None | 0 0
  1. const USER_STORE
  2. const FILE_STORE
  3. const ACL_LIST
  4.  
  5. func getFile(uname string, pwd string, fname string) bool {
  6.     if authenticate(uname, pwd) == false {
  7.         return false
  8.     }
  9.    
  10.     if fileExists(fname) == false {
  11.         return false
  12.     }
  13.  
  14.     if authorization(uname, fname) == false {
  15.         return false
  16.     }
  17.  
  18.     return true
  19. }
  20.  
  21. func authentication(uname string, pwd string) bool {
  22.    
  23.     val, ok := USER_STORE[uname]; ok {
  24.         if val == hash(pwd + getSalt(uname)) {
  25.             return true
  26.         }
  27.     }
  28.     return false   
  29.  
  30.  
  31. func fileExists(fname string) bool {
  32.     _, ok := FILE_STORE[fname]; ok {
  33.         return true
  34.     }
  35.     return false
  36. }
  37.  
  38. func authorization(uname string, fname string) bool {
  39.     val, ok := ACL_LIST[uname]; ok {
  40.         for _, file := range val {
  41.             if file = fname {
  42.                 return true
  43.             }
  44.         }
  45.     }
  46.     return false   
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement