if(launchSession.hasPolicy()) {
if(launchSession.isTracked()) {
// Launch session is tracked, do not allow policy to change but allow super user to browser readonly
if (!ResourceUtil.isManageableResource(resource, getRepository().getSession().getUser(), null)) {
throw new NoPermissionException("You do not have permission to access this network place resource under this policy.",
getRepository().getSession().getUser(),
resourceType);
}
readOnly = true;
}
else {
// Not a tracked launch session so policy changing is allowed
launchSession.takePolicy();
}
}
/* If the mount has not already been set as ready only (because its tracked)
* There check access to the mount is allowed and change the granting policy
*/
if(!readOnly) {
try {
if (!(resource instanceof OwnedResource) || (resource instanceof OwnedResource && ((OwnedResource) resource).getOwnerUsername() == null)) {
try {
grantingPolicy = PolicyDatabaseFactory.getInstance().getGrantingPolicyForUser(launchSession.getSession().getUser(), resource);
if(grantingPolicy == null) {
throw new NoPermissionException("You may not access this network place resource here.",
getRepository().getSession().getUser(),
resourceType);
}
} catch (NoPermissionException npe2) {
throw npe2;
} catch (Exception e) {
throw new NoPermissionException("Failed to determine if network place resource is accessable.",
getRepository().getSession().getUser(),
resourceType);
}
} else {
if (!(getRepository().getSession().getUser().getPrincipalName().equals(((OwnedResource) resource).getOwnerUsername()))) {
throw new NoPermissionException("You do not have permission to access this network place resource.",
getRepository().getSession().getUser(),
resourceType);
}
}
} catch (NoPermissionException npe) {
if (!ResourceUtil.isManageableResource(resource, getRepository().getSession().getUser(), PolicyConstants.PERM_USE )) {
throw new NoPermissionException("You do not have permission to access this network place resource.",
getRepository().getSession().getUser(),
resourceType);
}
readOnly = true;
} catch (Exception e) {