code: public void setSingleSignOn(HttpRequest request,
                                  HttpResponse response,
                                  Principal principal,
                                  Credential credential)
      {
          
          String ssoID=null;
          
          synchronized(_ssoId2Principal)
          {
              // Create new SSO ID
              while (true)
              {
                  ssoID = Long.toString(Math.abs(_random.nextLong()),
                                        30 + (int)(System.currentTimeMillis() % 7));
                  if (!_ssoId2Principal.containsKey(ssoID))
                      break;
              }
              
              if(log.isDebugEnabled())log.debug("set ssoID="+ssoID);
              _ssoId2Principal.put(ssoID,principal);
              _ssoPrincipal2Credential.put(principal,credential);
              _ssoUsername2Id.put(principal.getName(),ssoID);
          }
          
          Cookie cookie = new Cookie(SSO_COOKIE_NAME, ssoID);
          cookie.setPath("/");
          response.addSetCookie(cookie);
      }
docs: /* ------------------------------------------------------------