本文整理汇总了Java中org.springframework.security.acls.model.AccessControlEntry.getSid方法的典型用法代码示例。如果您正苦于以下问题:Java AccessControlEntry.getSid方法的具体用法?Java AccessControlEntry.getSid怎么用?Java AccessControlEntry.getSid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.acls.model.AccessControlEntry
的用法示例。
在下文中一共展示了AccessControlEntry.getSid方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllAclSids
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的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;
}
示例2: getProjectPermission
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的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;
}
示例3: checkObjectPublic
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的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;
}
示例4: fetchAccessControlInfoForObjectForUser
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
@Override
public AccessControlInfo fetchAccessControlInfoForObjectForUser(Long securedObjectId, Class clazz, String recipient)
{
MutableAcl acl = aclOperationService.fetchAclForObject(clazz, securedObjectId);
AccessControlInfo userAccess = new AccessControlInfo();
userAccess.setRecipient(recipient);
userAccess.setRecipientDisplayName(recipient);
userAccess.setAccessType(AccessTypeEnum.USER.getAccessType());
List<AccessControlEntry> entries = acl.getEntries();
for (AccessControlEntry entry : entries)
{
String aclSid = "";
if (entry.getSid() instanceof PrincipalSid)
{
PrincipalSid pSid = (PrincipalSid) entry.getSid();
aclSid = pSid.getPrincipal();
if (userAccess != null && recipient.equals(aclSid))
{
//userAccess.addPerm((BasePermission) entry.getPermission());
userAccess.setRoleName(userAccess.getRoleName() + " " + entry.getPermission().toString());
}
}
}
return userAccess;
}
示例5: AclEntry
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的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;
}
}
示例6: assertAclEntry
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的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
示例7: findPermisosPerAcl
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
private List<PermisDto> findPermisosPerAcl(Acl acl) {
List<PermisDto> resposta = new ArrayList<PermisDto>();
if (acl != null) {
Map<String, PermisDto> permisosUsuari = new HashMap<String, PermisDto>();
Map<String, PermisDto> permisosRol = new HashMap<String, PermisDto>();
for (AccessControlEntry ace: acl.getEntries()) {
PermisDto permis = null;
if (ace.getSid() instanceof PrincipalSid) {
String principal = ((PrincipalSid)ace.getSid()).getPrincipal();
permis = permisosUsuari.get(principal);
if (permis == null) {
permis = new PermisDto();
permis.setId((Long)ace.getId());
permis.setPrincipalNom(principal);
permis.setPrincipalTipus(PrincipalTipusEnumDto.USUARI);
permisosUsuari.put(principal, permis);
}
} else if (ace.getSid() instanceof GrantedAuthoritySid) {
String grantedAuthority = ((GrantedAuthoritySid)ace.getSid()).getGrantedAuthority();
permis = permisosRol.get(grantedAuthority);
if (permis == null) {
permis = new PermisDto();
permis.setId((Long)ace.getId());
permis.setPrincipalNom(grantedAuthority);
permis.setPrincipalTipus(PrincipalTipusEnumDto.ROL);
permisosRol.put(grantedAuthority, permis);
}
}
if (permis != null) {
updatePermisAmbPermission(
permis,
ace.getPermission());
}
}
resposta.addAll(permisosUsuari.values());
resposta.addAll(permisosRol.values());
}
return resposta;
}
示例8: deleteAccessToSid
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
@Override
public void deleteAccessToSid(String sid, MutableAcl acl)
{
if (!StringUtils.isEmpty(sid))
{
List<AccessControlEntry> entries = acl.getEntries();
if (entries != null)
{
int i = 0;
for (AccessControlEntry entry : entries)
{
String aclSid = "";
if (entry.getSid() instanceof GrantedAuthoritySid)
{
GrantedAuthoritySid gaSid = (GrantedAuthoritySid) entry.getSid();
aclSid = gaSid.getGrantedAuthority();
}
else
{
PrincipalSid pSid = (PrincipalSid) entry.getSid();
aclSid = pSid.getPrincipal();
}
if (sid.equals(aclSid))
acl.deleteAce(i);
else
i++;
}
aclService.updateAcl(acl);
}
}
}
示例9: deleteAccessExceptPublicAndDefault
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
@Override
public void deleteAccessExceptPublicAndDefault(MutableAcl acl)
{
if (acl != null)
{
String owner = ((PrincipalSid)acl.getOwner()).getPrincipal();
List<AccessControlEntry> entries = acl.getEntries();
if (entries != null)
{
int i = 0;
for (AccessControlEntry entry : entries)
{
String aclSid = "";
if (entry.getSid() instanceof GrantedAuthoritySid)
{
GrantedAuthoritySid gaSid = (GrantedAuthoritySid) entry.getSid();
aclSid = gaSid.getGrantedAuthority();
}
else
{
PrincipalSid pSid = (PrincipalSid) entry.getSid();
aclSid = pSid.getPrincipal();
}
if (!aclSid.equalsIgnoreCase(CaNanoRoleEnum.ROLE_ANONYMOUS.toString()) &&
!aclSid.equalsIgnoreCase(CaNanoRoleEnum.ROLE_CURATOR.toString()) &&
!aclSid.equalsIgnoreCase(CaNanoRoleEnum.ROLE_RESEARCHER.toString()) &&
!aclSid.equalsIgnoreCase(owner))
acl.deleteAce(i);
else
i++;
}
aclService.updateAcl(acl);
}
}
}
示例10: findPermisosPerAcl
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
private List<PermisDto> findPermisosPerAcl(Acl acl) {
List<PermisDto> resposta = new ArrayList<PermisDto>();
if (acl != null) {
Map<String, PermisDto> permisosUsuari = new HashMap<String, PermisDto>();
Map<String, PermisDto> permisosRol = new HashMap<String, PermisDto>();
for (AccessControlEntry ace: acl.getEntries()) {
PermisDto permis = null;
if (ace.getSid() instanceof PrincipalSid) {
String principal = ((PrincipalSid)ace.getSid()).getPrincipal();
permis = permisosUsuari.get(principal);
if (permis == null) {
permis = new PermisDto();
permis.setId((Long)ace.getId());
permis.setPrincipalNom(principal);
permis.setPrincipalTipus(PrincipalTipusEnumDto.USUARI);
permisosUsuari.put(principal, permis);
}
} else if (ace.getSid() instanceof GrantedAuthoritySid) {
String grantedAuthority = ((GrantedAuthoritySid)ace.getSid()).getGrantedAuthority();
permis = permisosUsuari.get(grantedAuthority);
if (permis == null) {
permis = new PermisDto();
permis.setId((Long)ace.getId());
permis.setPrincipalNom(grantedAuthority);
permis.setPrincipalTipus(PrincipalTipusEnumDto.ROL);
permisosRol.put(grantedAuthority, permis);
}
}
if (permis != null) {
if (BasePermission.READ.equals(ace.getPermission()))
permis.setRead(true);
if (BasePermission.WRITE.equals(ace.getPermission()))
permis.setWrite(true);
if (BasePermission.CREATE.equals(ace.getPermission()))
permis.setCreate(true);
if (BasePermission.DELETE.equals(ace.getPermission()))
permis.setDelete(true);
if (BasePermission.ADMINISTRATION.equals(ace.getPermission()))
permis.setAdministration(true);
}
}
resposta.addAll(permisosUsuari.values());
resposta.addAll(permisosRol.values());
}
return resposta;
}
示例11: getPermission
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
@Override
public PermissionData getPermission(Acl acl, List<Sid> sids) {
Assert.notNull(tenantsService, "tenantsService is null");
Assert.notNull(userDetailsService, "userDetailsService is null");
final Sid ownerSid = acl.getOwner();
final String ownerTenantId = getTenantFromSid(ownerSid);
if(ownerTenantId == MultiTenancySupport.NO_TENANT) {
throw new RuntimeException("Can not retrieve tenant from acl owner: acl.objectIdentity=" + acl.getObjectIdentity().getIdentifier());
}
final String currentPrincipalTenant = getPrincipalSidTenant(sids);
PermissionGrantingContext pgc = new PermissionGrantingContext(this, ownerSid, currentPrincipalTenant);
// below code based on DefaultPermissionGrantingStrategy
final List<AccessControlEntry> aces = acl.getEntries();
pgc.setHasAces(!aces.isEmpty());
PermissionData.Builder pb = PermissionData.builder();
pb.add(defaultBehavior.getPermission(pgc));
// !! not use foreach here
for(int aceIndex = 0; aceIndex < aces.size(); ++ aceIndex) {
AccessControlEntry ace = aces.get(aceIndex);
Sid aceSid = ace.getSid();
final String aceTenant = getTenantFromSid(aceSid);
for(int sidIndex = 0; sidIndex < sids.size(); ++sidIndex) {
final Sid sid = sids.get(sidIndex);
pgc.setCurrentSid(sid);
//root SIDs consume all ACE
if(aceTenant != null && !pgc.getCurrentTenants().contains(aceTenant)) {
continue;
}
if(!compareSids(sid, aceSid)) {
continue;
}
Permission acep = ace.getPermission();
if(ace.isGranting()) {
pb.add(acep);
} else {
pb.remove(acep);
}
}
}
//TODO handle ACL inheriting
return pb.build();
}
示例12: AceInfo
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
public AceInfo(AccessControlEntry ace) {
super();
this.sidInfo = new SidInfo(ace.getSid());
this.permissionMask = ace.getPermission().getMask();
}
示例13: getAccessString
import org.springframework.security.acls.model.AccessControlEntry; //导入方法依赖的package包/类
@Override
public String getAccessString(Long securedObjectId, Class clazz)
{
boolean isOwner = isOwnerOfObject(securedObjectId, clazz);
StringBuilder sb = isOwner ? new StringBuilder("(Owner, Shared with: ") : new StringBuilder("(Shared by: ") ;
MutableAcl acl = aclOperationService.fetchAclForObject(clazz, securedObjectId);
List<AccessControlEntry> entries = acl.getEntries();
if (entries != null)
{
List<String> uniqueSid = new ArrayList<String>();
for (AccessControlEntry entry : entries)
{
if (entry.getSid() instanceof GrantedAuthoritySid)
{
GrantedAuthoritySid gaSid = (GrantedAuthoritySid) entry.getSid();
String grantedAuthority = gaSid.getGrantedAuthority();
if (!uniqueSid.contains(grantedAuthority))
{
String str = grantedAuthority;
if (grantedAuthority.startsWith("ROLE_"))
{
CaNanoRoleEnum roleEnum = CaNanoRoleEnum.getFromString(grantedAuthority);
str = roleEnum.getRoleName();
}
sb.append(str).append(", ");
uniqueSid.add(grantedAuthority);
}
}
else
{
PrincipalSid pSid = (PrincipalSid) entry.getSid();
String principal = pSid.getPrincipal();
if (isOwner && !SpringSecurityUtil.getLoggedInUserName().equals(principal) && !uniqueSid.contains(principal))
{
sb.append(principal).append(", ");
uniqueSid.add(principal);
}
}
}
}
return sb.substring(0, sb.lastIndexOf(",")) + ")";
}