As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
String username = "guest"; String password = "guest"; /** AuthenticationService bean reference */ AuthenticationService authenticationService = null; /** NodeService bean reference */ NodeService nodeService = null; //ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); //ApplicationContext ctx=FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance()); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx .getBean(ServiceRegistry.SERVICE_REGISTRY); // get individual, required services nodeService = (NodeService)serviceRegistry.getNodeService(); authenticationService=(AuthenticationService)ctx.getBean("authenticationService"); try { String fromsysid = (String) request.getParameter("fromsysid"); System.out.println("fromsysid=" + fromsysid); authenticationService .authenticate(username, password.toCharArray()); // setup User object and Home space ID User user = new User(username, authenticationService .getCurrentTicket(), authenticationService .getPersonNodeRef(Repository.getStoreRef(), username)); String homeSpaceId = null; if (fromsysid == null || fromsysid.trim().equals("")) { homeSpaceId = (String) nodeService.getProperty( authenticationService.getPersonNodeRef(Repository .getStoreRef(), username), ContentModel.PROP_HOMEFOLDER); NodeRef homeSpaceRef = new NodeRef(Repository.getStoreRef(), homeSpaceId); // check that the home space node exists - else user cannot login if (nodeService.exists(homeSpaceRef) == false) { throw new InvalidNodeRefException(homeSpaceRef); } } else { //get homespaceid from config-file homeSpaceId = ""; Properties pro = new Properties(); //InputStream in = new BufferedInputStream(new FileInputStream(file)); InputStream in = getClass().getResourceAsStream( "/subsysid.properties"); try { pro.load(in); homeSpaceId = pro.getProperty(fromsysid.trim()).trim(); if (homeSpaceId == null || homeSpaceId.trim().equals("")) { homeSpaceId = pro.getProperty("default").trim(); } } catch (IOException ex) { } } System.out.println(homeSpaceId); user.setHomeSpaceId(homeSpaceId); // put the User object in the Session - the authentication servlet will then allow // the app to continue without redirecting to the login page session.putValue(AuthenticationFilter.AUTHENTICATION_USER, user); response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp"); } catch (Exception ex) { out.println("something is error."); out.println(ex); }