0

Here's my problem: I'm working on an application where the users have certain rights. Depending on these rights, they would have access to some functions.

My problem is that I would have to test for every case if the user has the rights or not and enable it or not. For a big app, this task is quite tiring. I want to ask if there is a design pattern or library that simplifies the management of this. My goal is to disable buttons when the user does not have proper permissions.

4

1 に答える 1

1

このようなソリューションでは、複数のことを考慮する必要があります

アイデアのシナリオでは、この問題に対処するために次の方法があります。

  1. USergroupに属するユーザーと、いくつかのデータベースの各ユーザーグループに割り当てられたロールがあります。

  2. ユーザーがアプリケーションにログインすると、データベースからユーザーグループと関連するユーザーロールを取得できます。

  3. ロールを使用して、アクセス権を持つfunctionaNames/フィールド名を格納するためのマップを作成できます。
  4. このマップをセッションスコープに渡し、その値を使用して、フィールドとボタンを有効/無効にします。
  5. 最善の方法は、jspで使用されるフィールドとボタンにカスタムタグを実装してから、マップを検証してフィールドを表示または非表示にするタグにマップオブジェクトを渡すことです。

短くシンプルにしたいだけです。

于 2012-10-22T07:04:14.667 に答える