Checks if a login is currently allowed.<p>

In case no logins are allowed, an Exception is thrown.<p>

@throws CmsAuthentificationException in case no logins are allowed
422800
public void checkLoginAllowed() throws CmsAuthentificationException {

        if ((m_loginMessage != null) && (m_loginMessage.isLoginCurrentlyForbidden())) {
            // login message has been set and is active
            throw new CmsAuthentificationException(
                Messages.get().container(Messages.ERR_LOGIN_FAILED_WITH_MESSAGE_1, m_loginMessage.getMessage()));
        }
    }
1306497
protected void asNonLoginRequired(LoginHandlingResource resource) throws LoginRequiredException {
        if (!isSuppressRememberMeOfNonLoginRequired(resource)) { // option just in case
            logger.debug("...Checking login status for non login required");
            if (tryAlreadyLoginOrRememberMe(resource)) {
                checkPermission(resource); // throws if denied
                return; // Good
            }
        }
        if (isLoginRedirectBeanKeptAction(resource)) {
            // keep login-redirect path in session
            logger.debug("...Passing login check as login action (or redirect-kept action)");
        } else {
            clearLoginRedirectBean();
            logger.debug("...Passing login check as non login required");
        }
    }
649412
private boolean isAllowedUser(CmsUser user) throws CmsException {

        if (user.getOuFqn().startsWith(m_cms.getRequestContext().getOuFqn())) {
            return true;
        }
        return OpenCms.getRoleManager().getRolesOfUser(m_cms, user.getName(), m_ou, true, true, false).size() > 0;
    }
1338235
protected void initMembers() {

        synchronized (LOCK) {
            m_resourceInitHandlers = new ArrayList<I_CmsResourceInit>();
            m_requestHandlers = new HashMap<String, I_CmsRequestHandler>();
            m_systemInfo = new CmsSystemInfo();
            m_exportPoints = Collections.emptySet();
            m_defaultUsers = new CmsDefaultUsers();
            m_localeManager = new CmsLocaleManager(Locale.ENGLISH);
            m_sessionManager = new CmsSessionManager();
            m_runtimeProperties = new Hashtable<Object, Object>();
            // the default event manager must be available because the configuration already registers events
            m_eventManager = new CmsEventManager();
            // default link manager is required for test cases
            m_linkManager = new CmsLinkManager(new CmsDefaultLinkSubstitutionHandler());
        }
    }
818082
public void setLoginMessage(String messageText, boolean loginDisabled) throws CmsRoleViolationException {

        CmsLoginMessage message = new CmsLoginMessage(0, 0, messageText, loginDisabled);
        OpenCms.getLoginManager().setLoginMessage(m_cms, message);
        OpenCms.writeConfiguration(CmsVariablesConfiguration.class);
    }
8170
public void setAllowedPermissions(CmsAccessControlEntry entry) {

        CmsPermissionSetCustom p = m_permissions.get(entry.getPrincipal());
        if (p == null) {
            p = new CmsPermissionSetCustom();
            m_permissions.put(entry.getPrincipal(), p);
        }
        p.setPermissions(entry.getAllowedPermissions(), p.getDeniedPermissions());
    }
575083
protected void asLoginRequired(LoginHandlingResource resource) throws LoginRequiredException {
        logger.debug("...Checking login status for login required");
        if (tryAlreadyLoginOrRememberMe(resource)) {
            checkPermission(resource); // throws if denied
            return; // Good
        }
        if (needsSavingRequestedLoginRedirect(resource)) {
            saveRequestedLoginRedirectInfo();
        }
        throwLoginRequiredException("Cannot access the action: " + resource);
    }
1372289
protected boolean isAlreadyAvailable(String userName) {

        List<CmsUser> availableUsers;
        try {
            availableUsers = OpenCms.getOrgUnitManager().getUsers(getCms(), m_ou, false);
        } catch (CmsException e) {
            availableUsers = new ArrayList<CmsUser>();
        }
        Iterator<CmsUser> itAvailableUsers = availableUsers.iterator();
        while (itAvailableUsers.hasNext()) {
            if (userName.equals(itAvailableUsers.next().getSimpleName())) {
                return true;
            }
        }
        return false;
    }
752296
protected void validateSessions() {

        try {
            CmsSessionManager sessionInfoManager = OpenCms.getSessionManager();
            if (sessionInfoManager != null) {
                // will be null if only the shell is running
                sessionInfoManager.validateSessionInfos();
            }
        } catch (Throwable t) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_THREADSTORE_CHECK_SESSIONS_ERROR_0), t);
        }
    }
438610
public boolean isAuthenticated() {
        try {
            return IS_AUTHENTICATED_AUTHORIZER.isAuthorized(null, getAll(true));
        } catch (final HttpAction e) {
            throw new TechnicalException(e);
        }
    }
1359525
protected void initCmsContextForUI(HttpServletRequest req, HttpServletResponse res, CmsUIServlet servlet)
    throws IOException, CmsException {

        // instantiate CMS context
        String originalEncoding = req.getCharacterEncoding();
        String referrer = req.getHeader("referer");
        boolean allowPrivilegedLogin = (referrer == null) || !referrer.contains(CmsWorkplaceLoginHandler.LOGIN_HANDLER);

        CmsObject cms = initCmsObject(req, res, allowPrivilegedLogin);
        servlet.setCms(cms);
        if (originalEncoding != null) {
            // getI18NInfo sets wrong encoding
            req.setCharacterEncoding(originalEncoding);
        }
    }
890235
public void validateSSLConfig() throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "validateSSLConfig");

        try {
            if (Boolean.parseBoolean(getProperty(Constants.SSLPROP_VALIDATION_ENABLED))) {
                JSSEProviderFactory.getInstance().getSSLContext(null, this);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "validateSSLConfig -> true");
                return;
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "validateSSLConfig not enabled.");
            return;
        } catch (Exception e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "validateSSLConfig -> false");
            throw e;
        }
    }
526283
private void checkEditResourceNotSet() throws CmsUgcException {

        if (m_editResource != null) {
            String message = Messages.get().container(Messages.ERR_CANT_EDIT_MULTIPLE_CONTENTS_IN_SESSION_0).key(
                getCmsObject().getRequestContext().getLocale());
            throw new CmsUgcException(CmsUgcConstants.ErrorCode.errInvalidAction, message);

        }
    }
168124
public void setEnableAuthentication( boolean enableAuthentication ) {

		this.logger.fine( "Authentication is now " + (enableAuthentication ? "enabled" : "disabled") + ". Updating the REST resource." );
		this.enableAuthentication = enableAuthentication;

		if( this.authenticationFilter != null )
			this.authenticationFilter.setAuthenticationEnabled( enableAuthentication );
	}
1208390
@Override
  protected void additionalAuthenticationChecks(UserDetails userDetails,
      UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {

    // default implementation authentications via servlet API (container managed)
    ServletRequestAttributes currentRequestAttributes =
        (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();

    HttpServletRequest request = currentRequestAttributes.getRequest();
    String login = authentication.getName();
    String password = null;
    Object credentials = authentication.getCredentials();
    if (credentials != null) {
      password = credentials.toString();
    }
    try {
      request.login(login, password);
    } catch (ServletException e) {
      LOG.warn("Authentication failed: {}", e.toString());
      throw new BadCredentialsException("Authentication failed.", e);
    }
    authentication.setDetails(userDetails);
  }
954234
protected void checkLoginRequired(ActionRuntime runtime) throws LoginRequiredException {
        loginManager.ifPresent(nager -> {
            nager.checkLoginRequired(createLogingHandlingResource(runtime));
        });
    }
1172476
protected void initAcceptData() {

        // read the current users agreement values
        CmsUser user = getCms().getRequestContext().getCurrentUser();
        String result = (String)user.getAdditionalInfo(CmsUserSettings.LOGIN_USERAGREEMENT_ACCEPTED);
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(result)) {
            // read JSON data structure that is stored in the user additional info
            try {
                JSONObject jsonData = new JSONObject(result);
                m_acceptedVersion = jsonData.getDouble(KEY_ACCEPTED_VERSION);
                m_acceptedCount = jsonData.getInt(KEY_ACCEPTED_COUNT);
            } catch (JSONException e) {
                LOG.error(e);
            }
        }
    }