Command | Description |
---|
addSubject(id, type, name) | Add local subject to registry. You need the jdbc source for this to work. In 2.4.0.api.41+ patch, this will also create the id, name, description, and loginid attribute (unless grouper.properties create.attributes.when.creating.registry.subjects is false) |
RegistrySubject.addOrUpdate(grouperSession, id, type, name, nameAttributeValue, loginid, description, email) | In 2.4.0.api.41+ patch, add a registry subject like addSubject, but specify the attribute values of name, loginid, etc |
RegistrySubject.find(id, errorOnNotFound) | In 2.4.0.api.41+ patch, get a registry subject |
registrySubject.delete(grouperSession) | In 2.4.0.api.41+ patch, delete a registry subject |
RegistrySubjectAttribute.addOrUpdate(subjectId, attributeName, attributeValue) | In 2.4.0.api.41+ patch, add or update a registry subject attribute |
registrySubjectAttribute.delete() | In 2.4.0.api.41+ patch, delete an attribute value |
findSubject(id) | Find a subject |
findSubject(id, type) | Find a subject |
findSubject(id, type, source) | Find a subject |
getSources() | Find all Subject sources |
grouperSession = GrouperSession.startRootSession(); SubjectFinder.findAll(searchString, source); | Find all subjects in a source by search string |
grouperSession = GrouperSession.startRootSession(); SubjectFinder.findByIdAndSource(id, source, exceptionIfNull); SubjectFinder.findByIdAndSource("12345", "jdbc", true); | Find a subject by id in a certain source |
grouperSession = GrouperSession.startRootSession(); SubjectFinder.findByIdentifierAndSource(identifier, source, exceptionIfNull); SubjectFinder.findByIdentifierAndSource("jsmith", "jdbc", true); | Find a subject by identifier in a certain source |
grouperSession = GrouperSession.startRootSession(); SubjectFinder.findByIdOrIdentifierAndSource(idOrIdentifier, source, exceptionIfNull); SubjectFinder.findByIdOrIdentifierAndSource("jsmith", "jdbc", true); | Find a subject by id or identifier in a certain source |
add test subjects to registry (e.g. test.subject.0 through 9) | grouperSession = GrouperSession.startRootSession(); new RegistryReset()._addSubjects(); |
Edit subject (in this case name) | RegistrySubject registrySubject = GrouperDAOFactory.getFactory().getRegistrySubject().find("user1a", "person", true); registrySubject.setName("New name"); HibernateSession.byObjectStatic().update(registrySubject); |
add a subject application principal with attributes (GSH) |
Code Block |
---|
String principal = "someApp";
String email = null;
GrouperSession grouperSession = GrouperSession.startRootSession();
addSubject(principal, "application", principal);
HibernateSession.bySqlStatic().executeSql("insert into subjectattribute (subjectId, name, value, searchValue) values (?, ?, ?, ?)", GrouperUtil.toListObject(new Object[]{principal, "description", principal, principal.toLowerCase()}));
if (email != null){ HibernateSession.bySqlStatic().executeSql("insert into subjectattribute (subjectId, name, value, searchValue) values (?, ?, ?, ?)", GrouperUtil.toListObject(new Object[]{principal, "email", email, email.toLowerCase()}));}
HibernateSession.bySqlStatic().executeSql("insert into subjectattribute (subjectId, name, value, searchValue) values (?, ?, ?, ?)", GrouperUtil.toListObject(new Object[]{principal, "loginid", principal, principal}));
HibernateSession.bySqlStatic().executeSql("insert into subjectattribute (subjectId, name, value, searchValue) values (?, ?, ?, ?)", GrouperUtil.toListObject(new Object[]{principal, "name", principal, principal}));
|
|
remove a subject with attributes (GSH) |
Code Block |
---|
String principal = "someApp";
String email = null;
GrouperSession grouperSession = GrouperSession.startRootSession();
HibernateSession.bySqlStatic().executeSql("delete from subjectattribute where subjectId = ?", GrouperUtil.toListObject(new Object[]{principal}));
HibernateSession.bySqlStatic().executeSql("delete from subject where subjectId = ?", GrouperUtil.toListObject(new Object[]{principal})); |
|