Hi everyone
I have written an applcation and now its the step that I want to make user authorization !
but I don't know any thing about it !
if anyone knows please introduce me some articles or please guides me !
thanx for your help

Dani AI

Generated

As clarified, the goal is to give different privileges to different users. Answers from , and pointed at pieces of the solution (UI gating, where to store credentials, and how to define rights). The reliable pattern is to separate authentication (who the user is) from authorization (what they may do), model roles and permissions explicitly, and enforce checks centrally in the service/business layer — not only by hiding UI elements.

A simple, practical plan:

  • Authenticate users (verify password hashes; do not store plaintext).
  • Load the user’s roles from a stable source (database or external config) and keep them server-side.
  • Map roles to permissions (RBAC). Keep that mapping configurable (DB/config) for maintainability.
  • Enforce authorization through a single AuthorizationManager used by services and UI code. Log denied attempts and add unit tests for rules.

A minimal Java pattern (conceptual):

enum Role { ADMIN, USER, GUEST }

enum Permission { VIEW, EDIT, DELETE }

class User {
  String username;
  Set<Role> roles;
}

class AuthorizationManager {
  Map<Role,Set<Permission>> rolePermissions;
  boolean isAllowed(User u, Permission p) {
    return u.roles.stream().anyMatch(r -> rolePermissions.getOrDefault(r, Collections.emptySet()).contains(p));
  }
}

Notes and common pitfalls: prefer database/config over hard-coded constants for long-term flexibility; always validate server-side (clients can be tampered); hash passwords with a strong algorithm (bcrypt/Argon2); for Java SE consider JAAS or for web apps use an established framework (Spring Security) instead of rolling your own. For implementation and security guidance, see the OWASP Access Control cheat sheet and Java JAAS docs: OWASP Access Control Cheat Sheet and Java JAAS Reference.

Recommended Answers

All 11 Replies

just make a function .. call it on top of the main class...

and you can input a username and password from the user ... and if you want it permanent .. then you can save it in a file in encrypted file or as it is.

Hi :)
thanx for your comments , but you have been misunderstanded!
I want to give different privilleges to different users :)

- Nazanin

owww .... I think you failed to explain clearly :D. Any wayz ... I make a different GUI group for every authorization. I made a home finance manager ... with four users with their seperate accounts .. and a general group that can be accessed by everyone ... and an admin .. who can access every GUI.

Hi everyone
I have written an applcation and now its the step that I want to make user authorization !
but I don't know any thing about it !
if anyone knows please introduce me some articles or please guides me !
thanx for your help

If u want it in great looking industrial standard way
u can give him a logon screen
wen he submits u can check to ur backend storage and if avialable
proceed else can show err msg
u can have stoarge at first for purpose of studying can use files and later can
move to dbs.In java u can have both these provisions easily
but if u keep user's details until his sessions that 'll be better because
if ur app have more than one modules and a normal user will not have acess to all.that'll be great :lol:

Hi :)
thanx for your comments , but you have been misunderstanded!
I want to give different privilleges to different users :)

- Nazanin

that's easy
u can define each user's access rights in some constants
and can store in backend along with his user id
while one tries to do a function u can chek if he have the right do it

Hi thanx for your guidance !
but that is some how complex to understant for someone like me for the first time :o
I want to know if you have got sample of this code ! or any thing like that !
thanx :)
E-mail :

Hi thanx for your guidance !
but that is some how complex to understant for someone like me for the first time :o
I want to know if you have got sample of this code ! or any thing like that !
thanx :)
E-mail :

sorry for the gap in reply
actually then way i tell is very easy u have to just use a class for defining all the acess privilages and read from there
ok i 'll try to send some coe snipplets for this

sorry for the gap in reply
actually then way i tell is very easy u have to just use a class for defining all the acess privilages and read from there
ok i 'll try to send some coe snipplets for this

Thanx for your help ! I am waiting for your links :)

Hi everyone
I have written an applcation and now its the step that I want to make user authorization !
but I don't know any thing about it !
if anyone knows please introduce me some articles or please guides me !
thanx for your help

hi ,

i am pandian plz tell ur problem clearly whether the authorization through database or thro coding.

with regards
pandian

hi ,

i am pandian plz tell ur problem clearly whether the authorization through database or thro coding.

with regards
pandian

Hi :)
I mean authorization through coding for example for admin or other ordinary users,the privileges should be different,for example ordinary user can not access to some part of application !
Thanx :o

Thanx for your help ! I am waiting for your links :)

am avilable at

u can snd mails
bye

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.