Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const USER_STORE
- const FILE_STORE
- const ACL_LIST
- func getFile(uname string, pwd string, fname string) bool {
- if authenticate(uname, pwd) == false {
- return false
- }
- if fileExists(fname) == false {
- return false
- }
- if authorization(uname, fname) == false {
- return false
- }
- return true
- }
- func authentication(uname string, pwd string) bool {
- val, ok := USER_STORE[uname]; ok {
- if val == hash(pwd + getSalt(uname)) {
- return true
- }
- }
- return false
- func fileExists(fname string) bool {
- _, ok := FILE_STORE[fname]; ok {
- return true
- }
- return false
- }
- func authorization(uname string, fname string) bool {
- val, ok := ACL_LIST[uname]; ok {
- for _, file := range val {
- if file = fname {
- return true
- }
- }
- }
- return false
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement