public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); // Check this object identity hasn't already been persisted if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) { throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists"); } // Need to retrieve the current principal, in order to know who "owns" this ACL // (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); // Create the acl_object_identity row createObjectIdentity(objectIdentity, sid); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval // etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); return (MutableAcl) acl; }
@Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { try (AutoLock l = lock.lockForWrite()) { AclRecord aclRecord = getAclRecordByCache(objID(objectIdentity)); if (aclRecord != null) { throw new AlreadyExistsException("ACL of " + objectIdentity + " exists!"); } AclRecord record = newPrjACL(objectIdentity); crud.save(record); logger.debug("ACL of " + objectIdentity + " created successfully."); } catch (IOException e) { throw new InternalErrorException(e); } return (MutableAcl) readAclById(objectIdentity); }
/** * {@inheritDoc} */ @Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); // Check this object identity hasn't already been persisted if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) { throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists"); } // Need to retrieve the current principal, in order to know who "owns" this ACL (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Sid sid = sidFactory.createPrincipal(auth); createObjectIdentity(objectIdentity, sid); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); return (MutableAcl) acl; }
/** * Same as {@link JdbcMutableAclService#createAcl(ObjectIdentity)} except for duplicate key * checking which is handled by by the database for performance reasons. */ @Transactional @Override public MutableAcl createAcl(ObjectIdentity objectIdentity) { Assert.notNull(objectIdentity, "Object Identity required"); // Need to retrieve the current principal, in order to know who "owns" this ACL // (can be changed later on) Sid sid = SidUtils.createSecurityContextSid(); try { // Create the acl_object_identity row createObjectIdentity(objectIdentity, sid); } catch (DuplicateKeyException e) { throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists"); } // Retrieve the ACL via superclass (ensures cache registration, proper retrieval // etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); return (MutableAcl) acl; }
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); // Check this object identity hasn't already been persisted if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) { throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists"); } // Need to retrieve the current principal, in order to know who "owns" this ACL // (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); // Create the acl_object_identity row createObjectIdentity(objectIdentity, sid); // Retrieve the ACL via superclass (ensures cache registration, proper retrieval // etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); return (MutableAcl) acl; }
@Override public void createUser(UserDetails user) { AuthenticationUser authUser = (AuthenticationUser) user; UserDetails newUser = new InMemoryAuthenticationUserImpl(authUser.getUsername(), authUser.getPassword(), false, authUser.getLoginAttemptsLeft(), new Date(System.currentTimeMillis()), authUser.getFirstName(), authUser.getLastName(), user.getAuthorities()); if( userExists( newUser.getUsername() ) ) { //ALREADY_EXIST: throw new AlreadyExistsException("user already exists"); } users.put(newUser.getUsername(), newUser); }
@Transactional public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { AclSecuredObjectIdentityData aclObjectIdentity = getAclSecuredObjectIdentity(objectIdentity); // Check this object identity hasn't already been persisted if (aclObjectIdentity != null) { throw new AlreadyExistsException("Object identity '" + aclObjectIdentity + "' already exists"); } AclSecuredClassDescriptionData aclClass = aclSecuredClassDao.loadOrCreate(objectIdentity.getType()); // Need to retrieve the current principal, in order to know who "owns" // this ACL (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); String sidName = getSidName(sid); boolean principal = isPrincipal(sid); AclSidData aclSid = aclSecurityIDDao.loadOrCreate(sidName, principal); aclObjectIdentity = aclObjectIdentityDao.createDefaultEntity(); aclObjectIdentity.setObjectIdClass(aclClass); aclObjectIdentity.setSid(aclSid); aclObjectIdentity.setObjectIdIdentity(Long.parseLong((objectIdentity.getIdentifier().toString()))); aclObjectIdentity.setEntriesInheriting(true); aclObjectIdentityDao.persist(aclObjectIdentity); // Retrieve the ACL via superclass (ensures cache registration, proper // retrieval etc) Acl acl = readAclById(objectIdentity); return (MutableAcl) acl; }