cancel
Showing results for 
Search instead for 
Did you mean: 

Getting password for alfresco user.

g_rathod
Star Contributor
Star Contributor
Hi Friends,

Actually I am trying to create forgot password function.
But I could not getting password for the current user.

I can check existed user through following code :


boolean exist = personService.personExists(this.userName);

but actually I am not getting how to get the password for that given user to send that to email ?
any idea regarding this ?

Once I got that password then I can send it to email.

Help me.
4 REPLIES 4

fhomasp
Champ in-the-making
Champ in-the-making
Take a look at this:

http://jsourcery.com/api/sourceforge/alfresco/2.0.0/org/alfresco/repo/security/authentication/Authen...

Passwords are based on AcegiSecurity code.  I never really tried to get the password for a user and I can't really imagine a developer needing to really access it.  It might be a better idea to reset the password to a defined variation on default password policy and email that to the user.

I could be mistaken but aren't passwords MD5-encrypted when they get created?

g_rathod
Star Contributor
Star Contributor
HI fhomasp,

Thanks for your reply, since we do same idea to reset password. but we are stuck at another problem.
We are getting user's email through nodeService but we can't authenticate internally. Access denied is there.

Since we need to send password to specific email id -user we got. So we are using nodeService and that is we need
authentication internally. How do we achive it ? any idea ?

see the below



15:20:33,793 ERROR [[localhost].[/alfresco].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception

net.sf.acegisecurity.AccessDeniedException: Access Denied

        at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:299)

        at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:196)

        at net.sf.acegisecurity.afterinvocation.AfterInvocationProviderManager.decide(AfterInvocationProviderManager.java:107)

        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.afterInvocation(AbstractSecurityInterceptor.java:329)

        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:82)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)

        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)

        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:241)

        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)

        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)

        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)

        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)

        at $Proxy48.getPerson(Unknown Source)

        at org.fortify.web.bean.user.FortifyForgotPassword.forgotpwd(FortifyForgotPassword.java:172)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:585)

        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)

        at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)

        at javax.faces.component.UICommand.broadcast(UICommand.java:109)

        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)

        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)

        at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)

        at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)

        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)

        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)

        at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)

        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)

        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)

        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)

        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)

        at java.lang.Thread.run(Thread.java:595)




again thanks,
F1

g_rathod
Star Contributor
Star Contributor
Hi ,

Actually we are using following code for getting authentication :


public void forgotpwd() {

            String sTempUserName = this.userName;

            getAuthenticationService().authenticateAsGuest();

            if (this.userName != null && this.userName.length() != 0) {

                 System.out.println("Username got :" + sTempUserName);

                  if (getPersonService().personExists(sTempUserName)) {

                        NodeRef person = getPersonService().getPerson(sTempUserName);

                        String address = (String) nodeService.getProperty(person,

                                    ContentModel.PROP_EMAIL);

                        if (address != null && address.length() != 0) {

                              // recipients.add(address);

                              System.out.println("Email Address is :" + address);

                        }

                  }

            }

      }





Here we want to get authenticated by any user or by guest ( I mean anyway ) , and then want to send email to specific user email.


if we are doing any mistake let us know.

Thanks,

fhomasp
Champ in-the-making
Champ in-the-making
Hey,

My guess is that a guest status will not be able to access sensitive info so you'll have to authenticate as an admin user.  You might be better off removing the line:
"getAuthenticationService().authenticateAsGuest();"


I also thought you'd need a transaction to access properties from a user using a noderef.  Or at least I have not been able to do that without one.
I'm using this code to get a first and last name property from a user.  If I didn't use a transaction I get an exception telling me that the transaction is not in an alive state.

public void setUp(){
  
      FacesContext context = FacesContext.getCurrentInstance();
      ServiceRegistry serviceRegistry = Repository.getServiceRegistry(context);
      AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
        String username=authenticationService.getCurrentUserName();
        this.username=username;
        System.out.println(username+" \t—> from AuthCheck!!!!!!!!!");

        UserTransaction tx = null;
        try
        {
           //Start the transaction.  Why this is required for such a simple operation is beyond me.
           TransactionService txs = (TransactionService) FacesContextUtils.getRequiredWebApplicationContext(context).getBean("transactionComponent");
           tx = txs.getUserTransaction();
           tx.begin();
           
              PersonService personService = (PersonService)FacesContextUtils.getRequiredWebApplicationContext(context).getBean("personService");
              NodeService nodeService = (NodeService)FacesContextUtils.getRequiredWebApplicationContext(context).getBean("nodeService");
              PersonService ps = serviceRegistry.getPersonService();
                                                
             System.out.println("\t"+ ps.getUserIdentifier(username));
             NodeRef nr = personService.getPerson(username);
         
       
             String firstName = (String)nodeService.getProperty(nr, ContentModel.PROP_FIRSTNAME);
             String lastName = (String)nodeService.getProperty(nr, ContentModel.PROP_LASTNAME);
      
             System.out.println(firstName +" " +lastName+ " From the Repo!!!!!!!!!!!");
             tx.commit();
            
        }catch (Exception err)
        {
            try { if (tx != null) {tx.rollback();}
            }
            catch (Exception tex) {tex.printStackTrace();}
            err.printStackTrace();
         }
         finally {
            //Normally I'd end the transaction, but it doesn't seem to feature such a method.
         }
   }