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


Java GrantedAuthoritySid类代码示例

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


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

示例1: getAllAclSids

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
public List<String> getAllAclSids(Acl acl, String type) {
    if (null == acl) {
        return Collections.emptyList();
    }

    List<String> result = new ArrayList<>();
    for (AccessControlEntry ace : acl.getEntries()) {
        String name = null;
        if (type.equalsIgnoreCase("user") && ace.getSid() instanceof PrincipalSid) {
            name = ((PrincipalSid) ace.getSid()).getPrincipal();
        }
        if (type.equalsIgnoreCase("group") && ace.getSid() instanceof GrantedAuthoritySid) {
            name = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority();
        }
        if (!StringUtils.isBlank(name)) {
            result.add(name);
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:AccessService.java

示例2: getProjectPermission

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
private Map<String, Integer> getProjectPermission(String project) {
    Map<String, Integer> SidWithPermission = new HashMap<>();

    String uuid = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).getProject(project).getUuid();
    AclEntity ae = getAclEntity(AclEntityType.PROJECT_INSTANCE, uuid);
    Acl acl = getAcl(ae);
    if (acl != null && acl.getEntries() != null) {
        List<AccessControlEntry> aces = acl.getEntries();
        for (AccessControlEntry ace : aces) {
            Sid sid = ace.getSid();
            if (sid instanceof PrincipalSid) {
                String principal = ((PrincipalSid) sid).getPrincipal();
                SidWithPermission.put(principal, ace.getPermission().getMask());
            }
            if (sid instanceof GrantedAuthoritySid) {
                String grantedAuthority = ((GrantedAuthoritySid) sid).getGrantedAuthority();
                SidWithPermission.put(grantedAuthority, ace.getPermission().getMask());
            }
        }
    }
    return SidWithPermission;
}
 
开发者ID:apache,项目名称:kylin,代码行数:23,代码来源:AccessService.java

示例3: mourePermisRol

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
public void mourePermisRol(
		String sourceRoleName,
		String targetRoleName,
		Long objectIdentifier,
		Class<?> objectClass,
		Permission permission) {
	assignarPermisos(
			new GrantedAuthoritySid(getMapeigRol(targetRoleName)),
			objectClass,
			objectIdentifier,
			new Permission[] {permission},
			false);
	revocarPermisos(
			new GrantedAuthoritySid(getMapeigRol(sourceRoleName)),
			objectClass,
			objectIdentifier,
			new Permission[] {permission});
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:19,代码来源:PermisosHelper.java

示例4: updatePermis

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
public void updatePermis(
		Long objectIdentifier,
		Class<?> objectClass,
		PermisDto permis) {
	if (PrincipalTipusEnumDto.USUARI.equals(permis.getPrincipalTipus())) {
		assignarPermisos(
				new PrincipalSid(permis.getPrincipalNom()),
				objectClass,
				objectIdentifier,
				getPermissionsFromPermis(permis),
				true);
	} else if (PrincipalTipusEnumDto.ROL.equals(permis.getPrincipalTipus())) {
		assignarPermisos(
				new GrantedAuthoritySid(getMapeigRol(permis.getPrincipalNom())),
				objectClass,
				objectIdentifier,
				getPermissionsFromPermis(permis),
				true);
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:21,代码来源:PermisosHelper.java

示例5: mourePermisRol

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
public void mourePermisRol(
		String sourceRoleName,
		String targetRoleName,
		Class<?> objectClass,
		Long objectIdentifier,
		Permission permission) {
	assignarPermisos(
			new GrantedAuthoritySid(getMapeigRol(targetRoleName)),
			objectClass,
			objectIdentifier,
			new Permission[] {permission});
	revocarPermisos(
			new GrantedAuthoritySid(getMapeigRol(sourceRoleName)),
			objectClass,
			objectIdentifier,
			new Permission[] {permission});
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:18,代码来源:PermisosHelper.java

示例6: compareSids

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
 * Note that position of SIDs is important
 * @param authSid
 * @param aclSid
 * @return
 */
private boolean compareSids(Sid authSid, Sid aclSid) {
    if(MultiTenancySupport.isNoTenant(aclSid)) {
        // acl sid can has no tenant, we must consider this
        // not that null tenant mean that it common rule for any GrantedAuthorities of tenants
        if(authSid instanceof GrantedAuthoritySid) {
            return (aclSid instanceof GrantedAuthoritySid) && Objects.equals(
              ((GrantedAuthoritySid) authSid).getGrantedAuthority(),
              ((GrantedAuthoritySid) aclSid).getGrantedAuthority()
            );
        }
        if(authSid instanceof PrincipalSid) {
            return (aclSid instanceof PrincipalSid) && Objects.equals(
              ((PrincipalSid) authSid).getPrincipal(),
              ((PrincipalSid) aclSid).getPrincipal()
            );
        }
    }
    // there a unsupported sids or its has tenant, compare its as usual objects
    return aclSid.equals(authSid);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:27,代码来源:TenantBasedPermissionGrantedStrategy.java

示例7: fixTenant

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
 * Fix null tenant for principals and validate.
 * @param sid
 * @param <T>
 * @return
 */
@SuppressWarnings("unchecked")
public static <T extends TenantSid> T fixTenant(T sid) {
    if(sid == null) {
        return sid;
    }
    final String tenant = sid.getTenant();
    if(sid instanceof GrantedAuthoritySid && tenant == null) {
        return sid;
    }
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    ExtendedUserDetails eud = (ExtendedUserDetails) auth.getPrincipal();
    final String authTenant = eud.getTenant();
    if(authTenant.equals(tenant)) {
        return sid;
    }
    if(tenant == null) {
        return (T) TenantPrincipalSid.from((PrincipalSid) sid);
    }
    if(!ROOT_TENANT.equals(authTenant)) {
        // we must check tenancy access through TenantHierarchy, but now we does not have any full tenancy support
        throw new IllegalArgumentException("Sid " + sid + " has incorrect tenant: " + tenant + " it allow only for root tenant.");
    }
    return sid;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:31,代码来源:MultiTenancySupport.java

示例8: test2UpdateAcl

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
@Test
@Rollback(false)
@Transactional(rollbackFor = Exception.class)
public void test2UpdateAcl() {
	Authentication auth = new TestingAuthenticationToken("shazin", "N/A");
	auth.setAuthenticated(true);
	SecurityContextHolder.getContext().setAuthentication(auth);
	ObjectIdentity oid = new ObjectIdentityImpl("my.test.Class", 1l);
	MutableAcl acl = (MutableAcl) mutableAclService.readAclById(oid);

	acl.insertAce(0, BasePermission.CREATE, new GrantedAuthoritySid(
			"ROLE_USER"), true);
	acl.insertAce(1, BasePermission.DELETE, new GrantedAuthoritySid(
			"ROLE_ADMIN"), true);

	mutableAclService.updateAcl(acl);
}
 
开发者ID:shazin,项目名称:spring-security-acl-neo4j,代码行数:18,代码来源:Neo4jMutableAclServiceTest.java

示例9: test4readAclById

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
@Test
@Rollback(false)
@Transactional(rollbackFor = Exception.class)
public void test4readAclById() {
	Authentication auth = new TestingAuthenticationToken("shazin", "N/A");
	auth.setAuthenticated(true);
	SecurityContextHolder.getContext().setAuthentication(auth);

	List<Sid> sids = Arrays.<Sid> asList(new PrincipalSid("USER_0"),
			new GrantedAuthoritySid("ROLE_1"));

	long start = System.nanoTime();
	Acl acl = mutableAclService.readAclById(new ObjectIdentityImpl(
			"com.test.Shazin1", 1l), sids);
	long end = System.nanoTime();

	System.out.println("Reading 1 objects in " + (end - start));

	assertNotNull(acl);
	assertEquals(2, acl.getEntries().size());
}
 
开发者ID:shazin,项目名称:spring-security-acl-neo4j,代码行数:22,代码来源:Neo4jAclServiceTest.java

示例10: checkObjectPublic

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
@Override
public boolean checkObjectPublic(Long securedObjectId, Class clazz)
{
	logger.debug("Checking if secure objectId: " + securedObjectId + " of class: " + clazz.getName() + " is Public.");
	MutableAcl acl = aclOperationService.fetchAclForObject(clazz, securedObjectId);
	List<AccessControlEntry> entries = acl.getEntries();
	if (entries != null)
	{
		for (AccessControlEntry entry : entries)
		{
			if (entry.getSid() instanceof GrantedAuthoritySid)
			{
				GrantedAuthoritySid gaSid = (GrantedAuthoritySid) entry.getSid();
				if (CaNanoRoleEnum.ROLE_ANONYMOUS.toString().equals(gaSid.getGrantedAuthority())) 
					return true;
			}
		}
	}
	return false;
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:21,代码来源:SpringSecurityAclServiceImpl.java

示例11: AclObjectIdentity

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
 * Constructs a new <code>AclObjectIdentity</code> out of the provided {@link Acl}.
 * 
 * @param acl the {@link Acl} to use for parameter population.
 */
public AclObjectIdentity(Acl acl) {
	Assert.notNull(acl, "Acl required");		
	entriesInheriting = acl.isEntriesInheriting();
	id = (String) acl.getObjectIdentity().getIdentifier();
	objectClass = acl.getObjectIdentity().getType();
	
	if (acl.getOwner() instanceof PrincipalSid) {
		ownerId = ((PrincipalSid) acl.getOwner()).getPrincipal();
		ownerPrincipal = true;
	} else if (acl.getOwner() instanceof GrantedAuthoritySid) {
		ownerId = ((GrantedAuthoritySid) acl.getOwner()).getGrantedAuthority();
		ownerPrincipal = false;
	}

	parentObjectId = acl.getParentAcl() != null ? (String) acl.getParentAcl().getObjectIdentity().getIdentifier() : null;
	parentObjectClass = acl.getParentAcl() != null ? (String) acl.getParentAcl().getObjectIdentity().getType() : null;
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:23,代码来源:AclObjectIdentity.java

示例12: AclEntry

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
 * Constructs a new <code>AclEntry</code> out of the provided <code>AccessControlEntry</code>.
 * 
 * @param ace the {@link AccessControlEntry} to use for parameter population.
 */
public AclEntry(AccessControlEntry ace) {
	granting = ace.isGranting();
	id = (String) ace.getId();
	mask = ace.getPermission().getMask();
	order = ace.getAcl().getEntries().indexOf(ace);
	
	if (ace.getSid() instanceof PrincipalSid) {
		sid = ((PrincipalSid) ace.getSid()).getPrincipal();
		sidPrincipal = true;
	} else if (ace.getSid() instanceof GrantedAuthoritySid) {
		sid = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority();
		sidPrincipal = false;
	}
	
	if (ace instanceof AuditableAccessControlEntry) {
		auditSuccess = ((AuditableAccessControlEntry) ace).isAuditSuccess();
		auditFailure =  ((AuditableAccessControlEntry) ace).isAuditFailure();
	} else {
		auditSuccess = false;
		auditFailure = false;
	}
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:28,代码来源:AclEntry.java

示例13: assertAclEntry

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
private void assertAclEntry(AccessControlEntry expected, AccessControlEntry actual) {
	StringBuilder sb = new StringBuilder();
	sb.append(expected.getAcl().getObjectIdentity().getType()).append(":");
	sb.append(expected.getAcl().getObjectIdentity().getIdentifier()).append(":");
	
	if (expected.getSid() instanceof GrantedAuthoritySid) {
		sb.append(((GrantedAuthoritySid) expected.getSid()).getGrantedAuthority());
	} else if (expected.getSid() instanceof PrincipalSid) {
		sb.append(((PrincipalSid) expected.getSid()).getPrincipal());
	}
	sb.append(":").append(expected.getAcl().getEntries().indexOf(expected));
	
	assertEquals(sb.toString(), actual.getId());
	assertEquals(expected.getPermission(), actual.getPermission());
	assertEquals(expected.getSid(), actual.getSid());
	assertEquals(expected.isGranting(), actual.isGranting());
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:18,代码来源:CassandraAclServiceTest.java

示例14: createOrRetrieveSidPrimaryKey

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
 * Retrieves the primary key from acl_sid, creating a new row if needed and the allowCreate property is
 * true.
 *
 * @param sid to find or create
 * @param allowCreate true if creation is permitted if not found
 *
 * @return the primary key or null if not found
 *
 * @throws IllegalArgumentException if the <tt>Sid</tt> is not a recognized implementation.
 */
protected AclSid createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate) {
    Assert.notNull(sid, "Sid required");

    String sidName;
    boolean sidIsPrincipal = true;

    if (sid instanceof PrincipalSid) {
        sidName = ((PrincipalSid) sid).getPrincipal();
    } else if (sid instanceof GrantedAuthoritySid) {
        sidName = ((GrantedAuthoritySid) sid).getGrantedAuthority();
        sidIsPrincipal = false;
    } else {
        throw new IllegalArgumentException("Unsupported implementation of Sid");
    }

    List<AclSid> sidIds = aclDao.findAclSidList(Boolean.valueOf(sidIsPrincipal), sidName);

    if (!sidIds.isEmpty()) {
        return sidIds.get(0);
    }

    if (allowCreate) {
        AclSid sid2 = new AclSid();
        sid2.setSid(sidName);
        sid2.setPrincipal(Boolean.valueOf(sidIsPrincipal));
        return aclDao.createAclSid(sid2);
    }

    return null;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:42,代码来源:JpaMutableAclService.java

示例15: createOrRetrieveSidPrimaryKey

import org.springframework.security.acls.domain.GrantedAuthoritySid; //导入依赖的package包/类
/**
    * Retrieves the primary key from acl_sid, creating a new row if needed and the allowCreate property is
    * true.
    *
    * @param sid to find or create
    * @param allowCreate true if creation is permitted if not found
    *
    * @return the primary key or null if not found
    *
    * @throws IllegalArgumentException if the <tt>Sid</tt> is not a recognized implementation.
    */
   @SuppressWarnings("deprecation")
protected Long createOrRetrieveSidPrimaryKey(Sid sid, boolean allowCreate) {
       Assert.notNull(sid, "Sid required");

       String sidName;
       boolean sidIsPrincipal = true;

       if (sid instanceof PrincipalSid) {
           sidName = ((PrincipalSid) sid).getPrincipal();
       } else if (sid instanceof GrantedAuthoritySid) {
           sidName = ((GrantedAuthoritySid) sid).getGrantedAuthority();
           sidIsPrincipal = false;
       } else {
           throw new IllegalArgumentException("Unsupported implementation of Sid");
       }

       List<Long> sidIds = jdbcTemplate.queryForList(selectSidPrimaryKey,
               new Object[] {Boolean.valueOf(sidIsPrincipal), sidName},  Long.class);

       if (!sidIds.isEmpty()) {
           return sidIds.get(0);
       }

       if (allowCreate) {
           jdbcTemplate.update(insertSid, Boolean.valueOf(sidIsPrincipal), sidName);
           Assert.isTrue(TransactionSynchronizationManager.isSynchronizationActive(), "Transaction must be running");
           return new Long(jdbcTemplate.queryForLong(sidIdentityQuery));
       }

       return null;
   }
 
开发者ID:GovernIB,项目名称:helium,代码行数:43,代码来源:JdbcMutableAclService.java


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