*  @param action what we are doing
     *  @return whether the user can perform the specified action
     *  @throws IOException if a network error occurs
     *  @throws CredentialExpiredException if cookies have expired
     *  @since 0.10
     */
    protected boolean checkRights(HashMap<String, Object> pageinfo, String action) throws IOException, CredentialException
    {
        // Check if we are logged out. Easiest way is via the edit token.
        String token = (String)pageinfo.get("token");
        if (token.equals("\\+") && user != null)
        {
            logger.log(Level.SEVERE, "Session has expired!");
            logout();
            throw new CredentialExpiredException("Cookies have expired.");
        }
        // check protection
        @SuppressWarnings("unchecked")
        HashMap<String, Object> protectionstate = (HashMap<String, Object>)pageinfo.get("protection");
        if (protectionstate.containsKey(action))
        {
            String level = (String)protectionstate.get(action);
            if (level.equals(SEMI_PROTECTION))
                return user.isAllowedTo("autoconfirmed");
            if (level.equals(FULL_PROTECTION))
                return user.isA("sysop");
        }
        return true;
    }