kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
63 stars 63 forks source link

Null pointer exception on creating LDAP user entry #4485

Closed henning-gerhardt closed 3 years ago

henning-gerhardt commented 3 years ago

If you click on "Write LDAP configuration" after you added a new user but did forget to select the correct LDAP user group, you get a null pointer exception:

[ERROR] 2021-06-14 12:59:27,665 [http-nio-127.0.0.1-8080-exec-1] org.kitodo.production.forms.UserForm - Could not generate ldap entry
java.lang.NullPointerException: null
        at org.kitodo.production.services.data.LdapServerService.createNewUser(LdapServerService.java:160) ~[classes/:3.3]
        at org.kitodo.production.forms.UserForm.writeUserAtLdapServer(UserForm.java:489) [classes/:3.3]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
        at org.apache.el.parser.AstValue.invoke(AstValue.java:247) [tomcat8-jasper-el-8.5.54.jar:8.5.54]
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267) [tomcat8-jasper-el-8.5.54.jar:8.5.54]
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-servlet-2.4.8.Final.jar:2.4.8.Final]
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-servlet-2.4.8.Final.jar:2.4.8.Final]
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) [weld-servlet-2.4.8.Final.jar:2.4.8.Final]
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-servlet-2.4.8.Final.jar:2.4.8.Final]
        at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96) [myfaces-impl-2.3.4.jar:2.3.4]
        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74) [myfaces-impl-2.3.4.jar:2.3.4]
        at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:71) [spring-faces-2.5.1.RELEASE.jar:2.5.1.RELEASE]
        at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:64) [spring-faces-2.5.1.RELEASE.jar:2.5.1.RELEASE]
        at javax.faces.component.UICommand.broadcast(UICommand.java:120) [myfaces-api-2.3.4.jar:2.3.4]
        at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1255) [myfaces-api-2.3.4.jar:2.3.4]
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:420) [myfaces-api-2.3.4.jar:2.3.4]
        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1741) [myfaces-api-2.3.4.jar:2.3.4]
        at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:942) [myfaces-api-2.3.4.jar:2.3.4]
        at org.apache.myfaces.lifecycle.ApplyRequestValuesExecutor.execute(ApplyRequestValuesExecutor.java:42) [myfaces-impl-2.3.4.jar:2.3.4]
        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:195) [myfaces-impl-2.3.4.jar:2.3.4]
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:142) [myfaces-impl-2.3.4.jar:2.3.4]
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:204) [myfaces-api-2.3.4.jar:2.3.4]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat8-catalina-8.5.54.jar:8.5.54]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat8-catalina-8.5.54.jar:8.5.54]
...

There is no check in user frontend which is checking is a ldap group selected for this user nor is in code a check if for a user a ldap group assigned.

matthias-ronge commented 3 years ago

This is caused by the first line of LdapServerService.createNewUser(…) which is:

if (!user.getLdapGroup().getLdapServer().isReadOnly())

So either the user has no LDAP group or the LDAP group has no LDAP server.