Example usage for org.springframework.security.acls.model AccessControlEntry getId

List of usage examples for org.springframework.security.acls.model AccessControlEntry getId

Introduction

In this page you can find the example usage for org.springframework.security.acls.model AccessControlEntry getId.

Prototype

Serializable getId();

Source Link

Document

Obtains an identifier that represents this ACE.

Usage

From source file:net.projectmonkey.spring.acl.hbase.repository.HBaseACLRepository.java

private AccessControlEntryValue createAceValue(final AccessControlEntry ace) {
    Serializable aceId = ace.getId();
    // we require the ACE ids to be uuids for ease of serialization /
    // deserialization
    UUID id = (UUID) (aceId != null && aceId instanceof UUID ? aceId : UUID.randomUUID());
    return new AccessControlEntryValue(id, ace.getSid(), ace.getPermission(), ace.isGranting());
}

From source file:org.apache.kylin.rest.service.AccessService.java

@Transactional
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')")
public Acl update(AclEntity ae, Long accessEntryId, Permission newPermission) {
    Message msg = MsgPicker.getMsg();//from  w w w  . jav  a 2  s .c  om

    if (ae == null)
        throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND());
    if (accessEntryId == null)
        throw new BadRequestException(msg.getACE_ID_REQUIRED());
    if (newPermission == null)
        throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED());

    ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId());
    MutableAcl acl = (MutableAcl) aclService.readAclById(objectIdentity);

    int indexOfAce = -1;
    for (int i = 0; i < acl.getEntries().size(); i++) {
        AccessControlEntry ace = acl.getEntries().get(i);
        if (ace.getId().equals(accessEntryId)) {
            indexOfAce = i;
            break;
        }
    }

    if (indexOfAce != -1) {
        secureOwner(acl, indexOfAce);

        try {
            acl.updateAce(indexOfAce, newPermission);
            acl = aclService.updateAcl(acl);
        } catch (NotFoundException e) {
            //do nothing?
        }
    }

    return acl;
}

From source file:org.apache.kylin.rest.service.AccessService.java

public List<AccessEntryResponse> generateAceResponsesByFuzzMatching(Acl acl, String nameSeg,
        boolean isCaseSensitive) {
    if (null == acl) {
        return Collections.emptyList();
    }// ww w  . j  ava 2s  . c o  m

    List<AccessEntryResponse> result = new ArrayList<AccessEntryResponse>();
    for (AccessControlEntry ace : acl.getEntries()) {
        if (nameSeg != null && !needAdd(nameSeg, isCaseSensitive, getName(ace.getSid()))) {
            continue;
        }
        result.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting()));
    }

    return result;
}

From source file:org.apache.kylin.rest.service.AccessService.java

public Object generateAllAceResponses(Acl acl) {
    List<AccessEntryResponse> result = new ArrayList<AccessEntryResponse>();

    while (acl != null) {
        for (AccessControlEntry ace : acl.getEntries()) {
            result.add(//from  www.  ja va2s .  com
                    new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting()));
        }
        acl = acl.getParentAcl();
    }

    return result;
}