/* (non-Javadoc)
@see com.ibm.ws.webcontainer31.session.IHttpSessionContext31#generateNewId(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpSession)
550320
@Override
    public HttpSession generateNewId(HttpServletRequest request, HttpServletResponse response, HttpSession existingSession) {
        SessionAffinityContext sac = getSessionAffinityContext(request);
        HttpSession session = (HttpSession) _coreHttpSessionManager.generateNewId(request, response, sac, ((SessionData) existingSession).getISession());
        return session;
    }
521781
private void generateSession() {
        this.session = this.system.getSession(getSettings(), this.useLegacyLocalRepository);
        if (this.disableClassPathWorkspaceReader) {
            ((DefaultRepositorySystemSession) this.session).setWorkspaceReader(null);
        }
    }
499014
public static synchronized String getNewId() {
		// unique across JVMs as long as each has a different workerID
		// based on Twitter's Snowflake algorithm
		long timestamp = timestamp();

		if (lastTimestamp == timestamp) {
			sequence = (sequence + 1) & SEQUENCE_MASK;
			if (sequence == 0) {
				timestamp = tilNextMillis(lastTimestamp);
			}
		} else {
			sequence = 0;
		}

		if (timestamp < lastTimestamp) {
			throw new IllegalStateException(String.format("Clock moved backwards.  "
					+ "Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
		}

		lastTimestamp = timestamp;
		return Long.toString(((timestamp - TIMER_OFFSET) << TIMESTAMP_LEFT_SHIFT) |
											(dataCenterId << DATACENTER_ID_SHIFT) |
													(workerId << WORKER_ID_SHIFT) |
																	(sequence));

	}
1354214
public static String getSessionEncodedUrl(String url, String sessionIdName, String sessionId) {
        return url + getSessionIdSubstring(sessionIdName) + sessionId;
    }
1329655
@Override
    public ClientResponse doHandle(ClientRequest cr) {
        UriBuilder newUri = UriBuilder.fromUri(cr.getURI());
        String currentQuery = cr.getURI().getRawQuery();
        if (currentQuery == null) {
            currentQuery = "";
        } else if (currentQuery.length() > 0) {
            currentQuery += "&";
        }
        currentQuery += "api-version=2016-05-31&" + sasToken;

        newUri.replaceQuery(currentQuery);
        cr.setURI(newUri.build());

        return getNext().handle(cr);
    }
1362477
public void createAndEditNewElement(
        final org.opencms.ade.containerpage.client.ui.CmsContainerPageElementPanel element,
        final boolean inline) {

        if (!element.isNew()) {
            return;
        }

        final CmsContainer container = m_containers.get(element.getParentTarget().getContainerId());

        m_handler.showPageOverlay();
        CmsRpcAction<CmsCreateElementData> action = new CmsRpcAction<CmsCreateElementData>() {

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
             */
            @Override
            public void execute() {

                getContainerpageService().checkCreateNewElement(
                    CmsCoreProvider.get().getStructureId(),
                    element.getId(),
                    element.getNewType(),
                    container,
                    getLocale(),
                    this);

            }

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
             */
            @Override
            protected void onResponse(CmsCreateElementData result) {

                if (result.needsModelSelection()) {
                    getHandler().openModelResourceSelect(element, result.getModelResources());
                } else {
                    openEditorForNewElement(element, result.getCreatedElement(), inline);
                }
            }
        };
        action.execute();
    }
893835
public int doEndTag() throws JspException
    {
        ServletRequest req = pageContext.getRequest();
        String scriptId = null;

        // report errors that may have occurred
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        // Generate the name definition or image element
        String uri = null;
        if (_state.src != null) {
            try {
                uri = PageFlowTagUtils.rewriteResourceURL(pageContext, _state.src, _params, _location);
            }
            catch (URISyntaxException e) {
                // report the error...
                String s = Bundle.getString("Tags_Image_URLException",
                        new Object[]{_state.src, e.getMessage()});
                registerTagError(s, e);
            }
        }

        if (uri != null) {
            _state.src = ((HttpServletResponse) pageContext.getResponse()).encodeURL(uri);
        }

        // we assume that tagId will over have override id if both
        // are defined.
        if (_state.id != null) {
            scriptId = renderNameAndId((HttpServletRequest) req, _state, null);
        }

        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.IMAGE_TAG, req);
        br.doStartTag(writer, _state);
        br.doEndTag(writer);


        if (scriptId != null)
            write(scriptId);

        // Evaluate the remainder of this page
        localRelease();
        return EVAL_PAGE;
    }
178404
public void setNewPwd(String newPwd) {

        // leave password unchanged, if the new password is empty
        if (CmsStringUtil.isEmpty(newPwd)) {
            return;
        }
        try {
            OpenCms.getPasswordHandler().validatePassword(newPwd);
        } catch (CmsSecurityException e) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_INVALID_NEWPWD_0), e);
        }
        m_newPwd = newPwd;
    }
704117
public String getRequestedSessionIdFromURL(ServletRequest request, boolean force) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL],"force="+force);
        }
        String sessionID = null;
        if (_smc.getEnableUrlRewriting() || force) {
            String requestURI = ((IExtendedRequest) request).getEncodedRequestURI();
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL], "request uri:" + requestURI);
            }
            int prefix = requestURI.indexOf(_smc.getSessUrlRewritePrefix());
            if (prefix != -1) {
                int sessionIDstart = requestURI.indexOf("=", prefix + 1);
                int i = requestURI.indexOf(";", prefix + 1);
                int j = requestURI.indexOf("?", prefix + 1);
                int postfix = -1;
                if (i == -1) {
                    postfix = j;
                } else if (j == -1) {
                    postfix = i;
                } else
                    postfix = (i > j) ? j : i;

                if (postfix != -1) {
                    sessionID = requestURI.substring(sessionIDstart + 1, postfix);
                } else {
                    sessionID = requestURI.substring(sessionIDstart + 1);
                }
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL], sessionID);
        }
        return sessionID;
    }
676201
@Nonnull
  public static HttpSession safeRenewSession (@Nonnull final HttpServletRequest aHttpRequest)
  {
    ValueEnforcer.notNull (aHttpRequest, "HttpRequest");

    // Is there any existing session?
    final HttpSession aSession = aHttpRequest.getSession (false);
    if (aSession != null)
    {
      try
      {
        if (LOGGER.isDebugEnabled ())
          LOGGER.debug ("Invalidating session " + aSession.getId () + " for renewal");
        aSession.invalidate ();
      }
      catch (final IllegalStateException ex)
      {
        // session already invalidated
      }
    }

    // Create the new session
    return aHttpRequest.getSession (true);
  }
1297603
private static ResponseSwitch createResponseSwitch(Object response)
  {
      if (response instanceof HttpServletResponse)
      {
          return new HttpServletResponseSwitch((HttpServletResponse) response);
      }
      else if (response instanceof ServletResponse)
      {
          return new ServletResponseSwitch((ServletResponse) response);
      }
      return null;
  }
42593
function getNewID()
    {
        $db = eZDB::instance();
        if( $db->supportsDefaultValuesInsertion() )
        {
            $db->query( 'INSERT INTO ezorder_nr_incr DEFAULT VALUES' );
        }
        else
        {
            $db->query( 'INSERT INTO ezorder_nr_incr(id) VALUES(DEFAULT)' );
        }

        return $db->lastSerialID( 'ezorder_nr_incr', 'id' );
    }
948924
@Override
  public String generateNextName() {
    String name;
    do {
      name = prefix;
      int i = nameCount;

      if (name.isEmpty()) {
        int pos = i % firstChars.length;
        name = String.valueOf(firstChars[pos].name);
        i /= firstChars.length;
      }

      while (i > 0) {
        i--;
        int pos = i % nonFirstChars.length;
        name += nonFirstChars[pos].name;
        i /= nonFirstChars.length;
      }

      nameCount++;

      // Make sure it's not a JS keyword or reserved name.
    } while (TokenStream.isKeyword(name) || reservedNames.contains(name));

    return name;
  }
1329446
@Override
    public int doEndTag() throws JspException {
        String result;                // the eventual result

        // add (already encoded) parameters
        String baseUrl = UrlSupport.resolveUrl(url, context, pageContext);
        result = params.aggregateParams(baseUrl);

        // if the URL is relative, rewrite it with 'redirect' encoding rules
        HttpServletResponse response =
                ((HttpServletResponse) pageContext.getResponse());
        if (!UrlUtil.isAbsoluteUrl(result)) {
            result = response.encodeRedirectURL(result);
        }

        // redirect!
        try {
            response.sendRedirect(result);
        } catch (java.io.IOException ex) {
            throw new JspTagException(ex.toString(), ex);
        }

        return SKIP_PAGE;
    }
468894
@Override
	protected WebResponse newWebResponse(final WebRequest webRequest,
		final HttpServletResponse httpServletResponse)
	{
		return new ServletWebResponse((ServletWebRequest)webRequest, httpServletResponse)
		{

			@Override
			public String encodeRedirectURL(final CharSequence url)
			{
				return isRobot(webRequest) ? url.toString() : super.encodeRedirectURL(url);
			}

			@Override
			public String encodeURL(final CharSequence url)
			{
				return isRobot(webRequest) ? url.toString() : super.encodeURL(url);
			}

			private boolean isRobot(final WebRequest request)
			{
				final String agent = webRequest.getHeader("User-Agent");
				return BotAgentInspector.isAgent(agent);
			}
		};
	}
2885
@Override
    public Object createSession(ServletRequest req, ServletResponse res, SessionAffinityContext sac, boolean reuseTheId) {
        String id = _sam.getInUseSessionID(req, sac);
        int version = _sam.getInUseSessionVersion(req, sac); // sac.getRequestedSessionVersion();
        ISession isess = createISession(id, version, reuseTheId);
        return adaptAndSetCookie(req, res, sac, isess);
    }
159405
function (fn) {
    if (fn.length === 0) {
      fn = _.wrap(fn, function(func, callback) {
        callback(null, func());
      });
    }

    this.getNewId = fn;

    return this;
  }