@Override public String getHeader(String name) { return httpRequest.getHeader(name); }
@Override public String getHeader(String name) { return httpRequest.getHeader(name); }
protected RequestLocation[] getRequestLocations(HttpRequest request, boolean addHeaderLocation) { HttpMethod method = request.getMethod(); String contentType = request.getHeader(CONTENT_TYPE_HEADER); List<RequestLocation> requestLocationList = new ArrayList<RequestLocation>(); if (addHeaderLocation) { requestLocationList.add(RequestLocation.HEADER); } EnumSet<HttpMethod> bodyLocationMethods = EnumSet.of(HttpMethod.POST, HttpMethod.DELETE, HttpMethod.PUT); if (bodyLocationMethods.contains(method) && hasContentType(contentType, MediaType.APPLICATION_FORM_URLENCODED_VALUE)) { requestLocationList.add(RequestLocation.BODY); } RequestLocation[] requestLocations = new RequestLocation[requestLocationList.size()]; return requestLocationList.toArray(requestLocations); } }
protected RequestLocation[] getRequestLocations(HttpRequest request, boolean addHeaderLocation) { HttpMethod method = request.getMethod(); String contentType = request.getHeader(CONTENT_TYPE_HEADER); List<RequestLocation> requestLocationList = new ArrayList<RequestLocation>(); if (addHeaderLocation) { requestLocationList.add(RequestLocation.HEADER); } EnumSet<HttpMethod> bodyLocationMethods = EnumSet.of(HttpMethod.POST, HttpMethod.DELETE, HttpMethod.PUT); if (bodyLocationMethods.contains(method) && hasContentType(contentType, MediaType.APPLICATION_FORM_URLENCODED_VALUE)) { requestLocationList.add(RequestLocation.BODY); } RequestLocation[] requestLocations = new RequestLocation[requestLocationList.size()]; return requestLocationList.toArray(requestLocations); } }
public AuthenticationRequest createFrom(HttpRequest httpRequest) { String authzHeaderValue = httpRequest.getHeader(AUTHORIZATION_HEADER); String[] schemeAndValue = getSchemeAndValue(authzHeaderValue); if (schemeAndValue == null) { RequestLocation[] requestLocations = getRequestLocations(httpRequest, false); if (requestLocations.length > 0) { return OAuthAuthenticationRequestFactory.INSTANCE.createRequest(httpRequest, requestLocations); } } else { if (schemeAndValue[0].equalsIgnoreCase(BEARER_AUTHENTICATION_SCHEME)) { RequestLocation[] requestLocations = getRequestLocations(httpRequest, true); return OAuthAuthenticationRequestFactory.INSTANCE.createRequest(httpRequest, requestLocations); } if (schemeAndValue[0].equalsIgnoreCase(BASIC_AUTHENTICATION_SCHEME)) { if (hasContentType(httpRequest.getHeader(CONTENT_TYPE_HEADER), MediaType.APPLICATION_FORM_URLENCODED_VALUE)) { Map<String, String[]> parameterMap = httpRequest.getParameters(); if (parameterMap != null && parameterMap.containsKey(GRANT_TYPE_PARAMETER)) { return OAuthAuthenticationRequestFactory.INSTANCE.createTokenRequest(httpRequest); } } return new DefaultBasicApiAuthenticationRequest(httpRequest); } } throw ApiAuthenticationExceptionFactory.newApiAuthenticationException(InvalidAuthenticationException.class); }
public AuthenticationRequest createFrom(HttpRequest httpRequest) { String authzHeaderValue = httpRequest.getHeader(AUTHORIZATION_HEADER); String[] schemeAndValue = getSchemeAndValue(authzHeaderValue); if (schemeAndValue == null) { RequestLocation[] requestLocations = getRequestLocations(httpRequest, false); if (requestLocations.length > 0) { return OAuthAuthenticationRequestFactory.INSTANCE.createRequest(httpRequest, requestLocations); } } else { if (schemeAndValue[0].equalsIgnoreCase(BEARER_AUTHENTICATION_SCHEME)) { RequestLocation[] requestLocations = getRequestLocations(httpRequest, true); return OAuthAuthenticationRequestFactory.INSTANCE.createRequest(httpRequest, requestLocations); } if (schemeAndValue[0].equalsIgnoreCase(BASIC_AUTHENTICATION_SCHEME)) { if (hasContentType(httpRequest.getHeader(CONTENT_TYPE_HEADER), MediaType.APPLICATION_FORM_URLENCODED_VALUE)) { Map<String, String[]> parameterMap = httpRequest.getParameters(); if (parameterMap != null && parameterMap.containsKey(GRANT_TYPE_PARAMETER)) { return OAuthAuthenticationRequestFactory.INSTANCE.createTokenRequest(httpRequest); } } return new DefaultBasicApiAuthenticationRequest(httpRequest); } } throw ApiAuthenticationExceptionFactory.newApiAuthenticationException(InvalidAuthenticationException.class); }
private DefaultBasicApiAuthenticationRequest(HttpServletRequestWrapper httpServletRequestWrapper, HttpRequest httpRequest) { this.httpServletRequestWrapper = httpServletRequestWrapper; this.httpRequest = httpRequest; Assert.isTrue(hasHttpServletRequest() || hasHttpRequest()); String authzHeaderValue; if (hasHttpRequest()) { authzHeaderValue = httpRequest.getHeader(ApiAuthenticationRequestFactory.AUTHORIZATION_HEADER); } else { authzHeaderValue = httpServletRequestWrapper.getHeader(ApiAuthenticationRequestFactory.AUTHORIZATION_HEADER); } String[] authTokens = getAuthenticationTokens(authzHeaderValue); id = authTokens[0]; secret = authTokens[1]; }
private DefaultBasicApiAuthenticationRequest(HttpServletRequestWrapper httpServletRequestWrapper, HttpRequest httpRequest) { this.httpServletRequestWrapper = httpServletRequestWrapper; this.httpRequest = httpRequest; Assert.isTrue(hasHttpServletRequest() || hasHttpRequest()); String authzHeaderValue; if (hasHttpRequest()) { authzHeaderValue = httpRequest.getHeader(ApiAuthenticationRequestFactory.AUTHORIZATION_HEADER); } else { authzHeaderValue = httpServletRequestWrapper.getHeader(ApiAuthenticationRequestFactory.AUTHORIZATION_HEADER); } String[] authTokens = getAuthenticationTokens(authzHeaderValue); id = authTokens[0]; secret = authTokens[1]; }