You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/06/29 09:23:37 UTC
[isis] 02/02: ISIS-2728: adds secman implementation of
UserMementoRefiner
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-2728
in repository https://gitbox.apache.org/repos/asf/isis.git
commit bbe75110ad56f915c3d7d0dae8e75227a249419c
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Jun 29 10:23:09 2021 +0100
ISIS-2728: adds secman implementation of UserMementoRefiner
... to copy the ApplicationUser#atPath onto the UserMemento#multiTenancyToken
---
.../UserMementoRefinerFromApplicationUser.java | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/extensions/security/secman/integration/src/main/java/org/apache/isis/extensions/secman/integration/usermementorefiner/UserMementoRefinerFromApplicationUser.java b/extensions/security/secman/integration/src/main/java/org/apache/isis/extensions/secman/integration/usermementorefiner/UserMementoRefinerFromApplicationUser.java
new file mode 100644
index 0000000..2b29aa2
--- /dev/null
+++ b/extensions/security/secman/integration/src/main/java/org/apache/isis/extensions/secman/integration/usermementorefiner/UserMementoRefinerFromApplicationUser.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.extensions.secman.integration.usermementorefiner;
+
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.services.user.UserMemento;
+import org.apache.isis.core.security.authentication.manager.UserMementoRefiner;
+import org.apache.isis.extensions.secman.applib.user.dom.ApplicationUserRepository;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.log4j.Log4j2;
+
+@Service
+@Log4j2
+@RequiredArgsConstructor(onConstructor_ = {@Inject})
+public class UserMementoRefinerFromApplicationUser implements UserMementoRefiner {
+
+ private final ApplicationUserRepository applicationUserRepository;
+
+ @Override
+ public UserMemento refine(UserMemento userMemento) {
+ return applicationUserRepository.findByUsername(userMemento.getName())
+ .map(applicationUser -> userMemento.withMultiTenancyToken(applicationUser.getAtPath()))
+ .orElse(userMemento);
+ }
+}