Search in sources :

Example 16 with ObjectIdentityImpl

use of org.springframework.security.acls.domain.ObjectIdentityImpl in project spring-security by spring-projects.

the class ObjectIdentityImplTests method hashcodeIsDifferentForDifferentJavaTypes.

@Test
public void hashcodeIsDifferentForDifferentJavaTypes() throws Exception {
    ObjectIdentity obj = new ObjectIdentityImpl(Object.class, Long.valueOf(1));
    ObjectIdentity obj2 = new ObjectIdentityImpl(String.class, Long.valueOf(1));
    assertThat(obj.hashCode() == obj2.hashCode()).isFalse();
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) Test(org.junit.Test)

Example 17 with ObjectIdentityImpl

use of org.springframework.security.acls.domain.ObjectIdentityImpl in project spring-security by spring-projects.

the class ObjectIdentityImplTests method gettersReturnExpectedValues.

@Test
public void gettersReturnExpectedValues() throws Exception {
    ObjectIdentity obj = new ObjectIdentityImpl(DOMAIN_CLASS, Long.valueOf(1));
    assertThat(obj.getIdentifier()).isEqualTo(Long.valueOf(1));
    assertThat(obj.getType()).isEqualTo(MockIdDomainObject.class.getName());
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) Test(org.junit.Test)

Example 18 with ObjectIdentityImpl

use of org.springframework.security.acls.domain.ObjectIdentityImpl in project spring-security by spring-projects.

the class ContactManagerBackend method deletePermission.

public void deletePermission(Contact contact, Sid recipient, Permission permission) {
    ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());
    MutableAcl acl = (MutableAcl) mutableAclService.readAclById(oid);
    // Remove all permissions associated with this particular recipient (string
    // equality to KISS)
    List<AccessControlEntry> entries = acl.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        if (entries.get(i).getSid().equals(recipient) && entries.get(i).getPermission().equals(permission)) {
            acl.deleteAce(i);
        }
    }
    mutableAclService.updateAcl(acl);
    if (logger.isDebugEnabled()) {
        logger.debug("Deleted contact " + contact + " ACL permissions for recipient " + recipient);
    }
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) AccessControlEntry(org.springframework.security.acls.model.AccessControlEntry) MutableAcl(org.springframework.security.acls.model.MutableAcl)

Example 19 with ObjectIdentityImpl

use of org.springframework.security.acls.domain.ObjectIdentityImpl in project spring-security by spring-projects.

the class ContactManagerBackend method delete.

public void delete(Contact contact) {
    contactDao.delete(contact.getId());
    // Delete the ACL information as well
    ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());
    mutableAclService.deleteAcl(oid, false);
    if (logger.isDebugEnabled()) {
        logger.debug("Deleted contact " + contact + " including ACL permissions");
    }
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl)

Example 20 with ObjectIdentityImpl

use of org.springframework.security.acls.domain.ObjectIdentityImpl in project spring-security by spring-projects.

the class DataSourcePopulator method changeOwner.

private void changeOwner(int contactNumber, String newOwnerUsername) {
    AclImpl acl = (AclImpl) mutableAclService.readAclById(new ObjectIdentityImpl(Contact.class, new Long(contactNumber)));
    acl.setOwner(new PrincipalSid(newOwnerUsername));
    updateAclInTransaction(acl);
}
Also used : AclImpl(org.springframework.security.acls.domain.AclImpl) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid)

Aggregations

ObjectIdentityImpl (org.springframework.security.acls.domain.ObjectIdentityImpl)24 ObjectIdentity (org.springframework.security.acls.model.ObjectIdentity)19 Test (org.junit.Test)13 PrincipalSid (org.springframework.security.acls.domain.PrincipalSid)8 MutableAcl (org.springframework.security.acls.model.MutableAcl)7 Authentication (org.springframework.security.core.Authentication)5 Transactional (org.springframework.transaction.annotation.Transactional)5 BasePermission (org.springframework.security.acls.domain.BasePermission)3 GrantedAuthoritySid (org.springframework.security.acls.domain.GrantedAuthoritySid)3 NotFoundException (org.springframework.security.acls.model.NotFoundException)3 Permission (org.springframework.security.acls.model.Permission)3 Sid (org.springframework.security.acls.model.Sid)3 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)3 HashMap (java.util.HashMap)2 AclImpl (org.springframework.security.acls.domain.AclImpl)2 Acl (org.springframework.security.acls.model.Acl)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1