Example usage for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl

List of usage examples for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl

Introduction

In this page you can find the example usage for org.springframework.security.acls.domain ObjectIdentityImpl ObjectIdentityImpl.

Prototype

public ObjectIdentityImpl(Object object) throws IdentityUnavailableException 

Source Link

Document

Creates the ObjectIdentityImpl based on the passed object instance.

Usage

From source file:com.sshdemo.common.security.acl.service.EwcmsAclService.java

@Override
public Set<Permission> getPermissions(final Object object) {
    final ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);
    return getPermissions(objectIdentity);
}

From source file:sample.contact.web.AdminPermissionController.java

/**
 * Displays the permission admin page for a particular contact.
 *///w ww . j a v a 2 s . c  o m
@RequestMapping(value = "/secure/adminPermission.htm", method = RequestMethod.GET)
public ModelAndView displayAdminPage(@RequestParam("contactId") int contactId) {
    Contact contact = contactService.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);
}

From source file:com.sshdemo.common.security.acl.service.EwcmsAclService.java

@Override
public List<AccessControlEntry> findAces(final Object object) {
    final ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);
    return findAces(objectIdentity);
}

From source file:com.ewcms.security.acls.service.EwcmsAclService.java

@Override
public void updateInheriting(Object object, Object parent) {
    ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);
    ObjectIdentity parentIdentity = (parent == null ? null : new ObjectIdentityImpl(parent));

    MutableAcl acl = getMutableAcl(objectIdentity);
    if (parentIdentity == null) {
        acl.setEntriesInheriting(Boolean.FALSE);
        acl.setParent(null);/*  w ww .  j a  va 2s  .  c  om*/
    } else {
        Acl parentAcl = getMutableAcl(parentIdentity);
        acl.setParent(parentAcl);
        acl.setEntriesInheriting(Boolean.TRUE);
    }
    updateAcl(acl);
}

From source file:com.sshdemo.common.security.acl.service.EwcmsAclService.java

@Override
public void updateInheriting(Object object, Object parent) {
    ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);
    ObjectIdentity parentIdentity = (parent == null ? null : new ObjectIdentityImpl(parent));

    MutableAcl acl = getMutableAcl(objectIdentity);
    if (parentIdentity == null) {
        acl.setEntriesInheriting(Boolean.FALSE);
        updateAcl(acl);//from  ww  w.j  av a2s.  co m
    }

    Acl parentAcl = getMutableAcl(parentIdentity);
    acl.setParent(parentAcl);
    acl.setEntriesInheriting(Boolean.TRUE);
    updateAcl(acl);
}

From source file:com.sshdemo.common.security.acl.service.EwcmsAclService.java

@Override
public void addPermission(Object object, Sid sid, Permission permission) {
    ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);

    MutableAcl acl = getMutableAcl(objectIdentity);
    acl.insertAce(acl.getEntries().size(), permission, sid, Boolean.TRUE);
    updateAcl(acl);/* www  .j a  v a 2 s .c  om*/
}

From source file:com.sshdemo.common.security.acl.service.EwcmsAclService.java

@Override
public void removePermission(Object object, String name) {
    ObjectIdentity objectIdentity = new ObjectIdentityImpl(object);
    MutableAcl acl = (MutableAcl) readAclById(objectIdentity);

    if (acl.getEntries() == null || acl.getEntries().isEmpty()) {
        return;//from  w  w w.  j ava  2  s. c  om
    }

    for (int i = 0; i < acl.getEntries().size(); i++) {
        AccessControlEntry entry = acl.getEntries().get(i);
        if (entry.getSid().equals(getSid(name))) {
            acl.deleteAce(i);
            updateAcl(acl);
            break;
        }
    }
}