...
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
This topic is discussed in the "Grouper API - Part 2" training video. |
GrouperShell (gsh)
gsh is a command line shell for administering and interacting with the Grouper API. See architectural diagram. It can be used in both a batch and interactive manner. For Grouper 2.3.0 patch 72+, it is built on GroovyShell. For older versions of Grouper, it is built on Java BeanShell. The legacy BeanShell version is now deprecated, but you can switch back to it by using one of the options:
- Setting gsh.useLegacy = true in grouper.properties.
- Using a command line argument (gsh.sh -forceLegacyGsh)
GrouperShell is for Grouper admins. End users can script with the grouper client command line utility
GSH operations
NOTE: Some classes were added a later 2.5.x releases. Not all are documented as to when they were initially added.
Category | Subtype | Action | Class |
---|---|---|---|
Attestation | Folders | insert / update / delete | AttestationStemSave |
Groups | insert / update / delete | AttestationGroupSave | |
Attribute assignment | Attribute assignment | insert / update / delete | AttributeAssignToAssignmentSave (2.5.48+) |
Folders | insert / update / delete | AttributeAssignToStemSave | |
Group | insert / update / delete | AttributeAssignToGroupSave | |
Attribute definition | insert / update / delete | AttributeDefSave | |
Attribute name | insert / update / delete | AttributeDefNameSave | |
Attribute value | insert / update / delete | AttributeAssignValueSave | |
Composite | insert /update / delete | CompositeSave | |
finder | CompositeFinder | ||
Email SMTP | GrouperEmail | ||
Gc db access | gc db access | GcDbAccess | |
Grouper session | GrouperSession | ||
Group | insert / update / delete | GroupSave | |
finder | GroupFinder | ||
copy | GroupCopy | ||
gsh | gsh template exec | GshTemplateExec | |
Http | GrouperHttpClient | ||
Ldap | ldap session utils | LdapSessionUtils | |
Member | finder | MemberFinder | |
Membership | insert / update / delete | MembershipSave | |
finder | MembershipFinder | ||
Password | insert / update / delete | GrouperPasswordSave | |
Privilege inheritance | Attribute definitions | insert / update / delete | PrivilegeAttributeDefInheritanceSave |
Folders | insert / update / delete | PrivilegeStemInheritanceSave | |
Groups | insert / update / delete | PrivilegeGroupInheritanceSave | |
Provisionable | Folders | finder | ProvisionableStemFinder |
insert / update / delete | ProvisionableStemSave | ||
Groups | finder | ProvisionableGroupFinder | |
insert / update / delete | ProvisionableGroupSave | ||
Stem | insert/update/delete | StemSave | |
finder | StemFinder | ||
copy | StemCopy | ||
Subject | finder | SubjectFinder | |
Sync data to SQL table | GcTableSyncFromData | ||
Types | Folders | finder | GdgTypeStemFinder |
insert / update / delete | GdgTypeStemSave | ||
Groups | finder | GdgTypeGroupFinder | |
insert / update / delete | GdgTypeGroupSave |
GrouperShell (gsh)
gsh is a command line shell for administering and interacting with the Grouper API. See architectural diagram. It can be used in both a batch and interactive manner. For Grouper 2.3.0 patch 72+, it is built on GroovyShell. For older versions of Grouper, it is built on Java BeanShell. The legacy BeanShell version is now deprecated, but you can switch back to it by using one of the options:
- Setting gsh.useLegacy = true in grouper.properties.
- Using a command line argument (gsh.sh -forceLegacyGsh)
GrouperShell is for Grouper admins. End users can script with the grouper client command line utility
JEXL hints and tricks
Hints and tricks
Escape things in Escape things in groovysh with single backslash. e.g.
...
Code Block |
---|
FROM Object[] row = new Object[] {emailFromOutsystems, pennkeyPerhaps}; TO Object[] row = new Object[2]; row[0] = emailFromOutsystems; row[1] = pennkeyPerhaps; |
API Compability
Reset the shell after an error:
:c
Escape dollars, e.g. "${something}"
Code Block |
---|
'$' + "{something}" |
Externalized text
Code Block |
---|
if you add to externalized text (config in ui), just make a key, e.g. mySchoolEmailKey, then refer to it like this
import edu.internet2.middleware.grouper.cfg.text.GrouperTextContainer;
String template = GrouperTextContainer.textOrNull("mySchoolEmailKey"); |
API Compability
gsh is now a core gsh is now a core part of the Grouper API and so is always compatible with the current release.
...
For more information, see Bad Membership Finder Utility
Command | Description |
---|---|
findBadMemberships() | complete findBadMemberships run |
Grouper export to GSH script
See page: Grouper export to a GSH script
XML legacy
Command | Description |
---|---|
xmlFromFile(filename) | Load registry from XML in file |
xmlFromString(xml) | Load registry from XML in string |
xmlFromURL(url) | Load registry from XML at URL |
xmlToFile(filename) | Exports registry to file |
xmlToString() | Exports registry to string. |
xmlUpdateFromFile(filename) | Update registry from XML in file |
xmlUpdateFromString(xml) | Update registry from XML in string |
xmlUpdateFromURL(url) | Update registry from XML at URL |
...
Code Block |
---|
GrouperSession.startRootSession(); edu.internet2.middleware.grouper.app.loader.GrouperLoader.scheduleJobs(); |
Loader
Enable a job (OTHER_JOB_grouperLoaderJexlScriptFullSync is the job name)
Code Block |
---|
edu.internet2.middleware.grouper.app.loader.GrouperLoader.schedulerFactory().getScheduler().resumeJob(new org.quartz.JobKey("OTHER_JOB_grouperLoaderJexlScriptFullSync")); |
Loader
Above, it describes how you can kick off the loader in daemon mode. You can also execute one job with:
...
You can also encrypt the password outside of GSH:
No Format |
---|
C:\mchyzer\isc\dev\grouper-qs-1.2.0\grouper>javajava -jarcp lib\morphString.jar Enter the location of morphString.properties: conf/morphString.properties"lib/*:classes" edu.internet2.middleware.morphString.Encrypt Type the string to encrypt (note: pasting might echo it back): The encrypted string is: ca8a15be4ad0fb45c6f1b3ca0cfd9c9e |
...
See the WIKI for running the Grouper Report manually
External systems
Test all external systems
Code Block |
---|
import java.util.List;
import edu.internet2.middleware.grouper.app.externalSystem.GrouperExternalSystem;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateOutput;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2input;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2output;
import edu.internet2.middleware.grouper.util.GrouperUtil;
public class Test77externalSystemTest extends GshTemplateV2 {
@Override
public void gshRunLogic(GshTemplateV2input gshTemplateV2input, GshTemplateV2output gshTemplateV2output) {
GshTemplateOutput gsh_builtin_gshTemplateOutput = gshTemplateV2output.getGsh_builtin_gshTemplateOutput();
gsh_builtin_gshTemplateOutput.assignRedirectToGrouperOperation("NONE");
List<GrouperExternalSystem> grouperExternalSystems = GrouperExternalSystem.retrieveAllGrouperExternalSystems();
for (GrouperExternalSystem grouperExternalSystem : grouperExternalSystems) {
try {
List<String> errors = grouperExternalSystem.test();
if (GrouperUtil.length(errors) == 0) {
gsh_builtin_gshTemplateOutput.addOutputLine("Success: extenal system '" + grouperExternalSystem.getConfigId() + "' passed its test");
continue;
}
for (String error : errors) {
gsh_builtin_gshTemplateOutput.addOutputLine("error", "Error: extenal system '" + grouperExternalSystem.getConfigId() + "': " + error);
}
} catch (Exception e) {
gsh_builtin_gshTemplateOutput.addOutputLine("error", "Error: extenal system '" + grouperExternalSystem.getConfigId() + "' failed: " + e.getMessage());
}
}
}
}
|
Create a script from SQL
Here is an example to remove access from someone... run a SQL to generate a GSH script, e.g. in oracle:
...