本文整理了Java中org.wso2.msf4j.Request.getHeaders
方法的一些代码示例,展示了Request.getHeaders
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getHeaders
方法的具体详情如下:
包路径:org.wso2.msf4j.Request
类名称:Request
方法名:getHeaders
暂无
代码示例来源:origin: wso2/msf4j
@Override
public boolean interceptRequest(Request request, Response response) throws Exception {
request.getHeaders().getRequestHeaders().entrySet()
.forEach(header -> log.info("Header - " + header.getKey() + " : " + header.getValue()));
return true;
}
}
代码示例来源:origin: org.wso2.msf4j.example/stockquote-fatjar
/**
* Retrieve all stocks.
* http://localhost:8080/stockquote/all
*
* @return All stocks will be sent to the client as Json/xml
* according to the Accept header of the request.
*/
@GET
@Path("/all")
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Get all stocks",
notes = "Returns all stock items",
response = Stocks.class,
responseContainer = "List")
public Stocks getAllStocks(@Context Request request) {
request.getHeaders().getRequestHeaders().entrySet().forEach(entry -> System.out.println(entry.getKey() + "=" + entry
.getValue()));
return new Stocks(stockQuotes.values());
}
代码示例来源:origin: wso2/msf4j
/**
* Retrieve all stocks.
* http://localhost:8080/stockquote/all
*
* @return All stocks will be sent to the client as Json/xml
* according to the Accept header of the request.
*/
@GET
@Path("/all")
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Get all stocks",
notes = "Returns all stock items",
response = Stocks.class,
responseContainer = "List")
public Stocks getAllStocks(@Context Request request) {
request.getHeaders().getRequestHeaders().entrySet().forEach(entry -> log.info(entry.getKey() + "=" + entry
.getValue()));
return new Stocks(stockQuotes.values());
}
代码示例来源:origin: wso2/msf4j
/**
* Retrieve all stocks.
* http://localhost:8080/stockquote/all
*
* @return All stocks will be sent to the client as Json/xml
* according to the Accept header of the request.
*/
@GET
@Path("/all")
@Produces({"application/json", "text/xml"})
@ApiOperation(
value = "Get all stocks",
notes = "Returns all stock items",
response = Stocks.class,
responseContainer = "List")
public Stocks getAllStocks(@Context Request request) {
request.getHeaders().getRequestHeaders().entrySet().forEach(entry -> System.out.println(entry.getKey() + "=" + entry
.getValue()));
return new Stocks(stockQuotes.values());
}
代码示例来源:origin: org.wso2.analytics.apim/org.wso2.analytics.apim.rest.api.file
@Override
public Response usageUploadFilePost(InputStream analyticsInputStream, FileInfo analyticsDetail,
Request request) throws NotFoundException {
HttpHeaders httpHeaders = request.getHeaders();
String uploadedFileName = httpHeaders.getHeaderString(UploadServiceConstants.FILE_NAME_HEADER);
代码示例来源:origin: org.wso2.carbon.uiserver/org.wso2.carbon.uiserver
Map<String, String> httpHeaders = request.getHeaders().getRequestHeaders().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get(0)));
this.headers = Collections.unmodifiableMap(httpHeaders);
代码示例来源:origin: org.wso2.carbon.uis/org.wso2.carbon.uis
Map<String, String> httpHeaders = request.getHeaders().getRequestHeaders().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().get(0)));
this.headers = Collections.unmodifiableMap(httpHeaders);
代码示例来源:origin: org.wso2.carbon.uuf/org.wso2.carbon.uuf.httpconnector.msf4j
request.getHeaders().getAll().forEach(header -> this.headers.put(header.getName(), header.getValue()));
String cookieHeader = this.headers.get(HttpHeaders.COOKIE);
this.cookies = (cookieHeader == null) ? Collections.emptyMap() :
代码示例来源:origin: org.wso2.carbon.uis/org.wso2.carbon.uis.core
request.getHeaders().getAll().forEach(header -> this.headers.put(header.getName(), header.getValue()));
String cookieHeader = this.headers.get(HttpHeaders.COOKIE);
this.cookies = (cookieHeader == null) ? Collections.emptyMap() :
代码示例来源:origin: wso2/msf4j
@Override
public boolean interceptRequest(Request request, Response response) throws Exception {
HttpHeaders headers = request.getHeaders();
if (headers != null) {
String jwtHeader = headers.getHeaderString(JWT_HEADER);
if (jwtHeader != null) {
SignedJWT signedJWT = SignedJWT.parse(jwtHeader);
ReadOnlyJWTClaimsSet readOnlyJWTClaimsSet = signedJWT.getJWTClaimsSet();
if (readOnlyJWTClaimsSet != null) {
// Do something with claims
return true;
}
}
}
response.setHeader(javax.ws.rs.core.HttpHeaders.WWW_AUTHENTICATE, AUTH_TYPE_JWT);
response.setStatus(javax.ws.rs.core.Response.Status.UNAUTHORIZED.getStatusCode());
return false;
}
}
代码示例来源:origin: wso2/msf4j
@Override
public boolean interceptRequest(Request request, Response response) throws Exception {
SecurityErrorCode errorCode;
try {
HttpHeaders headers = request.getHeaders();
String authHeader = headers.getHeaderString(AUTHORIZATION_HTTP_HEADER);
if (authHeader != null && !authHeader.isEmpty()) {
return validateToken(authHeader);
} else {
throw new MSF4JSecurityException(SecurityErrorCode.AUTHENTICATION_FAILURE,
"Missing Authorization header is the request.`");
}
} catch (MSF4JSecurityException e) {
errorCode = e.getErrorCode();
log.error(e.getMessage() + " Requested Path: " + request.getUri());
}
handleSecurityError(errorCode, response);
return false;
}
代码示例来源:origin: org.wso2.msf4j/msf4j-core
@Override
public boolean interceptRequest(Request request, Response response) throws Exception {
SecurityErrorCode errorCode;
try {
HttpHeaders headers = request.getHeaders();
String authHeader = headers.getHeaderString(AUTHORIZATION_HTTP_HEADER);
if (authHeader != null && !authHeader.isEmpty()) {
return validateToken(authHeader);
} else {
throw new MSF4JSecurityException(SecurityErrorCode.AUTHENTICATION_FAILURE,
"Missing Authorization header is the request.`");
}
} catch (MSF4JSecurityException e) {
errorCode = e.getErrorCode();
log.error(e.getMessage() + " Requested Path: " + request.getUri());
}
handleSecurityError(errorCode, response);
return false;
}
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.analytics.auth.rest.api
.extractTokenFromHeaders(request.getHeaders(), IdPClientConstants.WSO2_SP_TOKEN);
if (accessToken != null) {
try {
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.analytics.msf4j.interceptor.common
Headers headers = request.getHeaders();
String authorizationHeader = request.getHeader(IdPClientConstants.AUTHORIZATION_HEADER);
if (authorizationHeader != null) {
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.authenticator
.extractTokenFromHeaders(request.getHeaders(), AuthenticatorConstants.ACCESS_TOKEN_2);
if (accessToken != null) {
try {
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.msf4j.interceptor.common
HttpHeaders headers = request.getHeaders();
String authorizationHeader = request.getHeader(SPConstants.AUTHORIZATION_HEADER);
if (authorizationHeader != null && authorizationHeader.contains(" ")) {
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.analytics.auth.rest.api
if (IdPClientConstants.REFRESH_GRANT_TYPE.equals(grantType)) {
refToken = AuthUtil
.extractTokenFromHeaders(request.getHeaders(), IdPClientConstants.WSO2_SP_REFRESH_TOKEN);
if (refToken == null) {
LOG.error("Unable to extract refresh token from the header for the request '"
代码示例来源:origin: wso2/msf4j
httpMonitoringEvent.setServiceContext(servicePath);
HttpHeaders httpHeaders = request.getHeaders();
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.authenticator
if (AuthenticatorConstants.REFRESH_GRANT.equals(grantType)) {
refToken = AuthUtil
.extractTokenFromHeaders(request.getHeaders(), AuthenticatorConstants.REFRESH_TOKEN_2);
if (refToken == null) {
ErrorDTO errorDTO = new ErrorDTO();
代码示例来源:origin: org.wso2.carbon.identity.gateway/org.wso2.carbon.identity.gateway.api
/**
* Update GatewayRequestBuilder.
*
* @param builder Builder.
* @param request MS4J request
* @throws GatewayClientException GatewayClientException
*/
protected void create(T builder, Request request)
throws GatewayClientException {
request.getHeaders().getAll().forEach(header -> {
builder.addHeader(header.getName(), header.getValue());
});
builder.setMethod(request.getHttpMethod());
builder.setContentType(request.getContentType());
builder.setRequestURI(request.getUri());
builder.setMethod(request.getHttpMethod());
builder.setAttributes((Map) request.getProperties());
builder.addParameter(Constants.QUERY_PARAMETERS,
(Serializable) request.getProperty(Constants.QUERY_PARAMETERS));
builder.addParameter(Constants.BODY_PARAMETERS, (Serializable) request.getProperty(Constants.BODY_PARAMETERS));
String[] queryStringParams = request.getUri().split("\\?");
if (queryStringParams.length > 1) {
builder.setQueryString(queryStringParams[1]);
} else {
builder.setQueryString(queryStringParams[0]);
}
if (logger.isDebugEnabled()) {
logger.debug("Successfully Updated the request builder in GatewayRequestBuilderFactory.");
}
}
内容来源于网络,如有侵权,请联系作者删除!