本文整理汇总了Java中java.security.acl.LastOwnerException类的典型用法代码示例。如果您正苦于以下问题:Java LastOwnerException类的具体用法?Java LastOwnerException怎么用?Java LastOwnerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LastOwnerException类属于java.security.acl包,在下文中一共展示了LastOwnerException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteOwner
import java.security.acl.LastOwnerException; //导入依赖的package包/类
/**
* 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;
}
}
示例2: testCreateCloudAclEntrySetWithAUserOwnerWillNotAddTheSameOwnerMoreThanOnce
import java.security.acl.LastOwnerException; //导入依赖的package包/类
@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());
}
示例3: test_Constructor
import java.security.acl.LastOwnerException; //导入依赖的package包/类
/**
* @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());
}
}
示例4: deleteOwner
import java.security.acl.LastOwnerException; //导入依赖的package包/类
@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();
}
}
示例5: test_Constructor
import java.security.acl.LastOwnerException; //导入依赖的package包/类
/**
* @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());
}
}
示例6: testLastOwnerException
import java.security.acl.LastOwnerException; //导入依赖的package包/类
public void testLastOwnerException() {
assertNotNull(new LastOwnerException());
assertNull(new LastOwnerException().getMessage());
assertNull(new LastOwnerException().getCause());
}
示例7: testLastOwnerException
import java.security.acl.LastOwnerException; //导入依赖的package包/类
/**
* @tests java.security.acl.LastOwnerException#LastOwnerException()
*/
public void testLastOwnerException() {
LastOwnerException ex = new LastOwnerException();
assertNull(ex.getMessage());
assertNull(ex.getCause());
}