List of usage examples for org.springframework.security.acls.domain PrincipalSid getPrincipal
public String getPrincipal()
From source file:org.jtalks.common.security.acl.JtalksSidFactoryTest.java
@Test public void testCreate_principalSid() throws Exception { PrincipalSid sid = (PrincipalSid) sidFactory.create("uncle toby", true); assertEquals(sid.getPrincipal(), "uncle toby"); }
From source file:org.jtalks.common.security.acl.sids.UserSid.java
/** * {@inheritDoc}/*from w w w. ja v a2 s. c om*/ */ @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || !(o instanceof PrincipalSid)) { return false; } PrincipalSid that = (PrincipalSid) o; if (!getPrincipal().equals(that.getPrincipal())) { return false; } return true; }
From source file:eu.europeana.aas.acl.CassandraMutableAclService.java
@Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN createAcl: objectIdentity: " + objectIdentity); }//from w w w . ja v a 2 s .co m // Need to retrieve the current principal, in order to know who "owns" // this ACL (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); AclObjectIdentity newAoi = new AclObjectIdentity(objectIdentity); newAoi.setOwnerId(sid.getPrincipal()); newAoi.setOwnerPrincipal(true); newAoi.setEntriesInheriting(false); try { aclRepository.saveAcl(newAoi); } catch (AclAlreadyExistsException e) { throw new AlreadyExistsException(e.getMessage(), e); } // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); if (LOG.isDebugEnabled()) { LOG.debug("END createAcl: acl: " + acl); } return (MutableAcl) acl; }
From source file:com.cedac.security.acls.mongo.MongoMutableAclService.java
@Override public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); LOG.trace(ACL, "Checking that object identity {} hasn't already been persisted", objectIdentity); DBObject result = getAclCollection().findOne(queryByObjectIdentity(objectIdentity)); if (result != null) { LOG.warn(ACL, "An ACL entry for object identity {} already exists.", objectIdentity); throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists"); }/*w w w . j a va2 s . com*/ LOG.trace(ACL, "Retrieving current principal in order to know who owns this ACL."); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); LOG.debug(ACL, "Creating ACL entry."); DBObject ownerSid = new BasicDBObject(principalFieldName, true).append(sidFieldName, sid.getPrincipal()); DBObject objectId = new BasicDBObject(classFieldName, objectIdentity.getType()).append(identityFieldName, objectIdentity.getIdentifier()); DBObject acl = new BasicDBObject(ownerFieldName, ownerSid).append(objectIdFieldName, objectId) .append(entriesInheritingFieldName, true); getAclCollection().insert(acl, writeConcern); LOG.trace(ACL, "Retrieving back ACL using superclass."); return (MutableAcl) readAclById(objectIdentity); }
From source file:org.opennaas.core.security.acl.ACLManager.java
private void insertAclSid(long id, boolean isPrincipal, PrincipalSid sid) { String query = "insert into acl_sid (id, principal, sid) values ( " + id + ", " + (isPrincipal ? 1 : 0) + ", '" + sid.getPrincipal() + "');"; executeSqlQuery(query);/*from w w w. ja v a 2 s. c om*/ }
From source file:org.springframework.security.acls.cassandra.CassandraMutableAclService.java
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException { Assert.notNull(objectIdentity, "Object Identity required"); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN createAcl: objectIdentity: " + objectIdentity); }//from www. j av a 2 s . co m // Need to retrieve the current principal, in order to know who "owns" // this ACL (can be changed later on) Authentication auth = SecurityContextHolder.getContext().getAuthentication(); PrincipalSid sid = new PrincipalSid(auth); AclObjectIdentity newAoi = new AclObjectIdentity(objectIdentity); newAoi.setOwnerId(sid.getPrincipal()); newAoi.setOwnerPrincipal(true); newAoi.setEntriesInheriting(false); try { aclRepository.saveAcl(newAoi); } catch (AclAlreadyExistsException e) { throw new AlreadyExistsException(e.getMessage(), e); } // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc) Acl acl = readAclById(objectIdentity); Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned"); if (LOG.isDebugEnabled()) { LOG.debug("END createAcl: acl: " + acl); } return (MutableAcl) acl; }