com.sap.ip.me.api.security
Class Permission

java.lang.Object
  extended bycom.sap.ip.me.api.security.Permission

public class Permission
extends java.lang.Object

Title: Permission
Description: List with permissions which shall be checked
Copyright: Copyright (c) 2003
Company: SAP

Example 1: checking for one single permission

  User currentUser = getCurrentUser();
  Permission userPerms = new Permission("TESTPERM", "DATA", "READ");
  if(currentUser.hasPermission(userPerms)){
    System.out.println("User has permission for " + userPerms.getName());
  }
  else {
    System.out.println("User has NO permission for " + userPerms.getName());
  }
  
If the user has a (backend) permission named 'TESTPERM' with the field 'DATA' set to 'READ', this check returns true.

Example 2: checking for several permission with one call
  User currentUser = getCurrentUser();
  Permission userPerms = new Permission("ARTICLES", "READ", "BEER");
  userPerms.add("ARTICLES", "WRITE", "Lager");
  userPerms.add("ARTICLES", "WRITE", "Budweiser");

  if(currentUser.hasPermission(userPerms)){
    System.out.println("User has permission for " + userPerms.getName());
  }
  else {
    System.out.println("User has NO permission for " + userPerms.getName());
  }
  
If the user has a (backend) permission named 'ARTICLES' with the field 'READ' set to 'BEER' AND has a Permission named 'ARTICLES' with the field 'WRITE' set to 'Lager' AND has a Permission named 'ARTICLES' with the field 'WRITE' set to 'Budweiser' this check returns true, so he (maybe) is allowed to read all beers and change Lager and Budweiser.

Note: these tests also return true if the value of a field falls within a range of a (backend-) permission. If the user would be allowed to change all beers from A to K (alphabeticaly), the 'Budweiser' test above would succeed, but the 'Lager' test would fail the the overall test would fail!

Version:
1.0
Author:
T.Kroener

Constructor Summary
Permission(java.lang.String name, java.lang.String field, java.lang.String action)
          Constructor for the Permission object, adds the first PermissionEntry to its internal list
 
Method Summary
 void add(java.lang.String name, java.lang.String field, java.lang.String action)
          Adds a new PermissionEntry to the list of Permissions
 java.util.Vector get()
          Returns a ArrayList with all PermissionEntries
 java.lang.String getName()
          Gets the name of the Permission
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Permission

public Permission(java.lang.String name,
                  java.lang.String field,
                  java.lang.String action)
Constructor for the Permission object, adds the first PermissionEntry to its internal list

Parameters:
name - name of the corresponding ABAP permissionobject
field - fieldname of the corresponding ABAP permissionfield
action - action value of the corresponding ABAP permissionvalue
Method Detail

add

public void add(java.lang.String name,
                java.lang.String field,
                java.lang.String action)
Adds a new PermissionEntry to the list of Permissions

Parameters:
name - name of the corresponding ABAP permissionobject
field - fieldname of the corresponding ABA permissionfield
action - action value of the corresponding ABAP permissionvalue

get

public java.util.Vector get()
Returns a ArrayList with all PermissionEntries

Returns:
ArrayList of PermissionEntry

getName

public java.lang.String getName()
Gets the name of the Permission

Returns:
Name a the Permission


Copyright © 2005 SAP AG. All Rights Reserved.