use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class ImportMemberOverviewIdentitiesController method loadModelByIdentities.
private void loadModelByIdentities(List<Identity> keys) {
notfounds = new ArrayList<>();
Set<Identity> okSet = new HashSet<>();
SecurityGroup anonymousSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
List<Identity> anonymousUsers = securityManager.getIdentitiesOfSecurityGroup(anonymousSecGroup);
for (Identity ident : keys) {
if (ident == null || anonymousUsers.contains(ident)) {
// ignore
} else if (!okSet.contains(ident)) {
okSet.add(ident);
}
}
oks = new ArrayList<>(okSet);
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class PoolDAO method createPool.
public PoolImpl createPool(Identity owner, String name, boolean publicPool) {
PoolImpl pool = new PoolImpl();
pool.setCreationDate(new Date());
pool.setLastModified(new Date());
pool.setName(name);
pool.setPublicPool(publicPool);
SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
pool.setOwnerGroup(ownerGroup);
dbInstance.getCurrentEntityManager().persist(pool);
if (owner != null) {
securityManager.addIdentityToSecurityGroup(owner, ownerGroup);
}
return pool;
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class MembersOverviewIdentitiesController method loadModel.
private void loadModel(String inp) {
oks = new ArrayList<Identity>();
notfounds = new ArrayList<String>();
SecurityGroup anonymousSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ANONYMOUS);
List<String> identList = new ArrayList<String>();
String[] lines = inp.split("\r?\n");
for (int i = 0; i < lines.length; i++) {
String username = lines[i].trim();
if (username.length() > 0) {
identList.add(username);
}
}
// search by institutionalUserIdentifier, case sensitive
List<Identity> institutIdentities = securityManager.findIdentitiesByNumber(identList);
for (Identity identity : institutIdentities) {
String userIdent = identity.getUser().getProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, null);
if (userIdent != null) {
identList.remove(userIdent);
}
if (!PersistenceHelper.containsPersistable(oks, identity) && !securityManager.isIdentityInSecurityGroup(identity, anonymousSecGroup)) {
oks.add(identity);
}
}
// make a lowercase copy of identList for processing username and email
List<String> identListLowercase = new ArrayList<String>(identList.size());
for (String ident : identList) {
identListLowercase.add(ident.toLowerCase());
}
// search by names, must be lower case
List<Identity> identities = securityManager.findIdentitiesByNameCaseInsensitive(identListLowercase);
for (Identity identity : identities) {
identListLowercase.remove(identity.getName().toLowerCase());
if (!PersistenceHelper.containsPersistable(oks, identity) && !securityManager.isIdentityInSecurityGroup(identity, anonymousSecGroup)) {
oks.add(identity);
}
}
// search by email, case insensitive
List<Identity> mailIdentities = userManager.findIdentitiesByEmail(identListLowercase);
for (Identity identity : mailIdentities) {
String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
if (email != null) {
identListLowercase.remove(email.toLowerCase());
}
String institutEmail = identity.getUser().getProperty(UserConstants.INSTITUTIONALEMAIL, null);
if (institutEmail != null) {
identListLowercase.remove(institutEmail.toLowerCase());
}
if (!PersistenceHelper.containsPersistable(oks, identity) && !securityManager.isIdentityInSecurityGroup(identity, anonymousSecGroup)) {
oks.add(identity);
}
}
notfounds.addAll(identListLowercase);
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class QuestionItemDAO method removeAuthors.
public void removeAuthors(List<Identity> authors, QuestionItemShort item) {
QuestionItemImpl lockedItem = loadForUpdate(item);
SecurityGroup secGroup = lockedItem.getOwnerGroup();
for (Identity author : authors) {
if (securityManager.isIdentityInSecurityGroup(author, secGroup)) {
securityManager.removeIdentityFromSecurityGroup(author, secGroup);
}
}
dbInstance.commit();
}
use of org.olat.basesecurity.SecurityGroup in project OpenOLAT by OpenOLAT.
the class QuestionItemDAO method addAuthors.
public void addAuthors(List<Identity> authors, QuestionItemShort item) {
QuestionItemImpl lockedItem = loadForUpdate(item);
SecurityGroup secGroup = lockedItem.getOwnerGroup();
for (Identity author : authors) {
if (!securityManager.isIdentityInSecurityGroup(author, secGroup)) {
securityManager.addIdentityToSecurityGroup(author, secGroup);
}
}
dbInstance.commit();
}
Aggregations