use of org.springframework.http.server.ServletServerHttpRequest in project littlefisher-system by littlefishercoder.
the class SuccessControllerAdvice method beforeBodyWrite.
@Override
public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
if (request instanceof ServletServerHttpRequest) {
ServletServerHttpRequest httpRequest = (ServletServerHttpRequest) request;
String servletPath = httpRequest.getServletRequest().getServletPath();
if (servletPath.startsWith(BaseConstants.BASE_API_PREFIX)) {
logger.debug("对{}开头的请求,返回信息进行封装", BaseConstants.BASE_API_PREFIX);
if (!(body instanceof CommonResponse)) {
return new CommonResponse(EnumResult.SUCCESS, body);
}
}
}
return body;
}
use of org.springframework.http.server.ServletServerHttpRequest in project CzechIdMng by bcvsolutions.
the class RequestResourceResolver method resolve.
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T resolve(HttpServletRequest nativeRequest, Class<T> domainType, T objectToUpdate) throws HttpMessageNotReadableException {
ServletServerHttpRequest request = new ServletServerHttpRequest(nativeRequest);
IncomingRequest incoming = new IncomingRequest(request);
MediaType contentType = request.getHeaders().getContentType();
for (HttpMessageConverter converter : messageConverters) {
if (!converter.canRead(PersistentEntityResource.class, contentType)) {
continue;
}
T obj = (T) read(domainType, incoming, converter, objectToUpdate);
if (obj == null) {
throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, domainType));
}
return obj;
}
throw new HttpMessageNotReadableException(String.format(NO_CONVERTER_FOUND, domainType, contentType));
}
use of org.springframework.http.server.ServletServerHttpRequest in project portal by ixinportal.
the class MobileHandShakeInterceptor method beforeHandshake.
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
log.info("准备进行握手");
if (request instanceof ServletServerHttpRequest) {
List<String> appIds = request.getHeaders().get("appId");
if (appIds.isEmpty()) {
return false;
}
String appId = appIds.get(0);
List<String> signatures = request.getHeaders().get("Content-Signature");
if (StringUtils.isBlank(appId) || signatures.isEmpty()) {
return false;
}
String signature = signatures.get(0);
if (StringUtils.isBlank(signature)) {
return false;
}
ApplicationInfo applicationInfo1 = applicationInfo.getApplicationInfo(appId);
// }
if (!signature.equals(Base64.encode(HMACSHA1.getHmacSHA1(appId, applicationInfo1.getSecretKey()), false))) {
// secretKey // TODO: 2017/11/27
return false;
}
attributes.put("appId", appId);
// System.out.println(attributes.get("appId").toString());
}
return true;
}
use of org.springframework.http.server.ServletServerHttpRequest in project connectors-workspace-one by vmware.
the class ConnectorRootController method getRoot.
@GetMapping(path = "/", produces = MediaTypes.HAL_JSON_VALUE)
public ResponseEntity<ResourceSupport> getRoot(HttpServletRequest servletRequest) {
HttpRequest request = new ServletServerHttpRequest(servletRequest);
ResourceSupport resource = new ResourceSupport();
addMetadata(resource, request);
addCards(resource, request);
addImage(resource, request);
addAuth(resource, request);
return ResponseEntity.ok().cacheControl(CacheControl.maxAge(maxAge, unit)).body(resource);
}
use of org.springframework.http.server.ServletServerHttpRequest in project spring-session by spring-projects.
the class SessionRepositoryMessageInterceptorTests method beforeHandshakeNullSession.
@Test
public void beforeHandshakeNullSession() throws Exception {
ServletServerHttpRequest request = new ServletServerHttpRequest(new MockHttpServletRequest());
assertThat(this.interceptor.beforeHandshake(request, null, null, null)).isTrue();
verifyZeroInteractions(this.sessionRepository);
}
Aggregations