com.ibm.portal.state.accesscheck
Interface CheckedEngineURL
- All Superinterfaces:
- Disposable, DisposableURL, EngineURL, URL
public interface CheckedEngineURL
- extends EngineURL
In addition to the functionality of EngineURL the
CheckedEngineURL
allows setting access control checks
that must be fullfilled before the URL is generated. If this access
control check fails write, writeCopy
, and writeRelease
do not produce any output and toString
returns an empty string.
Code sample how to use checked URLs that only creates an URL for
users with Edit permission:
// ----- this code needs to be executed only once -----
// get an instance of the state manager service
StateManagerService service = (StateManagerService)
ServiceManager.getService(StateManagerService.class, true);
// get the state manager from service for this thread
StateManager manager = service.getStateManager();
// fetch the StateAccessorFactory
StateAccessorFactory stateFactory = (StateAccessorFactory)
manager.getAccessorFactory(StateAccessorFactory.class);
// fetch the CheckedURLAccessorFactory
CheckedURLAccessorFactory urlFactory = (CheckedURLAccessorFactory)
manager.getAccessorFactory(CheckedURLAccessorFactory.class);
// ------------------------------------------------------
// ----- this code needs to be done per request -----
// (1) create a new engine url which encodes the current state
StateAccessor stateAcc = stateFactory.getState();
StateHolder state = stateAcc.getStateHolder(request);
stateAcc.dispose();
CheckedEngineURL url = urlFactory.newURL(request, state, null);
// (2) set an access control check
url.setCheck(Constants.EDIT_PAGE, request.getUserPrincipal());
// (3) write to the response stream directly
url.writeDispose(outputStream);
- Since:
- 5.1
Method Summary |
void
| setCheck(Constants.AccessCheck check,
java.security.Principal user)
Specifies that a special access check will be performed before the URL is generated.
|
Methods inherited from interface com.ibm.portal.URL |
java.io.Writer)">write
|
setCheck
void setCheck(Constants.AccessCheck check,
java.security.Principal user)
- Specifies that a special access check will be performed before the URL is generated.
Not setting any access check on the URL results in the same behavoir as
if the access check is NO_CHECK: the URL is always generated.
If the access control check fails no URL is generated.
- Parameters:
- check - Constant identifying the check (must not be null)
- user - Principal to check the permission for (must not be null)