Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectVersion=4.0.0.BUILD-SNAPSHOT
projectVersion=4.0.0.BSA
grailsVersion=4.0.0.RC1
gormVersion=7.0.0.RC2
gradleWrapperVersion=4.9
Expand All @@ -7,4 +7,4 @@ springSecurityVersion=5.1.2.RELEASE
springSecurityCoreVersion=4.0.0.M2
javaServletApiVersion=3.1.0
micronautVersion=1.0.5
hibernateCoreVersion=5.3.7.Final
hibernateCoreVersion=5.3.7.Final
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,36 @@ class AclUtilServiceSpec extends AbstractAclSpec {
ProxyUtils.isProxy report.getClass()
aclUtilService.hasPermission(authenticateAsUser(false), report, WRITE)
}

void 'change owner'() {
given:
buildReports()
AclSid sid = new AclSid(sid: 'ben', principal: true).save(failOnError: true)
def report = Report.get(report1Id)
AclClass aclClass = new AclClass(className: Report.name).save(failOnError: true)
AclObjectIdentity aclObjectIdentity = new AclObjectIdentity(
aclClass: aclClass,
objectId: report1Id,
owner: sid,
entriesInheriting: true).save(failOnError: true)

new AclEntry(
aclObjectIdentity: aclObjectIdentity,
sid: sid,
mask: 1,
granting: true).save(failOnError: true)
flushAndClear()

expect: 'persistent data to be same as Acl'
aclUtilService.readAcl(report).owner.principal == AclObjectIdentity.findByObjectId(report1Id).owner.sid

when:
authenticateAsAdmin()
aclUtilService.changeOwner(report, 'admin')
flushAndClear()

then: "compare Acl with persistent data"
def aoi1 = AclObjectIdentity.findByObjectId(report1Id)
aclUtilService.readAcl(report).owner.principal == aoi1.owner.sid
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ class AclUtilService {
* Update the owner of the domain class instance.
*
* @param domainObject the domain class instance
* @param newOwnerUsername the new username
* @param newRecipient can be a username, role name, Sid, or Authentication
*/
void changeOwner(domainObject, String newUsername) {
void changeOwner(domainObject, recipient) {
MutableAcl acl = readAcl(domainObject)
acl.owner = new PrincipalSid(newUsername)
Sid newSid = createSid(recipient)
acl.owner = newSid
aclService.updateAcl acl
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package grails.plugin.springsecurity.acl

import grails.gorm.dirty.checking.DirtyCheck

import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString

Expand All @@ -25,6 +27,7 @@ import groovy.transform.ToString
*/
@EqualsAndHashCode(includes=['aclClass', 'parent', 'owner', 'entriesInheriting'])
@ToString(includeNames=true)
@DirtyCheck
abstract class AbstractAclObjectIdentity implements Serializable {

AclClass aclClass
Expand Down