当前位置: 首页>>代码示例>>Java>>正文


Java CookieValue类代码示例

本文整理汇总了Java中org.springframework.web.bind.annotation.CookieValue的典型用法代码示例。如果您正苦于以下问题:Java CookieValue类的具体用法?Java CookieValue怎么用?Java CookieValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CookieValue类属于org.springframework.web.bind.annotation包,在下文中一共展示了CookieValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOAuthMock

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@RequestMapping(path = "/oauthmock", method = RequestMethod.GET)
public ResponseEntity<String> getOAuthMock(@CookieValue("_oauth2_proxy") String oAuthToken) {
  if (StringUtils.isEmpty(mockOAuth) || !mockOAuth.equals("true")) {
    return new ResponseEntity<>(new StatusJSON("mocking disabled").getJSON().toString(), HttpStatus.LOCKED);
  }

  if (userRepository.findByMail(sessionService.extractMail(oAuthToken)) != null) {
    return new ResponseEntity<>(new StatusJSON("ok").getJSON().toString(), HttpStatus.ACCEPTED);
  }

  return new ResponseEntity<>(new StatusJSON("forbidden").getJSON().toString(), HttpStatus.FORBIDDEN);
}
 
开发者ID:sinnerschrader,项目名称:SkillWill,代码行数:13,代码来源:OAuthMock.java

示例2: getActionResult

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.ACTION_RESULTS_BASE + "/{actionResultId}", method = RequestMethod.GET,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public ActionResult getActionResult(@PathVariable final String actionResultId,
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws InvalidActionSpecificationException, NoSuchProviderException,
        NoSuchSessionException, NoSuchItemTypeException {
    if (rateLimiter.tryAcquire()) {
        if (actionResultId == null) {
            throw new BadRequestException("actionResultId cannot be null");
        }
        UUID uuid = UUID.fromString(actionResultId);
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Lookup action result " + actionResultId + " for session " + sessionId);
        }
        synchronized (session) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Assigned session " + session.getId());
            }
            ActionResult actionResult = actionManager.getActionResult(session, uuid);
            return actionResult;
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:29,代码来源:LoomServiceImpl.java

示例3: getRelationships

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.PROVIDERS_BASE + "/schema", method = RequestMethod.GET,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public String getRelationships(
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchProviderException, NoSuchSessionException {
    GenerateSchema drawer = new GenerateSchema();
    List<Class<? extends Item>> items = new ArrayList<>();
    if (rateLimiter.tryAcquire()) {
        Reflections reflections = new Reflections("com");
        Set<Class<? extends Item>> subTypes = reflections.getSubTypesOf(Item.class);
        for (Class<? extends Item> class1 : subTypes) {
            items.add(class1);
        }
    }

    Session session = modelValidator.validateSession(sessionId, response);

    return drawer.process(stitcher, items, session.getProviders().keySet());
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:22,代码来源:LoomServiceImpl.java

示例4: signUp

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@GetMapping("/signup")
public RedirectView signUp(WebRequest webRequest,
    @CookieValue(name = "NG_TRANSLATE_LANG_KEY", required = false, defaultValue = "\"en\"") String langKey) {
    String providerId = null;
    try {
        Connection<?> connection = providerSignInUtils.getConnectionFromSession(webRequest);
        providerId = connection.getKey().getProviderId();
        socialService.createSocialUser(connection, langKey.replace("\"", ""));
        return redirect(URIBuilder
                        .fromUri(TenantUtil.getApplicationUrl() + "/social-register/"
                                        + connection.getKey().getProviderId())
                        .queryParam("success", "true").build().toString());
    } catch (Exception e) {
        log.error("Exception creating social user: ", e);
        return redirectOnError(providerId);
    }
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:18,代码来源:SocialController.java

示例5: view

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
/**
 * 详情.
 */
@RequestMapping("disk-view")
public String view(
        @RequestParam("id") Long id,
        @CookieValue(value = "share", required = false) String sharePassword,
        Model model) {
    DiskShare diskShare = diskShareManager.get(id);

    if ("private".equals(diskShare.getShareType())) {
        if (!diskShare.getSharePassword().equals(sharePassword)) {
            return "disk/disk-code";
        }
    }

    model.addAttribute("diskShare", diskShare);

    return "disk/disk-view";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:DiskController.java

示例6: getCurrentUser

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@ApiOperation(value = "session/user", nickname = "get session user", notes = "get session user")
@ApiResponses({
  @ApiResponse(code = 200, message = "Success"),
  @ApiResponse(code = 401, message = "Unauthorized"),
  @ApiResponse(code = 500, message = "Failure")
})
@ApiImplicitParams({
  @ApiImplicitParam(name = "search", value = "Name to search", paramType = "query"),
  @ApiImplicitParam(name = "exclude_hidden", value = "Do not return hidden skills", paramType = "query", defaultValue = "true"),
  @ApiImplicitParam(name = "count", value = "Limit the number of skills to find", paramType = "query"),
})
@RequestMapping(path = "/session/user", method = RequestMethod.GET)
public ResponseEntity<String> getCurrentUser(@CookieValue("_oauth2_proxy") String oAuthToken) {
  logger.debug("Getting user from session {}", oAuthToken);
  User user = sessionService.getUserByToken(oAuthToken);
  if (user == null) {
    return new ResponseEntity<>(new StatusJSON("no current session").toString(), HttpStatus.UNAUTHORIZED);
  }
  return new ResponseEntity<>(user.toJSON().toString(), HttpStatus.OK);
}
 
开发者ID:sinnerschrader,项目名称:SkillWill,代码行数:21,代码来源:SessionController.java

示例7: doGetPrintSecrets

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@RequestMapping(value = "/admin/printSecrets", method = RequestMethod.GET)
public String doGetPrintSecrets(@CookieValue(value = "auth", defaultValue = "notset") String auth, HttpServletResponse response, HttpServletRequest request) throws Exception {

  if (request.getSession().getAttribute("auth") == null) {
    return fail;
  }

  String authToken = request.getSession().getAttribute("auth").toString();
  if(!isAdmin(authToken)) {
    return fail;
  }

  ClassPathResource cpr = new ClassPathResource("static/calculations.csv");
  try {
    byte[] bdata = FileCopyUtils.copyToByteArray(cpr.getInputStream());
    response.getOutputStream().println(new String(bdata, StandardCharsets.UTF_8));
    return null;
  } catch (IOException ex) {
    ex.printStackTrace();
    // redirect to /
    return fail;
  }
}
 
开发者ID:ShiftLeftSecurity,项目名称:HelloShiftLeft,代码行数:24,代码来源:AdminController.java

示例8: getProviders

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.PROVIDERS_BASE, method = RequestMethod.GET, headers = ApiConfig.API_HEADERS,
        produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public ProviderList getProviders(
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) {
    if (rateLimiter.tryAcquire()) {
        sessionManager.getSession(sessionId, response);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Get all providers");
        }

        ProviderList providerList = new ProviderList();
        providerList.getProviders().addAll(adapterManager.getProviders());
        return providerList;
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:22,代码来源:LoomServiceImpl.java

示例9: getProvider

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.PROVIDERS_BASE + "/{providerType}/{providerId}", method = RequestMethod.GET,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public Provider getProvider(@PathVariable final String providerType, @PathVariable final String providerId,
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchProviderException {
    if (rateLimiter.tryAcquire()) {
        sessionManager.getSession(sessionId, response);

        modelValidator.validateProviderType(providerType);
        modelValidator.validateProviderId(providerId);


        if (LOG.isDebugEnabled()) {
            LOG.debug("Get provider " + providerType + Provider.PROV_SEPARATOR + providerId);
        }
        return getProvider(providerType, providerId);
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:LoomServiceImpl.java

示例10: getPatterns

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.PATTERNS_BASE, method = RequestMethod.GET, headers = ApiConfig.API_HEADERS,
        produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public PatternDefinitionList getPatterns(
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchSessionException {
    if (rateLimiter.tryAcquire()) {
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Get all patterns for all providers");
        }

        synchronized (session) {
            PatternDefinitionList patternDefinitionList = new PatternDefinitionList();
            List<PatternDefinition> patterns = patternDefinitionList.getPatterns();
            patterns.addAll(tapestryManager.getAllPatterns());
            return patternDefinitionList;
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:24,代码来源:LoomServiceImpl.java

示例11: getPattern

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.PATTERNS_BASE + "/{patternId}", method = RequestMethod.GET,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public PatternDefinition getPattern(@PathVariable final String patternId,
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response)
        throws InterruptedException, NoSuchSessionException, NoSuchPatternException {
    if (rateLimiter.tryAcquire()) {
        if (StringUtils.isBlank(patternId)) {
            throw new BadRequestException("Empty pattern id parameter");
        }

        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Get pattern with id: " + patternId);
        }

        synchronized (session) {
            PatternDefinition patternDefinition = tapestryManager.getPattern(patternId);
            return patternDefinition;
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:27,代码来源:LoomServiceImpl.java

示例12: getTapestryDefinition

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.TAPESTRY_BASE + "/{tapestryId}", method = RequestMethod.GET,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public TapestryDefinition getTapestryDefinition(@PathVariable final String tapestryId,
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchSessionException, NoSuchTapestryDefinitionException {
    if (rateLimiter.tryAcquire()) {
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Get tapestry definition with id: " + tapestryId);
        }

        synchronized (session) {
            modelValidator.validateTapestryDefinition(tapestryId);
            TapestryDefinition tapestryDefinition = tapestryManager.getTapestryDefinition(session);
            // querying with any tapestryId would work as well as the tapestryManager works
            // based on session, not id.
            return tapestryDefinition;
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:25,代码来源:LoomServiceImpl.java

示例13: getTapestryDefinitions

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.TAPESTRY_BASE, method = RequestMethod.GET, headers = ApiConfig.API_HEADERS,
        produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public TapestryDefinitionList getTapestryDefinitions(
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchSessionException {
    if (rateLimiter.tryAcquire()) {
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Get all tapestry definitions");
        }

        synchronized (session) {
            // Ultimately, this needs to be changed based on user rather than session.
            TapestryDefinition tapestryDefinition = tapestryManager.getTapestryDefinition(session);
            ArrayList<TapestryDefinition> tapestryDefinitions = new ArrayList<>(1);
            if (tapestryDefinition != null) {
                tapestryDefinitions.add(tapestryDefinition);
            }
            return new TapestryDefinitionList(tapestryDefinitions);
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:27,代码来源:LoomServiceImpl.java

示例14: deleteTapestryDefinition

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.TAPESTRY_BASE + "/{tapestryId}", method = RequestMethod.DELETE,
        headers = ApiConfig.API_HEADERS, produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public void deleteTapestryDefinition(@PathVariable final String tapestryId,
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchSessionException, NoSuchTapestryDefinitionException {
    if (rateLimiter.tryAcquire()) {
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Delete tapestry definition with id: " + tapestryId);
        }

        synchronized (session) {
            modelValidator.validateTapestryDefinition(tapestryId);
            // Ultimately, this needs to be a specific tapestry not based on sesssion.
            tapestryManager.clearTapestryDefinition(session);
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:LoomServiceImpl.java

示例15: deleteTapestryDefinitions

import org.springframework.web.bind.annotation.CookieValue; //导入依赖的package包/类
@Override
@RequestMapping(value = ApiConfig.TAPESTRY_BASE, method = RequestMethod.DELETE, headers = ApiConfig.API_HEADERS,
        produces = {ApiConfig.API_PRODUCES})
@ResponseBody
public void deleteTapestryDefinitions(
        @CookieValue(value = SessionManager.SESSION_COOKIE, required = false) final String sessionId,
        final HttpServletResponse response) throws NoSuchSessionException {
    if (rateLimiter.tryAcquire()) {
        Session session = modelValidator.validateSession(sessionId, response);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Delete all tapestry definitions");
        }

        synchronized (session) {
            // Ultimately, this needs to invoke a method in tapestry manager to remove all
            // tapestries rather than the only one bound with a session.
            tapestryManager.clearTapestryDefinition(session);
        }
    } else {
        throw new ApiThrottlingException("Exceeded max number of requests per second");
    }
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:23,代码来源:LoomServiceImpl.java


注:本文中的org.springframework.web.bind.annotation.CookieValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。