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


Java PermissionNames类代码示例

本文整理汇总了Java中org.kuali.rice.kim.api.KimConstants.PermissionNames的典型用法代码示例。如果您正苦于以下问题:Java PermissionNames类的具体用法?Java PermissionNames怎么用?Java PermissionNames使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PermissionNames类属于org.kuali.rice.kim.api.KimConstants包,在下文中一共展示了PermissionNames类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KRNS_PESSIMISTIC_LOCK_T

import org.kuali.rice.kim.api.KimConstants.PermissionNames; //导入依赖的package包/类
/**
 * tests deleting {@link PessimisticLock} objects. Tests that invalid deletes throw exceptions and valid
 * deletes by owner users as well as lock admin users do work as expected
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '4f6bc9e2-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'employee', 'aa5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '5add9cba-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'dd4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '69e42b8e-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '76504650-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testDeleteLocks() throws Exception {
	
    List<PessimisticLock> locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 4 locks in DB", 4, locks.size());

    String userId = "employee";
    String[] lockIdsToVerify = new String[]{"1112", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
            Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "frank";
    lockIdsToVerify = new String[]{"1111", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "fred";
    lockIdsToVerify = new String[]{"1111", "1112"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);

    verifyDelete("employee", Arrays.asList(new String[]{"1111"}), null, false);
    verifyDelete("frank", Arrays.asList(new String[]{"1112"}), null, false);
    verifyDelete("fred", Arrays.asList(new String[]{"1113"}), null, false);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 1 lock left in DB", 1, locks.size());

    // test admin user can delete any lock
    userId = "fran";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    userId = "admin";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(new String[]{"1114"}), null, false);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 0 locks left in DB", 0, locks.size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:PessimisticLockServiceTest.java

示例2: isPessimisticLockAdminUser

import org.kuali.rice.kim.api.KimConstants.PermissionNames; //导入依赖的package包/类
/**
    * @see org.kuali.rice.krad.service.PessimisticLockService#isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person)
    */
   @Override
public boolean isPessimisticLockAdminUser(Person user) {
   	return getPermissionService().isAuthorized( user.getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
               Collections.<String, String>emptyMap() );
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:PessimisticLockServiceImpl.java

示例3: KRNS_PESSIMISTIC_LOCK_T

import org.kuali.rice.kim.api.KimConstants.PermissionNames; //导入依赖的package包/类
/**
 * tests deleting {@link PessimisticLock} objects. Tests that invalid deletes throw exceptions and valid
 * deletes by owner users as well as lock admin users do work as expected
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '4f6bc9e2-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'employee', 'aa5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '5add9cba-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'dd4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '69e42b8e-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '76504650-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testDeleteLocks() throws Exception {
	
    List<PessimisticLock> locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 4 locks in DB", 4, locks.size());

    String userId = "employee";
    String[] lockIdsToVerify = new String[]{"1112", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
            Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "frank";
    lockIdsToVerify = new String[]{"1111", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "fred";
    lockIdsToVerify = new String[]{"1111", "1112"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);

    verifyDelete("employee", Arrays.asList(new String[]{"1111"}), null, false);
    verifyDelete("frank", Arrays.asList(new String[]{"1112"}), null, false);
    verifyDelete("fred", Arrays.asList(new String[]{"1113"}), null, false);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 1 lock left in DB", 1, locks.size());

    // test admin user can delete any lock
    userId = "fran";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    userId = "admin";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(new String[]{"1114"}), null, false);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 0 locks left in DB", 0, locks.size());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:51,代码来源:PessimisticLockServiceTest.java

示例4: isPessimisticLockAdminUser

import org.kuali.rice.kim.api.KimConstants.PermissionNames; //导入依赖的package包/类
/**
 * @see org.kuali.rice.krad.service.PessimisticLockService#isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person)
 */
public boolean isPessimisticLockAdminUser(Person user) {
	return getPermissionService().isAuthorized( user.getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
            Collections.<String, String>emptyMap() );
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:8,代码来源:PessimisticLockServiceImpl.java


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