Skip to content

Commit

Permalink
Updated agent with security roles for #43. I have tested the cases I …
Browse files Browse the repository at this point in the history
…can test directly from Super.Human.Portal, but more robustness tests remain.
  • Loading branch information
JoelProminic committed Dec 8, 2023
1 parent d950efb commit 9d695a6
Show file tree
Hide file tree
Showing 21 changed files with 453 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
package CustomBookmarkAgents;

import java.util.Collection;

import org.json.JSONObject;

import com.moonshine.domino.security.SecurityInterface;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;
import auth.SimpleRoleSecurity;
import genesis.LinkProcessor;
import lotus.domino.Document;
import lotus.domino.NotesException;

/**
* Modify this class for custom changes to the agent.
*/
public class CustomBookmarkCreate extends CustomBookmarkCreateBase {
public class CustomBookmarkCreate extends CustomBookmarkCreateBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SecurityBuilder.ROLE_ADMINISTRATOR);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

@Override
protected void writeNewDocument(Document document) throws NotesException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package CustomBookmarkAgents;

import java.util.Collection;

import com.moonshine.domino.security.SecurityInterface;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;

/**
* Modify this class for custom changes to the agent.
*/
public class CustomBookmarkDelete extends CustomBookmarkDeleteBase {
public class CustomBookmarkDelete extends CustomBookmarkDeleteBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SecurityBuilder.ROLE_ADMINISTRATOR);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import org.json.JSONObject;

import com.moonshine.domino.field.FieldDefinition;
import com.moonshine.domino.security.SecurityInterface;
import com.moonshine.domino.util.ConfigurationUtils;
import com.moonshine.domino.util.DominoUtils;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;
import auth.SimpleRoleSecurity;
import genesis.LinkProcessor;
import lotus.domino.Database;
import lotus.domino.NotesException;
Expand All @@ -18,7 +22,20 @@
/**
* Modify this class for custom changes to the agent.
*/
public class CustomBookmarkRead extends CustomBookmarkReadBase {
public class CustomBookmarkRead extends CustomBookmarkReadBase implements RoleRestrictedAgent {

public Collection<String> 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 void writeDocuments(ViewEntryCollection entries, Collection<FieldDefinition> fieldList) throws NotesException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

import com.moonshine.domino.field.FieldDefinition;
import com.moonshine.domino.field.FieldType;
import com.moonshine.domino.security.SecurityInterface;
import com.moonshine.domino.util.DominoUtils;
import com.moonshine.domino.util.ParameterException;
import com.moonshine.domino.util.PublicException;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;
import genesis.LinkProcessor;
import lotus.domino.Database;
import lotus.domino.Document;
Expand All @@ -21,7 +24,20 @@
/**
* Modify this class for custom changes to the agent.
*/
public class CustomBookmarkUpdate extends CustomBookmarkUpdateBase {
public class CustomBookmarkUpdate extends CustomBookmarkUpdateBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SecurityBuilder.ROLE_ADMINISTRATOR);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

/**
* Override the default logic to return the document after edits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import com.moonshine.domino.security.SecurityInterface;
import com.moonshine.domino.util.DominoUtils;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;
import auth.SimpleRoleSecurity;
import genesis.LinkProcessor;
import lotus.domino.Database;
import lotus.domino.DbDirectory;
Expand All @@ -26,11 +29,24 @@
/**
* Return a list of the databases on the server
*/
public class DatabaseRead extends CRUDAgentBase
public class DatabaseRead extends CRUDAgentBase implements RoleRestrictedAgent
{

protected Map<String, Collection<String> > bookmarkCache = null;

public Collection<String> 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 void runAction() {
DbDirectory directory = null;
Expand Down Expand Up @@ -192,11 +208,6 @@ protected Collection<String> getBookmarks(String server, String dbName) {
return bookmarkCache.get(key);
}

@Override
protected SecurityInterface createSecurityInterface() {
return new AllowAllSecurity(session);
}

@Override
protected boolean useJSON() {
// only support JSON for now
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
package DocumentationFormAgents;

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 DocumentationFormCreate extends DocumentationFormCreateBase {
public class DocumentationFormCreate extends DocumentationFormCreateBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
package DocumentationFormAgents;

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 DocumentationFormDelete extends DocumentationFormDeleteBase {
public class DocumentationFormDelete extends DocumentationFormDeleteBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
package DocumentationFormAgents;

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 DocumentationFormRead extends DocumentationFormReadBase {
public class DocumentationFormRead extends DocumentationFormReadBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
package DocumentationFormAgents;

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 DocumentationFormUpdate extends DocumentationFormUpdateBase {
public class DocumentationFormUpdate extends DocumentationFormUpdateBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SimpleRoleSecurity.ROLE_ALL);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@
import java.util.Collection;

import com.moonshine.domino.field.FieldDefinition;
import com.moonshine.domino.security.SecurityInterface;
import com.moonshine.domino.util.CustomizationUtils;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;

/**
* Modify this class for custom changes to the agent.
*/
public class GenesisDirectoryCreate extends GenesisDirectoryCreateBase {
public class GenesisDirectoryCreate extends GenesisDirectoryCreateBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SecurityBuilder.ROLE_ADMINISTRATOR);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
package GenesisDirectoryAgents;

import java.util.Collection;

import com.moonshine.domino.security.SecurityInterface;

import auth.RoleRestrictedAgent;
import auth.SecurityBuilder;

/**
* Modify this class for custom changes to the agent.
*/
public class GenesisDirectoryDelete extends GenesisDirectoryDeleteBase {
public class GenesisDirectoryDelete extends GenesisDirectoryDeleteBase implements RoleRestrictedAgent {

public Collection<String> getAllowedRoles() {
return SecurityBuilder.buildList(SecurityBuilder.ROLE_ADMINISTRATOR);
}

public SecurityInterface checkSecurity() {
return getSecurity();
}

@Override
protected SecurityInterface createSecurityInterface() {
return SecurityBuilder.buildInstance(agentDatabase, this, session, getLog());
}

// No modifications by default
}
Loading

0 comments on commit 9d695a6

Please sign in to comment.