A new interface, RoleValidator, was created to allow validation of custom user details. So instead of simply validating simply against roles, addition properties of the custom user details can be used in the validation. To know more details, checkout reference API , click the link of Reference Framework then select 新しいインタフェースである RoleValidator は、カスタムユーザー詳細の検証をするために作成されました。そのため、Roleの単純検証の代わりに、カスタムユーザー詳細の追加プロパティは検証で使用可能です。詳細に関しては、 reference API の Reference Framework のリンクをクリックし、その後 com.nexaweb.referenceframework.core.security package.パッケージを選択します。
BasicRoleValidator is the default implementation of the RoleValidator interface. However it only supports the validateRoleはRoleValidator インタ フェースのデフォルト実装です。しかし、validateRole( String role ) method and validates the passed in role against the UserDetails roles based on the configured role voter. By default the role voter is configured to Affirmative.A custom implantation of RoleValidator can specified in the security section of the nexawebメソッドのみをサポートし、設定済みロール所有者に基づきUserDeails に対するロールでパスされたもののみを検証します。デフォルトではロール所有者が Affirmative に設定されています。
RoleValidator のカスタム組み込みは、nexaweb-reference-framework.xml .のセキュリティセクションで指定されます。
Code Block |
---|
<security> <!-- Whether or not security is enable --> <enabled>true</enabled> <!-- xal file to use as login page --> <loginPage>XAL/login/Login.xal</loginPage> <!-- custom role validator --> <roleValidator>com.mycompany.security.impleCustomRoleValidator</roleValidator> </security> |
This will instantiate the specified class and set it as the roleValidator.
Then in the impleCustomRoleValidator
class, you can implement the method below:これは指定されたクラスを例示化し、roleValidator として設定します。
その後、impleCustomRoleValidator クラスでは、次のメソッドを実装することが可能です。
Code Block | ||||
---|---|---|---|---|
| ||||
public boolean validateElement( Element element ) |
For example, if we have a button in the page like this例えば、次のようなページのボタンがある場合 :
<button text="Push Me" validate="true" dept="Department_A"/>
In the validateElement( Element element ) function, we could have codes likeファンクションでは、次のようなコードを持つ可能性があります :
Code Block | ||||
---|---|---|---|---|
| ||||
public boolean validateElement( Element element ) { //validation returning value boolean retValue = false; //User details of the logged in user CustomUserDetailsuserDetails = (CustomUserDetails)AppContext.getAppContext().getSecurityManager().getUserDetails(); //if no validation needed or user's dept attributes contains "Department_A" if(element.getAttribute("validate").equalsIgnoreCase("false") ( element.getAttribute("validate").equalsIgnoreCase("true") && element.getAttribute("dept").indexOf(userDetails.getDepartment())!=-1)){ retValue=true; element.setAttribute("text", "passed");//validation passed }else{ element.setAttribute("text","failed"); //otherwise validation failed } return retValue; } |
If validation is set to true and the user has the value of バリデーションが true に設定され、ユーザーが ”dept” 属性の"Department_A " in the "dept" attribute (Note: the user could be assigned with more than one dept), then the validation is passed.
If not, then validation is failed.
The validation could be triggered by events through MCO function call or through SecurityManager interface. For the sample above using "onCreate" event, it could beの値がある場合(注:ユーザーは一つ以上の dept でアサインされる可能性がある)、バリデーションはパスされます。
そうではない場合は、バリデーションは失敗します。
バリデーションは MCO ファンクション呼び出しまたは SecurityManager インタフェースのイベントによりトリガーされる可能性があります。例えば、上記の "onCreate" イベントを使用すると、次のようになります :
1. Using Mco calls呼び出しを使用:
<button text="Push Me" validate="true" dept="Department_A" onCreate="mco:MyMco.
validateElement
(this)"/>
ln the MyMco, there will be lines like bellowMyMco は次のようになります :
Code Block | ||||
---|---|---|---|---|
| ||||
private impleCustomRoleValidator roleValidator = (impleCustomRoleValidator) AppContext.getAppContext().getSecurityManager().getRoleValidator(); ... public void validateElement(Element element){ roleValidator.validateElement(element) ); } |
2. Using SecurityManager interfaceインタフェースを使用 :
<button text="Push Me" validate="true" dept="Department_A" onCreate="SecurityManager.validateElement(this)"/>
These two methods would serve the same purpose.これらの2つのメソッドでは同じ目的を提供します。
Similarly, in the impleCustomRoleValidator
class, you we could also implement同じように、impleCustomRoleValidator クラスでは、次も実装します :
Code Block | ||||
---|---|---|---|---|
| ||||
public boolean validateInfo( Object infoObj ) |
In this case you could pass any object to be validated.
For the same example above, it will be:このケースでは、検証する全てのオブジェクトをパスすることができます。
上記の同じ例において、
1. Using Mco calls呼び出しを使用:
<button text="Push Me" validate="true" dept="Department_A" onCreate="mco:MyMco.
validateInfo
(this)"/>
2. Using SecurityManager interfaceインタフェースを使用 :
<button text="Push Me" validate="true" dept="Department_A" onCreate="SecurityManager.
validateInfo
(this)"/>
...