cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic Login In alfresco

pankajnegi
Champ in-the-making
Champ in-the-making
Hello,
How to login in alfresco share or alfresco explorer automatically ,
like whenever any one goes to the url.

or can we do alfresco always logged in for a particular user.

Issue: In my case I want to use alfresco for repository.so through other application I want to access the link of alfresco to upload the document in a particular folder,for that I wants alfresco to be logged in automatically

I don't want to use SSO , because repository space is common.


Please suggest me

Thanks
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
If you want to use SSO then it will not exactly the same case.
You will be fetching the user information from the request header and then need to authenticate user in filter inside alfresco.

pankajnegi
Champ in-the-making
Champ in-the-making
I mean to say that whenever we hit a url (http://localhost:8080/alfresco/service/demo/webscript) it should login the user

it goes through java code and start the user session in browser

package autoLogin;

import java.io.IOException;


import org.alfresco.webservice.util.AuthenticationDetails;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.WebServiceFactory;
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;


public class AutoLogin extends AbstractWebScript{
    boolean logged = false;
   private static Logger log  = Logger.getLogger("AutoLogin");
    public void execute(WebScriptRequest req, WebScriptResponse res)
              throws IOException
    {
      
      
       JSONObject obj = new JSONObject();
      
      
       WebServiceFactory.setEndpointAddress("http://localhost:8080/alfresco/api");
      
       try
        {
         
      
       AuthenticationUtils.startSession("admin", "admin",10000);
      // AuthenticationUtils.startSession("", "","" );
       AuthenticationDetails authenticationDetails = AuthenticationUtils.getAuthenticationDetails();
       if(AuthenticationUtils.isCurrentTicketTimedOut())
       {
          obj.put("Already Logged in", "");
          obj.put("User:"+authenticationDetails.getUserName()+"Session ID:"+authenticationDetails.getSessionId()+"Ticket :"+authenticationDetails.getTicket()+"Time Out Interval:"+authenticationDetails.getTimeoutInterval(),"OK");
       }
       else{
          obj.put("Not Logged in", "");
          if (authenticationDetails != null) {
          logged = true;
             try {
                 obj.put("User:"+authenticationDetails.getUserName()+"Session ID:"+authenticationDetails.getSessionId()+"Ticket :"+authenticationDetails.getTicket()+"Time Out Interval:"+authenticationDetails.getTimeoutInterval(),"OK");
             } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
               }
            //log.info("isLoggedIn, logged in user : [" + userName + "]");
          } else {
         //log.info("isLoggedIn, Not logged in");
          try {
              obj.put("isLoggedIn, Not logged in","no");
         } catch (JSONException e) {
            // TODO Auto-generated catch block
         e.printStackTrace();
          }
         }
       }
             
             
          // build a json object
         
        
          // put some data on it
          obj.put("field1", "data1");
        
          // build a JSON string and send it back
          String jsonString = obj.toString();
          res.getWriter().write(jsonString);
           }
           catch(JSONException e)
           {
           throw new WebScriptException("Unable to serialize JSON");
           }
      
      

    }
   
   
   
    
}


and start the session for other like for repository

I did this way but I am not able to start the session for the browser ,

how can we do this .Please suggest


Thanks

pankajnegi
Champ in-the-making
Champ in-the-making
Thanks mitpatoliya ,

In the guest home,We can only view content which is uploded by other users in the guest home.
How to upload content in user space by default user credentials
(lets say if url is from valid source or localhost then read user credentials from file only for one user)

I mean if I dont want to use alfresco repository on user basis ,like all the users form some other websites uses the same repository user(Admin) Home.
which should be done without sso.


how to do this
Please help