use of org.cloudfoundry.credhub.entity.PermissionData in project credhub by cloudfoundry-incubator.
the class PermissionDataService method getAllowedOperations.
public List<PermissionOperation> getAllowedOperations(String name, String actor) {
List<PermissionOperation> operations = newArrayList();
Credential credential = credentialDataService.find(name);
PermissionData permissionData = permissionRepository.findByCredentialAndActor(credential, actor);
if (permissionData != null) {
if (permissionData.hasReadPermission()) {
operations.add(PermissionOperation.READ);
}
if (permissionData.hasWritePermission()) {
operations.add(PermissionOperation.WRITE);
}
if (permissionData.hasDeletePermission()) {
operations.add(PermissionOperation.DELETE);
}
if (permissionData.hasReadAclPermission()) {
operations.add(PermissionOperation.READ_ACL);
}
if (permissionData.hasWriteAclPermission()) {
operations.add(PermissionOperation.WRITE_ACL);
}
}
return operations;
}
use of org.cloudfoundry.credhub.entity.PermissionData in project credhub by cloudfoundry-incubator.
the class PermissionDataService method hasPermission.
public boolean hasPermission(String user, String name, PermissionOperation requiredPermission) {
Credential credential = credentialDataService.find(name);
final PermissionData permissionData = permissionRepository.findByCredentialAndActor(credential, user);
return permissionData != null && permissionData.hasPermission(requiredPermission);
}
use of org.cloudfoundry.credhub.entity.PermissionData in project credhub by cloudfoundry-incubator.
the class PermissionDataService method upsertPermissions.
private void upsertPermissions(Credential credential, List<PermissionData> accessEntries, String actor, List<PermissionOperation> operations) {
PermissionData entry = findAccessEntryForActor(accessEntries, actor);
if (entry == null) {
entry = new PermissionData(credential, actor);
}
entry.enableOperations(operations);
permissionRepository.saveAndFlush(entry);
}
Aggregations