From 8eeac0b2e770434825c1484d52fe15ea91b8b73d Mon Sep 17 00:00:00 2001 From: JoelProminic Date: Thu, 13 Jun 2024 18:01:49 -0500 Subject: [PATCH] Added security for Category agents and fixed agent configuration. #56 --- .../CategoryScripts/CategoryCreate.properties | 2 +- .../CategoryScripts/CategoryDelete.properties | 2 +- .../CategoryScripts/CategoryRead.properties | 2 +- .../CategoryScripts/CategoryUpdate.properties | 2 +- Super.Human.Portal_Agents/gradle.properties | 2 +- .../java/CategoryAgents/CategoryCreate.java | 25 ++++++++++++-- .../java/CategoryAgents/CategoryDelete.java | 25 ++++++++++++-- .../java/CategoryAgents/CategoryRead.java | 33 +++++++++++++++++-- .../java/CategoryAgents/CategoryUpdate.java | 25 ++++++++++++-- .../groovy/auth/SimpleRoleSecuritySpec.groovy | 5 +++ 10 files changed, 106 insertions(+), 17 deletions(-) diff --git a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryCreate.properties b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryCreate.properties index 9115c2b..e8f5227 100644 --- a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryCreate.properties +++ b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryCreate.properties @@ -8,7 +8,7 @@ agent_name=CategoryCreate # The main class that should be run for this agent. This must include the package. The maximum length is 65 characters - additional characters will be cut off. javaproject_class=CategoryAgents/CategoryCreate.class # The JAR to use for this agent. All agents will use the combined JAR -$$jarSourceFile=./build/libs/Super.Human.Portal_DVE_JavaAgents.jar +$$jarSourceFile=./build/libs/Super.Human.Portal_Agents.jar # Comma-separated list of Script Libraries required for this agent $$scriptLibrary=Moonshine-Domino-CRUD diff --git a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryDelete.properties b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryDelete.properties index 9daec05..66e0507 100644 --- a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryDelete.properties +++ b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryDelete.properties @@ -8,7 +8,7 @@ agent_name=CategoryDelete # The main class that should be run for this agent. This must include the package. The maximum length is 65 characters - additional characters will be cut off. javaproject_class=CategoryAgents/CategoryDelete.class # The JAR to use for this agent. All agents will use the combined JAR -$$jarSourceFile=./build/libs/Super.Human.Portal_DVE_JavaAgents.jar +$$jarSourceFile=./build/libs/Super.Human.Portal_Agents.jar # Comma-separated list of Script Libraries required for this agent $$scriptLibrary=Moonshine-Domino-CRUD diff --git a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryRead.properties b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryRead.properties index 9a1b735..6030f64 100644 --- a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryRead.properties +++ b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryRead.properties @@ -8,7 +8,7 @@ agent_name=CategoryRead # The main class that should be run for this agent. This must include the package. The maximum length is 65 characters - additional characters will be cut off. javaproject_class=CategoryAgents/CategoryRead.class # The JAR to use for this agent. All agents will use the combined JAR -$$jarSourceFile=./build/libs/Super.Human.Portal_DVE_JavaAgents.jar +$$jarSourceFile=./build/libs/Super.Human.Portal_Agents.jar # Comma-separated list of Script Libraries required for this agent $$scriptLibrary=Moonshine-Domino-CRUD diff --git a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryUpdate.properties b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryUpdate.properties index d2229d0..db57afc 100644 --- a/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryUpdate.properties +++ b/Super.Human.Portal_Agents/agentProperties/agentbuild/CategoryScripts/CategoryUpdate.properties @@ -8,7 +8,7 @@ agent_name=CategoryUpdate # The main class that should be run for this agent. This must include the package. The maximum length is 65 characters - additional characters will be cut off. javaproject_class=CategoryAgents/CategoryUpdate.class # The JAR to use for this agent. All agents will use the combined JAR -$$jarSourceFile=./build/libs/Super.Human.Portal_DVE_JavaAgents.jar +$$jarSourceFile=./build/libs/Super.Human.Portal_Agents.jar # Comma-separated list of Script Libraries required for this agent $$scriptLibrary=Moonshine-Domino-CRUD diff --git a/Super.Human.Portal_Agents/gradle.properties b/Super.Human.Portal_Agents/gradle.properties index 051aee2..d2ad890 100644 --- a/Super.Human.Portal_Agents/gradle.properties +++ b/Super.Human.Portal_Agents/gradle.properties @@ -1,4 +1,4 @@ notesInstallation=/Applications/HCL Notes.app/Contents/MacOS/ -server=demo/DEMO +server=demo.startcloud.com/STARTcloud dbName=SuperHumanPortal.nsf agentPropertiesDir=agentProperties/ diff --git a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryCreate.java b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryCreate.java index 2a6956a..13d4da5 100644 --- a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryCreate.java +++ b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryCreate.java @@ -1,9 +1,28 @@ package CategoryAgents; +import java.util.Collection; + +import com.moonshine.domino.security.SecurityInterface; + +import auth.RoleRestrictedAgent; +import auth.SecurityBuilder; +import auth.SimpleRoleSecurity; + /** * Modify this class for custom changes to the agent. */ -public class CategoryCreate extends CategoryCreateBase { - - // No modifications by default +public class CategoryCreate extends CategoryCreateBase implements RoleRestrictedAgent { + + public Collection getAllowedRoles() { + return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL); + } + + public SecurityInterface checkSecurity() { + return getSecurity(); + } + + @Override + protected SecurityInterface createSecurityInterface() { + return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog()); + } } diff --git a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryDelete.java b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryDelete.java index ff881b4..fb1bab2 100644 --- a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryDelete.java +++ b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryDelete.java @@ -1,9 +1,28 @@ package CategoryAgents; +import java.util.Collection; + +import com.moonshine.domino.security.SecurityInterface; + +import auth.RoleRestrictedAgent; +import auth.SecurityBuilder; +import auth.SimpleRoleSecurity; + /** * Modify this class for custom changes to the agent. */ -public class CategoryDelete extends CategoryDeleteBase { - - // No modifications by default +public class CategoryDelete extends CategoryDeleteBase implements RoleRestrictedAgent { + + public Collection getAllowedRoles() { + return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL); + } + + public SecurityInterface checkSecurity() { + return getSecurity(); + } + + @Override + protected SecurityInterface createSecurityInterface() { + return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog()); + } } diff --git a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryRead.java b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryRead.java index c1dd432..6040e60 100644 --- a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryRead.java +++ b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryRead.java @@ -1,9 +1,36 @@ package CategoryAgents; +import java.util.Collection; + +import com.moonshine.domino.security.SecurityInterface; + +import auth.RoleRestrictedAgent; +import auth.SecurityBuilder; +import auth.SimpleRoleSecurity; +import lotus.domino.NotesException; +import lotus.domino.View; + /** * Modify this class for custom changes to the agent. */ -public class CategoryRead extends CategoryReadBase { - - // No modifications by default +public class CategoryRead extends CategoryReadBase implements RoleRestrictedAgent { + + public Collection getAllowedRoles() { + return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL); + } + + public SecurityInterface checkSecurity() { + return getSecurity(); + } + + @Override + protected SecurityInterface createSecurityInterface() { + return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog()); + } + + + @Override + protected View getLookupView() throws NotesException { + return agentDatabase.getView("Categories/Ordered"); // use sorting + } } diff --git a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryUpdate.java b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryUpdate.java index 92db9b0..2eaf63e 100644 --- a/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryUpdate.java +++ b/Super.Human.Portal_Agents/src/main/java/CategoryAgents/CategoryUpdate.java @@ -1,9 +1,28 @@ package CategoryAgents; +import java.util.Collection; + +import com.moonshine.domino.security.SecurityInterface; + +import auth.RoleRestrictedAgent; +import auth.SecurityBuilder; +import auth.SimpleRoleSecurity; + /** * Modify this class for custom changes to the agent. */ -public class CategoryUpdate extends CategoryUpdateBase { - - // No modifications by default +public class CategoryUpdate extends CategoryUpdateBase implements RoleRestrictedAgent { + + public Collection getAllowedRoles() { + return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL); + } + + public SecurityInterface checkSecurity() { + return getSecurity(); + } + + @Override + protected SecurityInterface createSecurityInterface() { + return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog()); + } } diff --git a/Super.Human.Portal_Agents/src/test/groovy/auth/SimpleRoleSecuritySpec.groovy b/Super.Human.Portal_Agents/src/test/groovy/auth/SimpleRoleSecuritySpec.groovy index ac0291d..c68a30c 100644 --- a/Super.Human.Portal_Agents/src/test/groovy/auth/SimpleRoleSecuritySpec.groovy +++ b/Super.Human.Portal_Agents/src/test/groovy/auth/SimpleRoleSecuritySpec.groovy @@ -22,6 +22,7 @@ import com.moonshine.domino.security.SecurityInterface import com.moonshine.domino.log.DefaultLogInterface; import config.*; +import CategoryAgents.*; import CustomBookmarkAgents.*; import DocumentationFormAgents.*; import genesis.*; @@ -160,6 +161,10 @@ class SimpleRoleSecuritySpec extends Specification { new DocumentationFormDelete() | ['All'] new DocumentationFormCreate() | ['All'] new DocumentationFormUpdate() | ['All'] + new CategoryRead() | ['All'] + new CategoryDelete() | ['All'] + new CategoryCreate() | ['All'] + new CategoryUpdate() | ['All'] new CustomBookmarkDelete() | ['Administrator'] new CustomBookmarkCreate() | ['Administrator'] new CustomBookmarkUpdate() | ['Administrator']