mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
bug 4813: fix PermissionAndRoleAssociation to build
TypeRelativeObjectIdentifier
This commit is contained in:
1 parent
475356f8b8
commit
1fcdd6fc66
7 files changed
+45
-16
No files matched your search
+5
-1
@@ -118,10 +118,14 @@ public class RoleDefinitionImpl implements RoleDefinition {
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(RoleDefinition roleDefinition) {
|
||||
return new TypeRelativeObjectIdentifier(roleDefinition.getId().toString());
|
||||
return new TypeRelativeObjectIdentifier(getTypeRelativeObjectIdentifierAsString(roleDefinition));
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(UUID uuid) {
|
||||
return new TypeRelativeObjectIdentifier(uuid.toString());
|
||||
}
|
||||
|
||||
public static String getTypeRelativeObjectIdentifierAsString(RoleDefinition roleDefinition) {
|
||||
return roleDefinition.getId().toString();
|
||||
}
|
||||
}
|
||||
+9
-6
@@ -1,20 +1,23 @@
|
||||
package com.sap.sse.security.shared.impl;
|
||||
|
||||
import com.sap.sse.security.shared.RoleDefinitionImpl;
|
||||
import com.sap.sse.security.shared.TypeRelativeObjectIdentifier;
|
||||
|
||||
public class PermissionAndRoleAssociation {
|
||||
public static String get(Role role, User userWithRole) {
|
||||
public static TypeRelativeObjectIdentifier get(Role role, User userWithRole) {
|
||||
String ownerTenantString = "null";
|
||||
UserGroup ownerTenant = role.getQualifiedForTenant();
|
||||
if (ownerTenant != null) {
|
||||
ownerTenantString = ownerTenant.getIdentifier().getTypeRelativeObjectIdentifier();
|
||||
ownerTenantString = UserGroupImpl.getTypeRelativeObjectIdentifierAsString(ownerTenant);
|
||||
}
|
||||
String ownerUserString = "null";
|
||||
User ownerUser = role.getQualifiedForUser();
|
||||
if (ownerUser != null) {
|
||||
ownerUserString = ownerUser.getIdentifier().getTypeRelativeObjectIdentifier();
|
||||
ownerUserString = SecurityUserImpl.getTypeRelativeObjectIdentifierAsString(ownerUser);
|
||||
}
|
||||
String roleDefinitionString = role.getRoleDefinition().getId().toString();
|
||||
String userWithRoleString = userWithRole.getIdentifier().getTypeRelativeObjectIdentifier();
|
||||
String associationTypeRelativeId = WildcardPermissionEncoder.encode(userWithRoleString, roleDefinitionString,
|
||||
String roleDefinitionString = RoleDefinitionImpl.getTypeRelativeObjectIdentifierAsString(role.getRoleDefinition());
|
||||
String userWithRoleString = SecurityUserImpl.getTypeRelativeObjectIdentifierAsString(userWithRole);
|
||||
TypeRelativeObjectIdentifier associationTypeRelativeId = new TypeRelativeObjectIdentifier(userWithRoleString, roleDefinitionString,
|
||||
ownerUserString, ownerTenantString);
|
||||
return associationTypeRelativeId;
|
||||
}
|
||||
|
||||
+13
@@ -9,6 +9,7 @@ import com.sap.sse.security.shared.AbstractRole;
|
||||
import com.sap.sse.security.shared.RoleDefinition;
|
||||
import com.sap.sse.security.shared.SecurityUser;
|
||||
import com.sap.sse.security.shared.SecurityUserGroup;
|
||||
import com.sap.sse.security.shared.TypeRelativeObjectIdentifier;
|
||||
import com.sap.sse.security.shared.WildcardPermission;
|
||||
|
||||
public abstract class SecurityUserImpl<RD extends RoleDefinition, R extends AbstractRole<RD, G, ?>, G extends SecurityUserGroup>
|
||||
@@ -90,4 +91,16 @@ public abstract class SecurityUserImpl<RD extends RoleDefinition, R extends Abst
|
||||
public Iterable<G> getUserGroups() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(User user) {
|
||||
return new TypeRelativeObjectIdentifier(getTypeRelativeObjectIdentifierAsString(user));
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(String userName) {
|
||||
return new TypeRelativeObjectIdentifier(userName);
|
||||
}
|
||||
|
||||
public static String getTypeRelativeObjectIdentifierAsString(User user) {
|
||||
return user.getName();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -19,10 +19,14 @@ public class UserGroupImpl extends AbstractUserGroupImpl<User> implements UserGr
|
||||
}
|
||||
|
||||
static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(UserGroup userGroup) {
|
||||
return new TypeRelativeObjectIdentifier(userGroup.getId().toString());
|
||||
return getTypeRelativeObjectIdentifier(userGroup.getId());
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(UUID uuid) {
|
||||
return new TypeRelativeObjectIdentifier(uuid.toString());
|
||||
}
|
||||
|
||||
public static String getTypeRelativeObjectIdentifierAsString(UserGroup userGroup) {
|
||||
return userGroup.getId().toString();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -139,7 +139,7 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
Util.addAll(user.getRoles(), nonConcurrentModificationCopy);
|
||||
for (Role roleInstance : nonConcurrentModificationCopy) {
|
||||
if (roleInstance.getRoleDefinition().equals(role)) {
|
||||
String associationTypeIdentifier = PermissionAndRoleAssociation.get(roleInstance, user);
|
||||
TypeRelativeObjectIdentifier associationTypeIdentifier = PermissionAndRoleAssociation.get(roleInstance, user);
|
||||
QualifiedObjectIdentifier qualifiedTypeIdentifier = SecuredSecurityTypes.ROLE_ASSOCIATION
|
||||
.getQualifiedObjectIdentifier(associationTypeIdentifier);
|
||||
getSecurityService().deleteOwnership(qualifiedTypeIdentifier);
|
||||
@@ -441,7 +441,7 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
getLocaleFromLocaleName(localeName), validationBaseURL,
|
||||
getSecurityService().getDefaultTenantForCurrentUser());
|
||||
for (Role role : newUser.getRoles()) {
|
||||
String associationTypeIdentifier = PermissionAndRoleAssociation.get(role, newUser);
|
||||
TypeRelativeObjectIdentifier associationTypeIdentifier = PermissionAndRoleAssociation.get(role, newUser);
|
||||
QualifiedObjectIdentifier qualifiedTypeIdentifier = SecuredSecurityTypes.ROLE_ASSOCIATION
|
||||
.getQualifiedObjectIdentifier(associationTypeIdentifier);
|
||||
|
||||
@@ -586,7 +586,7 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
}
|
||||
}
|
||||
for (Role roleToRemove : roleDefinitionsToRemove) {
|
||||
String associationTypeIdentifier = PermissionAndRoleAssociation.get(roleToRemove, u);
|
||||
TypeRelativeObjectIdentifier associationTypeIdentifier = PermissionAndRoleAssociation.get(roleToRemove, u);
|
||||
QualifiedObjectIdentifier qualifiedTypeIdentifier = SecuredSecurityTypes.ROLE_ASSOCIATION
|
||||
.getQualifiedObjectIdentifier(associationTypeIdentifier);
|
||||
getSecurityService().checkPermissionAndDeleteOwnershipForObjectRemoval(qualifiedTypeIdentifier,
|
||||
@@ -600,9 +600,9 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
});
|
||||
}
|
||||
for (Role roleToAdd : rolesToAdd) {
|
||||
String associationTypeIdentifier = PermissionAndRoleAssociation.get(roleToAdd, u);
|
||||
TypeRelativeObjectIdentifier associationTypeIdentifier = PermissionAndRoleAssociation.get(roleToAdd, u);
|
||||
getSecurityService().setOwnershipCheckPermissionForObjectCreationAndRevertOnError(SecuredSecurityTypes.ROLE_ASSOCIATION,
|
||||
associationTypeIdentifier, associationTypeIdentifier, new Action() {
|
||||
associationTypeIdentifier, associationTypeIdentifier.toString(), new Action() {
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@ import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.UserStore;
|
||||
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
|
||||
import com.sap.sse.security.shared.RoleDefinition;
|
||||
import com.sap.sse.security.shared.TypeRelativeObjectIdentifier;
|
||||
import com.sap.sse.security.shared.impl.PermissionAndRoleAssociation;
|
||||
import com.sap.sse.security.shared.impl.Role;
|
||||
import com.sap.sse.security.shared.impl.SecuredSecurityTypes;
|
||||
@@ -75,10 +76,10 @@ public class Activator implements BundleActivator {
|
||||
}
|
||||
for (User user : securityService.getUserList()) {
|
||||
for (Role role : user.getRoles()) {
|
||||
String associationTypeIdentifier = PermissionAndRoleAssociation.get(role, user);
|
||||
TypeRelativeObjectIdentifier associationTypeIdentifier = PermissionAndRoleAssociation.get(role, user);
|
||||
QualifiedObjectIdentifier associationQualifiedIdentifier = SecuredSecurityTypes.ROLE_ASSOCIATION
|
||||
.getQualifiedObjectIdentifier(associationTypeIdentifier);
|
||||
securityService.migrateOwnership(associationQualifiedIdentifier, associationTypeIdentifier);
|
||||
securityService.migrateOwnership(associationQualifiedIdentifier, associationTypeIdentifier.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -371,13 +371,17 @@ public class UserImpl extends SecurityUserImpl<RoleDefinition, Role, UserGroup>
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(User user) {
|
||||
return new TypeRelativeObjectIdentifier(user.getName());
|
||||
return new TypeRelativeObjectIdentifier(getTypeRelativeObjectIdentifierAsString(user));
|
||||
}
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(String userName) {
|
||||
return new TypeRelativeObjectIdentifier(userName);
|
||||
}
|
||||
|
||||
public static String getTypeRelativeObjectIdentifierAsString(User user) {
|
||||
return user.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasPermissions getType() {
|
||||
return SecuredSecurityTypes.USER;
|
||||
|
||||
Reference in new issue
Block a user