/** * Returns the ip.<p> * * @return the ip */ public String getIp() { return m_context.getRemoteAddress(); }
/** * Returns the ip.<p> * * @return the ip */ public String getIp() { return m_context.getRemoteAddress(); }
/** * Logs a user into the Cms, if the password is correct.<p> * * @param username the name of the user * @param password the password of the user * * @return the name of the logged in user * * @throws CmsException if the login was not successful */ public String loginUser(String username, String password) throws CmsException { return loginUser(username, password, m_context.getRemoteAddress()); }
/** * Logs a user into the Cms, if the password is correct.<p> * * @param username the name of the user * @param password the password of the user * * @return the name of the logged in user * * @throws CmsException if the login was not successful */ public String loginUser(String username, String password) throws CmsException { return loginUser(username, password, m_context.getRemoteAddress()); }
/** * Returns all the groups the given user belongs to.<p> * * @param username the name of the user * @param directGroupsOnly if set only the direct assigned groups will be returned, if not also indirect roles * @param includeOtherOus if to include groups of other organizational units * * @return a list of <code>{@link CmsGroup}</code> objects * * @throws CmsException if operation was not successful */ public List getGroupsOfUser(String username, boolean directGroupsOnly, boolean includeOtherOus) throws CmsException { return getGroupsOfUser(username, directGroupsOnly, includeOtherOus, m_context.getRemoteAddress()); }
/** * Returns all the groups the given user belongs to.<p> * * @param username the name of the user * @param directGroupsOnly if set only the direct assigned groups will be returned, if not also indirect roles * @param includeOtherOus if to include groups of other organizational units * * @return a list of <code>{@link CmsGroup}</code> objects * * @throws CmsException if operation was not successful */ public List<CmsGroup> getGroupsOfUser(String username, boolean directGroupsOnly, boolean includeOtherOus) throws CmsException { return getGroupsOfUser(username, directGroupsOnly, includeOtherOus, m_context.getRemoteAddress()); }
/** * Logs a web user into the Cms, if the password is correct. * * @param username the name of the user * @param password the password of the user * * @return the name of the logged in user * * @throws CmsException if the login was not successful * * @deprecated there are no more web users, use a user without any role! */ public String loginWebUser(String username, String password) throws CmsException { return loginUser(username, password, m_context.getRemoteAddress()); }
/** * Returns the remote ip address of the current user.<p> * * @return the remote ip address of the current user */ public String getLoginAddress() { return getCms().getRequestContext().getRemoteAddress(); }
/** * Returns the remote ip address of the current user.<p> * * @return the remote ip address of the current user */ public String getLoginAddress() { return getCms().getRequestContext().getRemoteAddress(); }
/** * Returns the groups of an user filtered by the specified IP address.<p> * * @param dbc the current database context * @param username the name of the user * @param readRoles if to read roles or groups * * @return the groups of the given user, as a list of {@link CmsGroup} objects * * @throws CmsException if something goes wrong */ public List<CmsGroup> getGroupsOfUser(CmsDbContext dbc, String username, boolean readRoles) throws CmsException { return getGroupsOfUser(dbc, username, "", true, readRoles, false, dbc.getRequestContext().getRemoteAddress()); }
/** * Returns the groups of an user filtered by the specified IP address.<p> * * @param dbc the current database context * @param username the name of the user * @param readRoles if to read roles or groups * * @return the groups of the given user, as a list of {@link CmsGroup} objects * * @throws CmsException if something goes wrong */ public List getGroupsOfUser(CmsDbContext dbc, String username, boolean readRoles) throws CmsException { return getGroupsOfUser(dbc, username, "", true, readRoles, false, dbc.getRequestContext().getRemoteAddress()); }
getGroupsOfUser(dbc, user.getName(), "", true, true, false, dbc.getRequestContext().getRemoteAddress()));
true, false, dbc.getRequestContext().getRemoteAddress()));
true, false, dbc.getRequestContext().getRemoteAddress()); } catch (CmsException e) { if (LOG.isErrorEnabled()) {
/** * Logs a user out, i.e. destroys the current users session, * after that the current page will be redirected to itself one time to ensure that * the users session is truly destroyed.<p> * * @throws IOException if redirect after logout fails */ public void logout() throws IOException { HttpSession session = getRequest().getSession(false); if (session != null) { session.invalidate(); } // logout was successful if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key( Messages.LOG_LOGOUT_SUCCESFUL_3, getRequestContext().currentUser().getName(), getRequestContext().addSiteRoot(getRequestContext().getUri()), getRequestContext().getRemoteAddress())); } getResponse().sendRedirect(getFormLink()); } }
/** * Logs out the current user redirecting to the login form afterwards.<p> * * @param cms the cms context * @param request the servlet request * @param response the servlet response * * @throws IOException if writing to the response fails */ public static void logout(CmsObject cms, HttpServletRequest request, HttpServletResponse response) throws IOException { String loggedInUser = cms.getRequestContext().getCurrentUser().getName(); HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); /* we need this because a new session might be created after this method, but before the session info is updated in OpenCmsCore.showResource. */ cms.getRequestContext().setUpdateSessionEnabled(false); } // logout was successful if (LOG.isInfoEnabled()) { LOG.info( org.opencms.jsp.Messages.get().getBundle().key( org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3, loggedInUser, cms.getRequestContext().addSiteRoot(cms.getRequestContext().getUri()), cms.getRequestContext().getRemoteAddress())); } response.sendRedirect(getFormLink(cms)); }
/** * Logs a user out, i.e. destroys the current users session, * after that the current page will be redirected to itself one time to ensure that * the users session is truly destroyed.<p> * * @throws IOException if redirect after logout fails */ public void logout() throws IOException { String loggedInUserName = getRequestContext().getCurrentUser().getName(); HttpSession session = getRequest().getSession(false); if (session != null) { session.invalidate(); /* we need this because a new session might be created after this method, but before the session info is updated in OpenCmsCore.showResource. */ getCmsObject().getRequestContext().setUpdateSessionEnabled(false); } // logout was successful if (LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key( Messages.LOG_LOGOUT_SUCCESFUL_3, loggedInUserName, getRequestContext().addSiteRoot(getRequestContext().getUri()), getRequestContext().getRemoteAddress())); } getResponse().sendRedirect(getFormLink()); } }
/** * Logs the current user out by invalidating the session an reloading the current URI.<p> * Important: This works only within vaadin apps.<p> */ public static void logout() { CmsObject cms = A_CmsUI.getCmsObject(); if (UI.getCurrent() instanceof CmsAppWorkplaceUi) { ((CmsAppWorkplaceUi)UI.getCurrent()).onWindowClose(); } String loggedInUser = cms.getRequestContext().getCurrentUser().getName(); UI.getCurrent().getSession().close(); String loginLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget( cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false); VaadinService.getCurrentRequest().getWrappedSession().invalidate(); Page.getCurrent().setLocation(loginLink); // logout was successful if (LOG.isInfoEnabled()) { LOG.info( org.opencms.jsp.Messages.get().getBundle().key( org.opencms.jsp.Messages.LOG_LOGOUT_SUCCESFUL_3, loggedInUser, "{workplace logout option}", cms.getRequestContext().getRemoteAddress())); } }
/** * Creates a new instance with all context variables initialized from the given request context.<p> * * @param requestContext the request context to initialize this context info with */ public CmsContextInfo(CmsRequestContext requestContext) { setUserName(requestContext.currentUser().getName()); setProjectName(requestContext.currentProject().getName()); setRequestedUri(requestContext.getUri()); setSiteRoot(requestContext.getSiteRoot()); setLocale(requestContext.getLocale()); setEncoding(requestContext.getEncoding()); setRemoteAddr(requestContext.getRemoteAddress()); setRequestTime(requestContext.getRequestTime()); setOuFqn(requestContext.getOuFqn()); }
/** * Creates a new instance with all context variables initialized from the given request context.<p> * * @param requestContext the request context to initialize this context info with */ public CmsContextInfo(CmsRequestContext requestContext) { setUserName(requestContext.getCurrentUser().getName()); setProjectName(requestContext.getCurrentProject().getName()); setRequestedUri(requestContext.getUri()); setSiteRoot(requestContext.getSiteRoot()); setRequestMatcher(requestContext.getRequestMatcher()); setLocale(requestContext.getLocale()); setEncoding(requestContext.getEncoding()); setRemoteAddr(requestContext.getRemoteAddress()); setRequestTime(requestContext.getRequestTime()); setIsSecureRequest(requestContext.isSecureRequest()); setOuFqn(requestContext.getOuFqn()); setDetailResource(requestContext.getDetailResource()); }