← Back to team overview

dhis2-devs team mailing list archive

Re: Is it possible to change the passwd of the users using the API??

 

Thanks Lars,

now I am getting the following output in the tomcat log

* WARN  2015-02-11 15:53:49,477 Encoded password does not look like BCrypt
(BCry
ptPasswordEncoder.java [http-apr-8080-exec-10])

and the same error in the curl output...

On Wed, Feb 11, 2015 at 2:33 PM, Lars Helge Øverland <larshelge@xxxxxxxxx>
wrote:

> Hi Jose,
>
> try specifying "username" instead of "name" property.
>
> Lars
>
> On Wed, Feb 11, 2015 at 2:32 PM, Jose Garcia Muñoz <josemp10@xxxxxxxxx>
> wrote:
>
>>
>> ups... :) You are right, I completely forgot the Content-Type, sorry.
>>
>> Almost there. The tomcat console gives me the following message:
>>
>> * INFO  2015-02-11 14:23:26,119 'devapp' update org.hisp.dhis.user.User,
>> name: xxxx, uid: zNdlm77vil8 (AuditLogUtil.java [http-apr-8080-exec-9])
>>
>> So everything seems to be correct, but when I try to log in the system
>> with that user, still has the old passwd...
>>
>> Also, I am getting an error in the curl output. I am copying it here
>> (maybe it is not very useful):
>>
>> {color : black;}HR {color : #525D76;}--></style> </head><body><h1>Estado
>> HTTP 500 - Request processing failed; nested excepti
>> on is java.lang.NullPointerException</h1><HR size="1"
>> noshade="noshade"><p><b>type</b> Informe de Excepci├│n</p><p><b>mensaje
>> </b> <u>Request processing failed; nested exception is
>> java.lang.NullPointerException</u></p><p><b>descripci├│n</b> <u>El ser
>> vidor encontr├│ un error interno que hizo que no pudiera rellenar este
>> requerimiento.</u></p><p><b>excepci├│n</b> <pre>org.sp
>> ringframework.web.util.NestedServletException: Request processing failed;
>> nested exception is java.lang.NullPointerException
>>
>> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
>>
>> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:839)
>>         javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
>>
>> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>>
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118
>> )
>>
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:8
>> 4)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.
>> java:113)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwa
>> reRequestFilter.java:154)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java
>> :201)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
>> nProcessingFilter.java:199)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
>> nProcessingFilter.java:199)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.hisp.dhis.security.filter.CustomAuthenticationFilter.doFilter(CustomAuthenticationFilter.java:64)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter(AutomaticAccessFilter.java:115)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncMana
>> gerIntegrationFilter.java:50)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.j
>> ava:87)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
>>
>> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
>>
>> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
>>
>> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
>>
>> org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:82)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
>>
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>> </pre></p><p><b>causa raíz</b> <pre>java.lang.NullPointerException
>>
>> org.hisp.dhis.security.DefaultUsernameSaltSource.getSalt(DefaultUsernameSaltSource.java:49)
>>
>> org.hisp.dhis.security.migration.SpringSecurityMigrationPasswordManager.legacyMatches(SpringSecurityMigrationPassword
>> Manager.java:76)
>>
>> org.hisp.dhis.security.migration.SpringSecurityMigrationPasswordManager.legacyOrCurrentMatches(SpringSecurityMigratio
>> nPasswordManager.java:82)
>>
>> org.hisp.dhis.user.DefaultUserService.encodeAndSetPassword(DefaultUserService.java:557)
>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>         java.lang.reflect.Method.invoke(Method.java:606)
>>
>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.jav
>> a:99)
>>
>> org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport
>> .java:281)
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
>>
>> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
>>
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
>>         com.sun.proxy.$Proxy35.encodeAndSetPassword(Unknown Source)
>>
>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.updateObject(DefaultIdentifiableObjectImporte
>> r.java:477)
>>
>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.startImport(DefaultIdentifiableObjectImporter
>> .java:538)
>>
>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObjectLocal(DefaultIdentifiableObjectIm
>> porter.java:517)
>>
>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObject(DefaultIdentifiableObjectImporte
>> r.java:217)
>>
>> org.hisp.dhis.dxf2.metadata.importers.DefaultIdentifiableObjectImporter.importObject(DefaultIdentifiableObjectImporte
>> r.java:103)
>>
>> org.hisp.dhis.dxf2.metadata.DefaultImportService.doImport(DefaultImportService.java:278)
>>
>> org.hisp.dhis.dxf2.metadata.DefaultImportService.importObject(DefaultImportService.java:112)
>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>         java.lang.reflect.Method.invoke(Method.java:606)
>>
>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.jav
>> a:99)
>>
>> org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport
>> .java:281)
>>
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
>>
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
>>
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
>>         com.sun.proxy.$Proxy117.importObject(Unknown Source)
>>
>> org.hisp.dhis.webapi.controller.AbstractCrudController.updateObjectProperty(AbstractCrudController.java:326)
>>
>> org.hisp.dhis.webapi.controller.AbstractCrudController$$FastClassBySpringCGLIB$$92e3cd00.invoke(&lt;generated&gt;)
>>
>> org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
>>
>> org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
>>
>> org.hisp.dhis.webapi.controller.user.UserController$$EnhancerBySpringCGLIB$$86713dbc.updateObjectProperty(&lt;generat
>> ed&gt;)
>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>         java.lang.reflect.Method.invoke(Method.java:606)
>>
>> org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
>>
>> org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
>>
>> org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableH
>> andlerMethod.java:110)
>>
>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingH
>> andlerAdapter.java:777)
>>
>> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandl
>> erAdapter.java:706)
>>
>> org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
>>
>> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
>>
>> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
>>
>> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
>>
>> org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:839)
>>         javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
>>
>> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
>>
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118
>> )
>>
>> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:8
>> 4)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.
>> java:113)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwa
>> reRequestFilter.java:154)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java
>> :201)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
>> nProcessingFilter.java:199)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticatio
>> nProcessingFilter.java:199)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.hisp.dhis.security.filter.CustomAuthenticationFilter.doFilter(CustomAuthenticationFilter.java:64)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter(AutomaticAccessFilter.java:115)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncMana
>> gerIntegrationFilter.java:50)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.j
>> ava:87)
>>
>> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
>>
>> org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
>>
>> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
>>
>> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
>>
>> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
>>
>> org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:82)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
>>
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
>>
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
>>
>> On Wed, Feb 11, 2015 at 2:15 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>> wrote:
>>
>>> You need to include the content-type of what you are sending.
>>>
>>> -H "Content-Type: application/json"
>>>
>>> --
>>> Morten
>>>
>>> On Wed, Feb 11, 2015 at 8:08 PM, Jose Garcia Muñoz <josemp10@xxxxxxxxx>
>>> wrote:
>>>
>>>>
>>>> sure,
>>>>
>>>>
>>>> curl.exe -X PATCH -d @c:\file.json -u myuser:mypasswd "
>>>> http://localhost:8080/dhis/api/users/zNdlm77vil8/userCredentials";
>>>>
>>>> On Wed, Feb 11, 2015 at 2:01 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx
>>>> > wrote:
>>>>
>>>>> Can you give me the full cURL command you are using for this?
>>>>> including headers etc
>>>>>
>>>>> --
>>>>> Morten
>>>>>
>>>>> On Wed, Feb 11, 2015 at 7:07 PM, Jose Garcia Muñoz <josemp10@xxxxxxxxx
>>>>> > wrote:
>>>>>
>>>>>>
>>>>>> Thanks Lars, Morten,
>>>>>>
>>>>>> Now the payload I am using is:
>>>>>>
>>>>>> {
>>>>>>  "userCredentials":
>>>>>>  {"password": "new_passwd",
>>>>>>   "id": "AMuabF1Lrct",
>>>>>>   "name": "user_name",
>>>>>>   "code": "user_code",
>>>>>>   "created": "2014-11-27T18:24:05.888+0000",  (Do I need this?)
>>>>>>   "lastUpdated": "2015-02-11T11:57:58.116+0000"}  (Do I need this?)
>>>>>> }
>>>>>>
>>>>>> But still getting the same message: "Unknown payload format".
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Feb 11, 2015 at 10:05 AM, Lars Helge Øverland <
>>>>>> larshelge@xxxxxxxxx> wrote:
>>>>>>
>>>>>>> An example can be seen under "user account invitations" in web api
>>>>>>> docs:
>>>>>>>
>>>>>>>
>>>>>>> https://www.dhis2.org/doc/snapshot/en/developer/html/ch01s27.html#d5e3604
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Follow ups

References