org.springframework.security.acls.model.NotFoundException Java Examples
The following examples show how to use
org.springframework.security.acls.model.NotFoundException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccessService.java From kylin with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public MutableAclRecord grant(AclEntity ae, Permission permission, Sid sid) { Message msg = MsgPicker.getMsg(); if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (permission == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); if (sid == null) throw new BadRequestException(msg.getSID_REQUIRED()); MutableAclRecord acl = null; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { acl = init(ae, null); } secureOwner(acl, sid); return aclService.upsertAce(acl, sid, permission); }
Example #2
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * This implementation will simply delete all ACEs in the database and recreate them on each invocation of * this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM * capabilities for create, update and delete operations of {@link MutableAcl}. */ @Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); // Delete this ACL's ACEs in the acl_entry table aclDao.deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity())); // Create this ACL's ACEs in the acl_entry table createEntries(acl); // Change the mutable columns in acl_object_identity updateObjectIdentity(acl); // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
Example #3
Source File: AclService.java From kylin with Apache License 2.0 | 6 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> oids, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> aclMaps = new HashMap<>(); for (ObjectIdentity oid : oids) { AclRecord record = getAclRecordByCache(objID(oid)); if (record == null) { Message msg = MsgPicker.getMsg(); throw new NotFoundException(String.format(Locale.ROOT, msg.getACL_INFO_NOT_FOUND(), oid)); } Acl parentAcl = null; if (record.isEntriesInheriting() && record.getParentDomainObjectInfo() != null) parentAcl = readAclById(record.getParentDomainObjectInfo()); record.init(parentAcl, aclPermissionFactory, permissionGrantingStrategy); aclMaps.put(oid, new MutableAclRecord(record)); } return aclMaps; }
Example #4
Source File: AccessService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')" + " or hasPermission(#ae, 'MANAGEMENT')" + " or hasPermission(#ae, 'OPERATION')" + " or hasPermission(#ae, 'READ')") public MutableAclRecord getAcl(AclEntity ae) { if (null == ae) { return null; } MutableAclRecord acl = null; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { //do nothing? } return acl; }
Example #5
Source File: AccessService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public void clean(AclEntity ae, boolean deleteChildren) { Message msg = MsgPicker.getMsg(); if (ae == null) { throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); } // For those may have null uuid, like DataModel, won't delete Acl. if (ae.getId() == null) return; ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae); try { aclService.deleteAcl(objectIdentity, deleteChildren); } catch (NotFoundException e) { //do nothing? } }
Example #6
Source File: AccessService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public MutableAclRecord grant(AclEntity ae, Permission permission, Sid sid) { Message msg = MsgPicker.getMsg(); if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (permission == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); if (sid == null) throw new BadRequestException(msg.getSID_REQUIRED()); MutableAclRecord acl = null; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { acl = init(ae, null); } secureOwner(acl, sid); return aclService.upsertAce(acl, sid, permission); }
Example #7
Source File: AccessService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public void batchGrant(AclEntity ae, Map<Sid, Permission> sidToPerm) { Message msg = MsgPicker.getMsg(); if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (sidToPerm == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); MutableAclRecord acl; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { acl = init(ae, null); } for (Sid sid : sidToPerm.keySet()) { secureOwner(acl, sid); } aclService.batchUpsertAce(acl, sidToPerm); }
Example #8
Source File: AclService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> oids, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> aclMaps = new HashMap<>(); for (ObjectIdentity oid : oids) { AclRecord record = getAclRecordByCache(objID(oid)); if (record == null) { Message msg = MsgPicker.getMsg(); throw new NotFoundException(String.format(Locale.ROOT, msg.getACL_INFO_NOT_FOUND(), oid)); } Acl parentAcl = null; if (record.isEntriesInheriting() && record.getParentDomainObjectInfo() != null) parentAcl = readAclById(record.getParentDomainObjectInfo()); record.init(parentAcl, aclPermissionFactory, permissionGrantingStrategy); aclMaps.put(oid, new MutableAclRecord(record)); } return aclMaps; }
Example #9
Source File: AccessService.java From kylin with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public void batchGrant(AclEntity ae, Map<Sid, Permission> sidToPerm) { Message msg = MsgPicker.getMsg(); if (ae == null) throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); if (sidToPerm == null) throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED()); MutableAclRecord acl; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { acl = init(ae, null); } for (Sid sid : sidToPerm.keySet()) { secureOwner(acl, sid); } aclService.batchUpsertAce(acl, sidToPerm); }
Example #10
Source File: AccessService.java From kylin with Apache License 2.0 | 6 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public void clean(AclEntity ae, boolean deleteChildren) { Message msg = MsgPicker.getMsg(); if (ae == null) { throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND()); } // For those may have null uuid, like DataModel, won't delete Acl. if (ae.getId() == null) return; ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae); try { aclService.deleteAcl(objectIdentity, deleteChildren); } catch (NotFoundException e) { //do nothing? } }
Example #11
Source File: AccessService.java From kylin with Apache License 2.0 | 6 votes |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')" + " or hasPermission(#ae, 'MANAGEMENT')" + " or hasPermission(#ae, 'OPERATION')" + " or hasPermission(#ae, 'READ')") public MutableAclRecord getAcl(AclEntity ae) { if (null == ae) { return null; } MutableAclRecord acl = null; try { acl = aclService.readAcl(new ObjectIdentityImpl(ae)); } catch (NotFoundException e) { //do nothing? } return acl; }
Example #12
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * This implementation will simply delete all ACEs in the database and recreate them on each invocation of * this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM * capabilities for create, update and delete operations of {@link MutableAcl}. */ @Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); // Delete this ACL's ACEs in the acl_entry table aclDao.deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity())); // Create this ACL's ACEs in the acl_entry table createEntries(acl); // Change the mutable columns in acl_object_identity updateObjectIdentity(acl); // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
Example #13
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * This implementation will simply delete all ACEs in the database and recreate them on each invocation of * this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM * capabilities for create, update and delete operations of {@link MutableAcl}. */ @Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); // Delete this ACL's ACEs in the acl_entry table aclDao.deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity())); // Create this ACL's ACEs in the acl_entry table createEntries(acl); // Change the mutable columns in acl_object_identity updateObjectIdentity(acl); // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
Example #14
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * This implementation will simply delete all ACEs in the database and recreate them on each invocation of * this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM * capabilities for create, update and delete operations of {@link MutableAcl}. */ @Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); // Delete this ACL's ACEs in the acl_entry table aclDao.deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity())); // Create this ACL's ACEs in the acl_entry table createEntries(acl); // Change the mutable columns in acl_object_identity updateObjectIdentity(acl); // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
Example #15
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 6 votes |
/** * This implementation will simply delete all ACEs in the database and recreate them on each invocation of * this method. A more comprehensive implementation might use dirty state checking, or more likely use ORM * capabilities for create, update and delete operations of {@link MutableAcl}. */ @Override public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException { Assert.notNull(acl.getId(), "Object Identity doesn't provide an identifier"); // Delete this ACL's ACEs in the acl_entry table aclDao.deleteEntries(retrieveObjectIdentityPrimaryKey(acl.getObjectIdentity())); // Create this ACL's ACEs in the acl_entry table createEntries(acl); // Change the mutable columns in acl_object_identity updateObjectIdentity(acl); // Clear the cache, including children clearCacheIncludingChildren(acl.getObjectIdentity()); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) return (MutableAcl) readAclById(acl.getObjectIdentity()); }
Example #16
Source File: NextServerAclService.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> acls = new HashMap<ObjectIdentity, Acl>(); for (ObjectIdentity objectIdentity : objects) { acls.put(objectIdentity, new NextServerAcl(objectIdentity, aclDao, securityDao, storageDao)); } return acls; }
Example #17
Source File: AccessService.java From Kylin with Apache License 2.0 | 5 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public Acl revoke(AclEntity ae, Long accessEntryId) { Assert.notNull(ae, "Acl domain object required"); Assert.notNull(accessEntryId, "Ace id required"); ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId()); MutableAcl acl = (MutableAcl) aclService.readAclById(objectIdentity); int indexOfAce = -1; for (int i = 0; i < acl.getEntries().size(); i++) { AccessControlEntry ace = acl.getEntries().get(i); if (((Long) ace.getId()).equals(accessEntryId)) { indexOfAce = i; break; } } if (indexOfAce != -1) { secureOwner(acl, indexOfAce); try { acl.deleteAce(indexOfAce); acl = aclService.updateAcl(acl); } catch (NotFoundException e) { } } return acl; }
Example #18
Source File: AccessService.java From Kylin with Apache License 2.0 | 5 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public Acl update(AclEntity ae, Long accessEntryId, Permission newPermission) { Assert.notNull(ae, "Acl domain object required"); Assert.notNull(accessEntryId, "Ace id required"); Assert.notNull(newPermission, "Acl permission required"); ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId()); MutableAcl acl = (MutableAcl) aclService.readAclById(objectIdentity); int indexOfAce = -1; for (int i = 0; i < acl.getEntries().size(); i++) { AccessControlEntry ace = acl.getEntries().get(i); if (ace.getId().equals(accessEntryId)) { indexOfAce = i; break; } } if (indexOfAce != -1) { secureOwner(acl, indexOfAce); try { acl.updateAce(indexOfAce, newPermission); acl = aclService.updateAcl(acl); } catch (NotFoundException e) { } } return acl; }
Example #19
Source File: AclService.java From Kylin with Apache License 2.0 | 5 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> oids, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> aclMaps = new HashMap<ObjectIdentity, Acl>(); HTableInterface htable = null; Result result = null; try { htable = HBaseConnection.get(hbaseUrl).getTable(aclTableName); for (ObjectIdentity oid : oids) { result = htable.get(new Get(Bytes.toBytes(String.valueOf(oid.getIdentifier())))); if (null != result && !result.isEmpty()) { SidInfo owner = sidSerializer.deserialize(result.getValue(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_OWNER_COLUMN))); Sid ownerSid = (null == owner) ? null : (owner.isPrincipal() ? new PrincipalSid(owner.getSid()) : new GrantedAuthoritySid(owner.getSid())); boolean entriesInheriting = Bytes.toBoolean(result.getValue(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_ENTRY_INHERIT_COLUMN))); Acl parentAcl = null; DomainObjectInfo parentInfo = domainObjSerializer.deserialize(result.getValue(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN))); if (null != parentInfo) { ObjectIdentity parentObj = new ObjectIdentityImpl(parentInfo.getType(), parentInfo.getId()); parentAcl = readAclById(parentObj, null); } AclImpl acl = new AclImpl(oid, oid.getIdentifier(), aclAuthorizationStrategy, permissionGrantingStrategy, parentAcl, null, entriesInheriting, ownerSid); genAces(sids, result, acl); aclMaps.put(oid, acl); } else { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { IOUtils.closeQuietly(htable); } return aclMaps; }
Example #20
Source File: NextServerAclService.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException { List<ObjectIdentity> objects = new ArrayList<ObjectIdentity>(); objects.add(object); Map<ObjectIdentity, Acl> map = readAclsById(objects, sids); if (map.size() == 0) { throw new NotFoundException("Acl not find for " + object); } return map.get(object); }
Example #21
Source File: AccessService.java From Kylin with Apache License 2.0 | 5 votes |
@Transactional @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')") public void clean(AclEntity ae, boolean deleteChildren) { Assert.notNull(ae, "Acl domain object required"); ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId()); try { aclService.deleteAcl(objectIdentity, deleteChildren); } catch (NotFoundException e) { } }
Example #22
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 5 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects, sids); // Check every requested object identity was found (throw NotFoundException if needed) for (ObjectIdentity oid : objects) { if (!result.containsKey(oid)) { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } return result; }
Example #23
Source File: AclRecord.java From kylin with Apache License 2.0 | 5 votes |
@Override public void deleteAce(int aceIndex) throws NotFoundException { verifyAceIndexExists(aceIndex); synchronized (entries) { entries.remove(aceIndex); } }
Example #24
Source File: AclRecord.java From kylin with Apache License 2.0 | 5 votes |
@Override public void updateAce(int aceIndex, Permission permission) throws NotFoundException { verifyAceIndexExists(aceIndex); synchronized (entries) { AceImpl ace = entries.get(aceIndex); ace.setPermission(permission); } }
Example #25
Source File: AclRecord.java From kylin with Apache License 2.0 | 5 votes |
@Override public void insertAce(int atIndexLocation, Permission permission, Sid sid, boolean granting) throws NotFoundException { Assert.state(granting, "Granting must be true"); // entries are strictly ordered, given index is ignored upsertAce(permission, sid); }
Example #26
Source File: ContainersAclProvider.java From haven-platform with Apache License 2.0 | 5 votes |
@Override protected String getCluster(Serializable id) { String strId = (String) id; if(!ContainerUtils.isContainerId(strId)) { throw new IllegalArgumentException("Invalid container id: " + id); } ContainerRegistration cr = containers.getContainer(strId); if(cr == null) { throw new NotFoundException("Container '" + id + "' is not registered."); } String node = cr.getNode(); return nodes.getNodeCluster(node); }
Example #27
Source File: NodesAclProvider.java From haven-platform with Apache License 2.0 | 5 votes |
@Override protected String getCluster(Serializable id) { String strId = (String) id; NodeRegistrationImpl nr = nodeStorage.getNodeRegistrationInternal(strId); if (nr == null) { throw new NotFoundException("Node '" + id + "' is not registered."); } return nr.getCluster(); }
Example #28
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 5 votes |
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects, sids); // Check every requested object identity was found (throw NotFoundException if needed) for (ObjectIdentity oid : objects) { if (!result.containsKey(oid)) { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } return result; }
Example #29
Source File: JpaMutableAclService.java From Spring-Security-Third-Edition with MIT License | 5 votes |
@Override public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> map = readAclsById(Arrays.asList(object), sids); Assert.isTrue(map.containsKey(object), "There should have been an Acl entry for ObjectIdentity " + object); return (Acl) map.get(object); }
Example #30
Source File: AclRecord.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void updateAce(int aceIndex, Permission permission) throws NotFoundException { verifyAceIndexExists(aceIndex); synchronized (entries) { AceImpl ace = entries.get(aceIndex); ace.setPermission(permission); } }