bug5197: Created SetOwnershipOperation

This commit is contained in:
Tim Hessenmüller committed 2020-03-16 14:28:07 +01:00
1 parent 7704f98b51
commit 65ad45ff75
2 files changed
+32 -1

No files matched your search

@@ -110,6 +110,7 @@ import com.sap.sse.security.operations.DeleteUserGroupOperation;
import com.sap.sse.security.operations.PutRoleDefinitionToUserGroupOperation;
import com.sap.sse.security.operations.RemoveRoleDefinitionFromUserGroupOperation;
import com.sap.sse.security.operations.RemoveUserFromUserGroupOperation;
import com.sap.sse.security.operations.SetOwnershipOperation;
import com.sap.sse.security.persistence.PersistenceFactory;
import com.sap.sse.security.shared.AccessControlListAnnotation;
import com.sap.sse.security.shared.Account;
@@ -864,7 +865,7 @@ public class SecurityServiceImpl implements ReplicableSecurityService, ClearStat
setDefaultTenantForCurrentServerForUser(username, tenant.getId());
// the new user becomes its owner to ensure the user role is working correctly
// the default tenant is the owning tenant to allow users having admin role for a specific server tenant to also be able to delete users
apply(s->s.internalSetOwnership(result.getIdentifier(), username, groupOwningUser==null?null:groupOwningUser.getId(), username));
apply(new SetOwnershipOperation(result.getIdentifier(), username, groupOwningUser==null?null:groupOwningUser.getId(), username));
updateUserProperties(username, fullName, company, locale);
// email has been set during creation already; the following call will trigger the e-mail validation process
updateSimpleUserEmail(username, email, validationBaseURL);
@@ -0,0 +1,30 @@
package com.sap.sse.security.operations;
import java.util.UUID;
import com.sap.sse.replication.OperationWithResult;
import com.sap.sse.security.impl.ReplicableSecurityService;
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
import com.sap.sse.security.shared.impl.Ownership;
public class SetOwnershipOperation implements OperationWithResult<ReplicableSecurityService, Ownership> {
private static final long serialVersionUID = 1L;
protected final QualifiedObjectIdentifier idOfOwnedObject;
protected final String owningUsername;
protected final UUID tenantOwnerId;
protected final String displayNameOfOwnedObject;
public SetOwnershipOperation(QualifiedObjectIdentifier idOfOwnedObject, String owningUsername, UUID tenantOwnerId,
String displayNameOfOwnedObject) {
this.idOfOwnedObject = idOfOwnedObject;
this.owningUsername = owningUsername;
this.tenantOwnerId = tenantOwnerId;
this.displayNameOfOwnedObject = displayNameOfOwnedObject;
}
@Override
public Ownership internalApplyTo(ReplicableSecurityService toState) throws Exception {
return toState.internalSetOwnership(idOfOwnedObject, owningUsername, tenantOwnerId, displayNameOfOwnedObject);
}
}