List of usage examples for org.apache.wicket.session ISessionStore getAttribute
Serializable getAttribute(Request request, String name);
From source file:$.HippoAuthenticationRequestHandler.java
License:Apache License
public Response handleRequest(Message m, ClassResourceInfo resourceClass) { ISessionStore sessionStore = Application.get().getSessionStore(); Serializable attribute = sessionStore.getAttribute( new ServletWebRequest((HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST), ""), "session"); if (attribute instanceof PluginUserSession) { UserCredentials userCredentials = ((PluginUserSession) attribute).getUserCredentials(); if (userCredentials != null) { SimpleCredentials jcrCredentials = (SimpleCredentials) userCredentials.getJcrCredentials(); String username = jcrCredentials.getUserID(); String password = new String(jcrCredentials.getPassword()); try { session = JcrSessionUtil.createSession(username, password); if (isAuthenticated()) { HttpServletRequest request = (HttpServletRequest) m .get(AbstractHTTPDestination.HTTP_REQUEST); request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session); return null; } else { throw new UnauthorizedException(); }/*from w w w . j a v a2s . c o m*/ } catch (LoginException e) { LOG.debug("Login failed: {}", e); throw new UnauthorizedException(e.getMessage()); } } } throw new UnauthorizedException(); }
From source file:nl.openweb.hippo.umd.webservices.HippoAuthenticationRequestHandler.java
License:Apache License
public Response handleRequest(Message m, ClassResourceInfo resourceClass) { ISessionStore sessionStore = Application.get().getSessionStore(); Serializable attribute = sessionStore.getAttribute( new ServletWebRequest((HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST), ""), "session"); if (attribute instanceof PluginUserSession) { UserCredentials userCredentials = ((PluginUserSession) attribute).getUserCredentials(); if (userCredentials != null) { SimpleCredentials jcrCredentials = (SimpleCredentials) userCredentials.getJcrCredentials(); String username = jcrCredentials.getUserID(); String password = new String(jcrCredentials.getPassword()); try { session = JcrSessionUtil.createSession(username, password); if (isAuthenticated()) { HttpServletRequest request = (HttpServletRequest) m .get(AbstractHTTPDestination.HTTP_REQUEST); request.setAttribute(AuthenticationConstants.HIPPO_SESSION, session); return null; } else { throw new UnauthorizedException(); }/*from w w w . j av a 2s . c o m*/ } catch (LoginException e) { LOG.debug("Login failed: {}", e); throw new UnauthorizedException(e.getMessage()); } } } throw new UnauthorizedException(); }