本文整理汇总了Java中org.springframework.security.acls.model.Sid类的典型用法代码示例。如果您正苦于以下问题:Java Sid类的具体用法?Java Sid怎么用?Java Sid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sid类属于org.springframework.security.acls.model包,在下文中一共展示了Sid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readAclById
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> map = readAclsById(Arrays.asList(object), sids);
Assert.isTrue(map.containsKey(object), "There should have been an Acl entry for ObjectIdentity " + object);
return (Acl) map.get(object);
}
示例2: lookupPrimaryKeys
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
* Locates the primary key IDs specified in "findNow", adding AclImpl instances with StubAclParents to the
* "acls" Map.
*
* @param acls the AclImpls (with StubAclParents)
* @param findNow Long-based primary keys to retrieve
* @param sids
*/
private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, final List<Sid> sids) {
Assert.notNull(acls, "ACLs are required");
Assert.notEmpty(findNow, "Items to find now required");
String sql = computeRepeatingSql(lookupPrimaryKeysWhereClause, findNow.size());
Set<Long> parentsToLookup = jdbcTemplate.query(sql,
new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException {
int i = 0;
for (Long toFind : findNow) {
i++;
ps.setLong(i, toFind);
}
}
}, new ProcessResultSet(acls, sids));
// Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
if (parentsToLookup.size() > 0) {
lookupPrimaryKeys(acls, parentsToLookup, sids);
}
}
示例3: isGranted
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public boolean isGranted(Acl acl, List<Permission> requests, List<Sid> sids, boolean administrativeMode) {
PermissionData granted = getPermission(acl, sids);
final int grantedMask = granted.getMask();
boolean allow = false;
for(Permission request: requests) {
int reqMask = request.getMask();
if((reqMask & grantedMask) == reqMask) {
allow = true;
}
if(!allow) {
// each false is mean disallow
break;
}
}
return allow;
}
示例4: getProjectPermission
import org.springframework.security.acls.model.Sid; //导入依赖的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;
}
示例5: readAclsById
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> result = doLookup(objects, sids);
// Check every requested object identity was found (throw
// NotFoundException if needed)
for (ObjectIdentity oid : objects) {
if (!result.containsKey(oid)) {
throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'");
}
}
return result;
}
示例6: lookUpParentAcls
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
private void lookUpParentAcls(Map<Serializable, Acl> acls, Set<String> parentIds, List<Sid> sids) {
QAclObjectIdentity aclObjectIdentity = QAclObjectIdentity.aclObjectIdentity;
BooleanExpression objectIdentityCondition = null;
for (String oid : parentIds) {
BooleanExpression oidCondition = aclObjectIdentity.id.eq(oid);
if (objectIdentityCondition == null) {
objectIdentityCondition = oidCondition;
} else {
objectIdentityCondition = objectIdentityCondition.or(oidCondition);
}
}
List<AclObjectIdentity> aoiList = (List<AclObjectIdentity>) objectIdentityRepository
.findAll(objectIdentityCondition, aclObjectIdentity.objectIdIdentity.asc());
Set<String> parentIdsToLookup = getParentIdsToLookup(acls, aoiList, sids);
if (parentIdsToLookup != null && parentIdsToLookup.size() > 0) {
lookUpParentAcls(acls, parentIdsToLookup, sids);
}
}
示例7: readAclsById
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
* Read Acls By Object Identities and Sids
*/
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects,
sids);
// Check every requested object identity was found (throw
// NotFoundException if needed)
for (ObjectIdentity oid : objects) {
if (!result.containsKey(oid)) {
throw new NotFoundException(
"Unable to find ACL information for object identity '"
+ oid + "'");
}
}
return result;
}
示例8: getAclEntriesGroupedBySid
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Map<Sid, List<AccessControlEntry>> getAclEntriesGroupedBySid(
Serializable id,
Class clazz) {
ObjectIdentity oid = new ObjectIdentityImpl(clazz, id);
try {
Map<Sid, List<AccessControlEntry>> resposta = new HashMap<Sid, List<AccessControlEntry>>();
List<AccessControlEntry> aces = aclServiceDao.findAclsByOid(oid);
if (aces != null) {
for (AccessControlEntry ace: aces) {
List<AccessControlEntry> entriesForSid = resposta.get(ace.getSid());
if (entriesForSid == null) {
entriesForSid = new ArrayList<AccessControlEntry>();
resposta.put(ace.getSid(), entriesForSid);
}
entriesForSid.add(ace);
}
}
return resposta;
} catch (NotFoundException ex) {
return null;
}
}
示例9: revocarPermisos
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
private void revocarPermisos(
Sid sid,
Class<?> objectClass,
Serializable objectIdentifier,
Permission[] permissions) throws NotFoundException {
ObjectIdentity oid = new ObjectIdentityImpl(objectClass, objectIdentifier);
try {
MutableAcl acl = (MutableAcl)aclService.readAclById(oid);
List<Integer> indexosPerEsborrar = new ArrayList<Integer>();
int aceIndex = 0;
for (AccessControlEntry ace: acl.getEntries()) {
if (ace.getSid().equals(sid)) {
for (Permission p: permissions) {
if (p.equals(ace.getPermission()))
indexosPerEsborrar.add(aceIndex);
}
}
aceIndex++;
}
for (Integer index: indexosPerEsborrar)
acl.deleteAce(index);
aclService.updateAcl(acl);
} catch (NotFoundException nfex) {
// Si no troba l'ACL no fa res
}
}
示例10: compareSids
import org.springframework.security.acls.model.Sid; //导入依赖的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);
}
示例11: cumulativePermissions
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Test
public void cumulativePermissions() {
Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_ADMINISTRATOR");
auth.setAuthenticated(true);
SecurityContextHolder.getContext().setAuthentication(auth);
ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, "110");
MutableAcl topParent = mongodbMutableAclService.createAcl(topParentOid);
// Add an ACE permission entry
Permission cm = new CumulativePermission().set(BasePermission.READ).set(BasePermission.ADMINISTRATION);
assertEquals(17, cm.getMask());
Sid benSid = new PrincipalSid(auth);
topParent.insertAce(0, cm, benSid, true);
assertEquals(1, topParent.getEntries().size());
// Explicitly save the changed ACL
topParent = mongodbMutableAclService.updateAcl(topParent);
// Check the mask was retrieved correctly
assertEquals(17, topParent.getEntries().get(0).getPermission().getMask());
assertTrue(topParent.isGranted(Arrays.asList(cm), Arrays.asList(benSid), true));
SecurityContextHolder.clearContext();
}
示例12: test4readAclById
import org.springframework.security.acls.model.Sid; //导入依赖的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());
}
示例13: findAuthorizedModules
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public List<CfModule> findAuthorizedModules() {
List<Sid> sids = sidRetrievalStrategy.getSids(SecurityContextHolder.getContext().getAuthentication());
List<String> names = new ArrayList<String>();
for (Sid sid : sids) {
if (sid instanceof PrincipalSid)
names.add(((PrincipalSid) sid).getPrincipal());
}
log.debug("==============================");
for (String name : names) {
log.debug("Group: " + name);
}
log.debug("==============================");
List<CfModule> authorized = moduleDao.findAuthorized(names);
log.debug("==============================");
for (CfModule fsModule : authorized) {
log.debug("authorized module: " + fsModule.getCode());
}
log.debug("==============================");
return authorized;
}
示例14: readAclsById
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects, sids);
// Check every requested object identity was found (throw NotFoundException if needed)
for (ObjectIdentity oid : objects) {
if (!result.containsKey(oid)) {
throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'");
}
}
return result;
}
示例15: createObjectIdentity
import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
* Creates an entry in the acl_object_identity table for the passed ObjectIdentity. The Sid is also
* necessary, as acl_object_identity has defined the sid column as non-null.
*
* @param object to represent an acl_object_identity for
* @param owner for the SID column (will be created if there is no acl_sid entry for this particular Sid already)
* @return
*/
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
AclSid sid = createOrRetrieveSidPrimaryKey(owner, true);
AclClass clazz = createOrRetrieveClassPrimaryKey(object.getType(), true);
AclObjectIdentity identity = new AclObjectIdentity();
identity.setObjIdClass(clazz);
identity.setObjIdIdentity((Long) object.getIdentifier());
identity.setOwner(sid);
identity.setEntriesInheriting(Boolean.TRUE);
aclDao.createObjectIdentity(identity);
}