当前位置: 首页>>代码示例>>Java>>正文


Java LastOwnerException类代码示例

本文整理汇总了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;
      }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:OwnerImpl.java

示例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());
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:20,代码来源:CloudAclEntrySetTest.java

示例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());
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:LastOwnerException2Test.java

示例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();
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:33,代码来源:CloudAclEntrySet.java

示例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());
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:15,代码来源:LastOwnerException2Test.java

示例6: testLastOwnerException

import java.security.acl.LastOwnerException; //导入依赖的package包/类
public void testLastOwnerException() {
    assertNotNull(new LastOwnerException());
    assertNull(new LastOwnerException().getMessage());
    assertNull(new LastOwnerException().getCause());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:6,代码来源:LastOwnerExceptionTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:LastOwnerExceptionTest.java


注:本文中的java.security.acl.LastOwnerException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。