From 2ea505411dd5685eb4288d7ee6d40bda6a09d91c Mon Sep 17 00:00:00 2001 From: Divine Threepwood Date: Tue, 9 Jan 2024 22:18:04 +0100 Subject: [PATCH] make code compile again --- .../lib/auth/AuthorizationWithTokenHelper.kt | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/module/registry/unit-registry/lib/src/main/java/org/openbase/bco/registry/unit/lib/auth/AuthorizationWithTokenHelper.kt b/module/registry/unit-registry/lib/src/main/java/org/openbase/bco/registry/unit/lib/auth/AuthorizationWithTokenHelper.kt index 277f805fc7..8babea995f 100644 --- a/module/registry/unit-registry/lib/src/main/java/org/openbase/bco/registry/unit/lib/auth/AuthorizationWithTokenHelper.kt +++ b/module/registry/unit-registry/lib/src/main/java/org/openbase/bco/registry/unit/lib/auth/AuthorizationWithTokenHelper.kt @@ -131,57 +131,56 @@ object AuthorizationWithTokenHelper { userMessage: UserMessageType.UserMessage, permissionType: AuthorizationHelper.PermissionType, unitRegistry: UnitRegistry, - ): AuthPair = try { - // validate sender + ): AuthPair = try { + // validate sender + canDo( + authenticationBaseData, + unitRegistry.getUnitConfigById(userMessage.senderId), + permissionType, + unitRegistry, + null, + null + ) + } catch (ex: CouldNotPerformException) { + var exceptionStack: ExceptionStack? = null + exceptionStack = MultiException.push(AuthorizationWithTokenHelper::class.java, ex, exceptionStack) + + // validate receiver if sender validation failed. + try { canDo( authenticationBaseData, - unitRegistry.getUnitConfigById(userMessage.senderId), + unitRegistry.getUnitConfigById(userMessage.recipientId), permissionType, unitRegistry, null, null ) - } catch (ex: CouldNotPerformException) { - var exceptionStack: ExceptionStack? = null - exceptionStack = MultiException.push(AuthorizationWithTokenHelper::class.java, ex, exceptionStack) - - // validate receiver if sender validation failed. - try { - canDo( - authenticationBaseData, - unitRegistry.getUnitConfigById(userMessage.recipientId), - permissionType, - unitRegistry, - null, - null - ) - } catch (exx: CouldNotPerformException) { - exceptionStack = MultiException.push(AuthorizationWithTokenHelper::class.java, exx, exceptionStack) + } catch (exx: CouldNotPerformException) { + exceptionStack = MultiException.push(AuthorizationWithTokenHelper::class.java, exx, exceptionStack) - userMessage.conditionList.firstNotNullOfOrNull { condition -> - try { - canDo( - authenticationBaseData, - unitRegistry.getUnitConfigById(condition.unitId), - permissionType, - unitRegistry, - null, - null - ) - } catch (exxx: CouldNotPerformException) { - exceptionStack = - MultiException.push(AuthorizationWithTokenHelper::class.java, exxx, exceptionStack) + userMessage.conditionList.firstNotNullOfOrNull { condition -> + try { + canDo( + authenticationBaseData, + unitRegistry.getUnitConfigById(condition.unitId), + permissionType, + unitRegistry, + null, null - } + ) + } catch (exxx: CouldNotPerformException) { + exceptionStack = + MultiException.push(AuthorizationWithTokenHelper::class.java, exxx, exceptionStack) + null } - MultiException.checkAndThrow({ "Permission denied!" }, exceptionStack) - null } - } ?: throw FatalImplementationErrorException( - "ExceptionStack empty in error case.", - AuthorizationWithTokenHelper::class.java - ) - } + MultiException.checkAndThrow({ "Permission denied!" }, exceptionStack) + null + } + } ?: throw FatalImplementationErrorException( + "ExceptionStack empty in error case.", + AuthorizationWithTokenHelper::class.java + ) /** * Perform a permission check for authentication data including tokens.