Search in sources :

Example 1 with ObjectIdentityImpl

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

the class AdminPermissionController method displayAdminPage.

/**
	 * Displays the permission admin page for a particular contact.
	 */
@RequestMapping(value = "/secure/adminPermission.htm", method = RequestMethod.GET)
public ModelAndView displayAdminPage(@RequestParam("contactId") int contactId) {
    Contact contact = contactManager.getById(Long.valueOf(contactId));
    Acl acl = aclService.readAclById(new ObjectIdentityImpl(contact));
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("contact", contact);
    model.put("acl", acl);
    return new ModelAndView("adminPermission", "model", model);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) ModelAndView(org.springframework.web.servlet.ModelAndView) Acl(org.springframework.security.acls.model.Acl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ObjectIdentityImpl

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

the class ContactManagerBackend method addPermission.

public void addPermission(Contact contact, Sid recipient, Permission permission) {
    MutableAcl acl;
    ObjectIdentity oid = new ObjectIdentityImpl(Contact.class, contact.getId());
    try {
        acl = (MutableAcl) mutableAclService.readAclById(oid);
    } catch (NotFoundException nfe) {
        acl = mutableAclService.createAcl(oid);
    }
    acl.insertAce(acl.getEntries().size(), permission, recipient, true);
    mutableAclService.updateAcl(acl);
    logger.debug("Added permission " + permission + " for Sid " + recipient + " contact " + contact);
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) NotFoundException(org.springframework.security.acls.model.NotFoundException) MutableAcl(org.springframework.security.acls.model.MutableAcl)

Example 3 with ObjectIdentityImpl

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

the class JdbcAclServiceTests method readAclByIdMissingAcl.

// SEC-1898
@Test(expected = NotFoundException.class)
public void readAclByIdMissingAcl() {
    Map<ObjectIdentity, Acl> result = new HashMap<ObjectIdentity, Acl>();
    when(lookupStrategy.readAclsById(anyListOf(ObjectIdentity.class), anyListOf(Sid.class))).thenReturn(result);
    ObjectIdentity objectIdentity = new ObjectIdentityImpl(Object.class, 1);
    List<Sid> sids = Arrays.<Sid>asList(new PrincipalSid("user"));
    aclService.readAclById(objectIdentity, sids);
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) HashMap(java.util.HashMap) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) Acl(org.springframework.security.acls.model.Acl) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) Sid(org.springframework.security.acls.model.Sid) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) Test(org.junit.Test)

Example 4 with ObjectIdentityImpl

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

the class ObjectIdentityImplTests method equalStringIdsAreEqualAndHaveSameHashcode.

@Test
public void equalStringIdsAreEqualAndHaveSameHashcode() throws Exception {
    ObjectIdentity obj = new ObjectIdentityImpl(Object.class, "1000");
    ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, "1000");
    assertThat(obj2).isEqualTo(obj);
    assertThat(obj2.hashCode()).isEqualTo(obj.hashCode());
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) Test(org.junit.Test)

Example 5 with ObjectIdentityImpl

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

the class ObjectIdentityImplTests method longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode.

@Test
public void longAndIntegerIdsWithSameValueAreEqualAndHaveSameHashcode() {
    ObjectIdentity obj = new ObjectIdentityImpl(Object.class, new Long(5));
    ObjectIdentity obj2 = new ObjectIdentityImpl(Object.class, Integer.valueOf(5));
    assertThat(obj2).isEqualTo(obj);
    assertThat(obj2.hashCode()).isEqualTo(obj.hashCode());
}
Also used : ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) ObjectIdentityImpl(org.springframework.security.acls.domain.ObjectIdentityImpl) Test(org.junit.Test)

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