Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
c5dce2bb
Commit
c5dce2bb
authored
Oct 22, 2015
by
michael.simon
Browse files
fire group event after group change
parent
9a691347
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwreg-jpa/src/main/java/edu/kit/scc/webreg/dao/jpa/as/JpaAttributeSourceGroupDao.java
View file @
c5dce2bb
...
...
@@ -15,11 +15,6 @@ import java.util.List;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.inject.Named
;
import
javax.persistence.NoResultException
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Join
;
import
javax.persistence.criteria.Root
;
import
edu.kit.scc.webreg.dao.as.AttributeSourceGroupDao
;
import
edu.kit.scc.webreg.dao.jpa.JpaBaseDao
;
...
...
@@ -31,21 +26,15 @@ import edu.kit.scc.webreg.entity.as.AttributeSourceGroupEntity;
@ApplicationScoped
public
class
JpaAttributeSourceGroupDao
extends
JpaBaseDao
<
AttributeSourceGroupEntity
,
Long
>
implements
AttributeSourceGroupDao
{
@SuppressWarnings
(
"unchecked"
)
@Override
public
List
<
AttributeSourceGroupEntity
>
findByUserAndAS
(
UserEntity
user
,
AttributeSourceEntity
attributeSource
)
{
CriteriaBuilder
builder
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
AttributeSourceGroupEntity
>
criteria
=
builder
.
createQuery
(
AttributeSourceGroupEntity
.
class
);
Root
<
UserEntity
>
userRoot
=
criteria
.
from
(
UserEntity
.
class
);
Root
<
AttributeSourceGroupEntity
>
asgRoot
=
criteria
.
from
(
AttributeSourceGroupEntity
.
class
);
criteria
.
where
(
builder
.
and
(
builder
.
equal
(
userRoot
.
get
(
"id"
),
user
.
getId
()),
builder
.
equal
(
asgRoot
.
get
(
"id"
),
attributeSource
.
getId
())
));
Join
<
UserEntity
,
AttributeSourceGroupEntity
>
users
=
userRoot
.
join
(
"groups"
);
CriteriaQuery
<
AttributeSourceGroupEntity
>
cq
=
criteria
.
select
(
users
);
TypedQuery
<
AttributeSourceGroupEntity
>
query
=
em
.
createQuery
(
cq
);
return
query
.
getResultList
();
return
(
List
<
AttributeSourceGroupEntity
>)
em
.
createQuery
(
"select e from AttributeSourceGroupEntity e left join e.users as ug"
+
" where ug.user = :user"
+
" and e.attributeSource = :attributeSource"
)
.
setParameter
(
"user"
,
user
)
.
setParameter
(
"attributeSource"
,
attributeSource
)
.
getResultList
();
}
@Override
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/as/AbstractAttributeSourceWorkflow.java
View file @
c5dce2bb
...
...
@@ -8,6 +8,9 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
javax.naming.InitialContext
;
import
javax.naming.NamingException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -16,6 +19,8 @@ import edu.kit.scc.webreg.dao.GroupDao;
import
edu.kit.scc.webreg.dao.as.ASUserAttrValueDao
;
import
edu.kit.scc.webreg.dao.as.AttributeSourceGroupDao
;
import
edu.kit.scc.webreg.entity.AuditStatus
;
import
edu.kit.scc.webreg.entity.EventType
;
import
edu.kit.scc.webreg.entity.GroupEntity
;
import
edu.kit.scc.webreg.entity.ServiceEntity
;
import
edu.kit.scc.webreg.entity.UserEntity
;
import
edu.kit.scc.webreg.entity.as.ASUserAttrEntity
;
...
...
@@ -24,6 +29,9 @@ import edu.kit.scc.webreg.entity.as.ASUserAttrValueStringEntity;
import
edu.kit.scc.webreg.entity.as.AttributeSourceEntity
;
import
edu.kit.scc.webreg.entity.as.AttributeSourceGroupEntity
;
import
edu.kit.scc.webreg.entity.as.AttributeSourceServiceEntity
;
import
edu.kit.scc.webreg.event.EventSubmitter
;
import
edu.kit.scc.webreg.event.MultipleGroupEvent
;
import
edu.kit.scc.webreg.exc.EventSubmitException
;
import
edu.kit.scc.webreg.exc.PropertyReaderException
;
import
edu.kit.scc.webreg.exc.UserUpdateException
;
import
edu.kit.scc.webreg.service.reg.ldap.PropertyReader
;
...
...
@@ -183,7 +191,8 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
private
Boolean
processGroups
(
ASUserAttrValueStringEntity
asValue
)
{
Boolean
changed
=
false
;
HashSet
<
GroupEntity
>
allChangedGroups
=
new
HashSet
<
GroupEntity
>();
UserEntity
user
=
asUserAttr
.
getUser
();
AttributeSourceEntity
attributeSource
=
asUserAttr
.
getAttributeSource
();
List
<
AttributeSourceGroupEntity
>
oldGroupList
=
attributeSourceGroupDao
.
findByUserAndAS
(
asUserAttr
.
getUser
(),
attributeSource
);
...
...
@@ -192,6 +201,7 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
//delete all groups for this user
for
(
AttributeSourceGroupEntity
group
:
oldGroupList
)
{
groupDao
.
removeUserGromGroup
(
user
,
group
);
allChangedGroups
.
add
(
group
);
}
changed
=
true
;
}
...
...
@@ -210,6 +220,7 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
for
(
String
s
:
groupsToRemove
)
{
logger
.
debug
(
"Removeing {} grom group {}"
,
user
.
getEppn
(),
s
);
groupDao
.
removeUserGromGroup
(
user
,
oldGroupsMap
.
get
(
s
));
allChangedGroups
.
add
(
oldGroupsMap
.
get
(
s
));
}
Set
<
String
>
groupsToAdd
=
new
HashSet
<
String
>(
newGroups
);
...
...
@@ -231,9 +242,23 @@ public abstract class AbstractAttributeSourceWorkflow implements AttributeSource
logger
.
debug
(
"Adding {} to group {}"
,
user
.
getEppn
(),
s
);
groupDao
.
addUserToGroup
(
user
,
group
);
allChangedGroups
.
add
(
group
);
}
}
if
(
allChangedGroups
.
size
()
>
0
)
{
EventSubmitter
eventSubmitter
;
try
{
InitialContext
ic
=
new
InitialContext
();
eventSubmitter
=
(
EventSubmitter
)
ic
.
lookup
(
"global/bwreg/bwreg-service/EventSubmitterImpl!edu.kit.scc.webreg.event.EventSubmitter"
);
MultipleGroupEvent
mge
=
new
MultipleGroupEvent
(
allChangedGroups
);
eventSubmitter
.
submit
(
mge
,
EventType
.
GROUP_UPDATE
,
auditor
.
getActualExecutor
());
}
catch
(
NamingException
e
)
{
logger
.
warn
(
"Exeption"
,
e
);
}
catch
(
EventSubmitException
e
)
{
logger
.
warn
(
"Exeption"
,
e
);
}
}
return
changed
;
}
}
bwreg-service/src/main/java/edu/kit/scc/webreg/service/reg/ldap/AbstractLdapRegisterWorkflow.java
View file @
c5dce2bb
...
...
@@ -250,8 +250,8 @@ public abstract class AbstractLdapRegisterWorkflow
LdapWorker
ldapWorker
=
new
LdapWorker
(
prop
,
auditor
,
isSambaEnabled
());
ldapWorker
.
reconUser
(
cn
,
sn
,
givenName
,
mail
,
localUid
,
uidNumber
,
gidNumber
,
homeDir
,
description
);
if
(
(
prop
.
hasProp
(
"pw_location"
)
&&
(
prop
.
readPropOrNull
(
"pw_location"
).
equalsIgnoreCase
(
"registry"
))
||
prop
.
readPropOrNull
(
"pw_location"
).
equalsIgnoreCase
(
"both"
))
if
(
prop
.
hasProp
(
"pw_location"
)
&&
(
(
prop
.
readPropOrNull
(
"pw_location"
).
equalsIgnoreCase
(
"registry"
))
||
prop
.
readPropOrNull
(
"pw_location"
).
equalsIgnoreCase
(
"both"
))
&&
(!
registry
.
getRegistryValues
().
containsKey
(
"userPassword"
)))
{
List
<
String
>
pwList
=
ldapWorker
.
getPasswords
(
localUid
);
if
(
pwList
.
size
()
>
0
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment