Java 类java.security.acl.LastOwnerException 实例源码

项目:OpenJSharp    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:jdk8u-jdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:java-cloud-filesystem-provider    文件:CloudAclEntrySetTest.java   
@Test
public void testCreateCloudAclEntrySetWithAUserOwnerWillNotAddTheSameOwnerMoreThanOnce() throws NotOwnerException, LastOwnerException {
    TestUserImpl user1 = new TestUserImpl("user1");
    TestUserImpl user2 = new TestUserImpl("user2");
    CloudAclEntrySet cloudAclEntrySet = new CloudAclEntrySet(Sets.newHashSet(user1, user2));
    Assert.assertTrue(cloudAclEntrySet.isOwner(user1));
    Assert.assertTrue(cloudAclEntrySet.isOwner(user2));
    Assert.assertEquals(2, cloudAclEntrySet.getOwners().size());

    Assert.assertFalse(cloudAclEntrySet.addOwner(user1, user2));
    Assert.assertEquals(2, cloudAclEntrySet.getOwners().size());

    TestUserImpl user3 = new TestUserImpl("user3");
    Assert.assertTrue(cloudAclEntrySet.addOwner(user1, user3));
    Assert.assertTrue(cloudAclEntrySet.isOwner(user1));
    Assert.assertTrue(cloudAclEntrySet.isOwner(user2));
    Assert.assertTrue(cloudAclEntrySet.isOwner(user3));
    Assert.assertEquals(3, cloudAclEntrySet.getOwners().size());
}
项目:jdk8u_jdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:lookaside_java-1.8.0-openjdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:infobip-open-jdk-8    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:jdk8u-dev-jdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:In-the-Box-Fork    文件:LastOwnerException2Test.java   
/**
 * @tests java.security.acl.LastOwnerException#LastOwnerException()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "LastOwnerException",
    args = {}
)
public void test_Constructor() {
    // Test for method java.security.acl.LastOwnerException()
    try {
        throw new LastOwnerException();
    } catch (LastOwnerException e) {
        assertEquals("LastOwnerException.toString() should have been "
                + "'java.security.acl.LastOwnerException' but was "
                + e.toString(), "java.security.acl.LastOwnerException", e
                .toString());
    }
}
项目:jdk7-jdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:openjdk-source-code-learn    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:OLD-OpenJDK8    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:openjdk-jdk7u-jdk    文件:OwnerImpl.java   
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * The caller principal must be an owner of the ACL in order to invoke this method.
 *
 * @param caller the principal invoking this method. It must be an owner
 *   of the ACL.
 * @param owner the owner to be removed from the list of owners.
 * @return true if successful, false if owner is already an owner.
 * @exception NotOwnerException if the caller principal is not an owner
 *   of the ACL.
 * @exception LastOwnerException if there is only one owner left, so that
 *   deleteOwner would leave the ACL owner-less.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      if (!ownerList.contains(caller))
        throw new NotOwnerException();

      if (!ownerList.contains(owner)){
        return false;
      } else {
        if (ownerList.size() == 1)
              throw new LastOwnerException();

        ownerList.removeElement(owner);
        return true;
      }
}
项目:java-cloud-filesystem-provider    文件:CloudAclEntrySet.java   
@Override
public boolean deleteOwner(Principal caller, Principal owner) throws NotOwnerException, LastOwnerException {
    ownersLock.readLock().lock();

    try {
        checkWriteAccess(caller);

        // Upgrade to a write lock
        ownersLock.readLock().unlock();
        ownersLock.writeLock().lock();
        boolean returnValue = false;

        try {
            // Cannot delete if this would violate the size constraint
            if (owners.contains(owner)) {
                if (owners.size() == 1) {
                    throw new LastOwnerException();
                }

                returnValue = owners.remove(owner);
            }
        } finally {
            // Downgrade back to a read lock
            ownersLock.readLock().lock();
            ownersLock.writeLock().unlock();
        }

        return returnValue;
    } finally {
        ownersLock.readLock().unlock();
    }
}
项目:freeVM    文件:LastOwnerException2Test.java   
/**
 * @tests java.security.acl.LastOwnerException#LastOwnerException()
 */
public void test_Constructor() {
    // Test for method java.security.acl.LastOwnerException()
    try {
        throw new LastOwnerException();
    } catch (LastOwnerException e) {
        assertEquals("LastOwnerException.toString() should have been "
                + "'java.security.acl.LastOwnerException' but was "
                + e.toString(), "java.security.acl.LastOwnerException", e
                .toString());
    }
}
项目:In-the-Box-Fork    文件:LastOwnerExceptionTest.java   
public void testLastOwnerException() {
    assertNotNull(new LastOwnerException());
    assertNull(new LastOwnerException().getMessage());
    assertNull(new LastOwnerException().getCause());
}
项目:cn1    文件:LastOwnerExceptionTest.java   
/**
 * @tests java.security.acl.LastOwnerException#LastOwnerException()
 */
public void testLastOwnerException() {
    LastOwnerException ex = new LastOwnerException();
    assertNull(ex.getMessage());
    assertNull(ex.getCause());
}
项目:freeVM    文件:LastOwnerExceptionTest.java   
public void testLastOwnerException() {
    assertNotNull(new LastOwnerException());
    assertNull(new LastOwnerException().getMessage());
    assertNull(new LastOwnerException().getCause());
}
项目:freeVM    文件:LastOwnerExceptionTest.java   
/**
 * @tests java.security.acl.LastOwnerException#LastOwnerException()
 */
public void testLastOwnerException() {
    LastOwnerException ex = new LastOwnerException();
    assertNull(ex.getMessage());
    assertNull(ex.getCause());
}