Set the request authentication.

@param request The request containing all of the options related to the update request.
@return Result of the setHTTPSAcceleration operation returned by the service.
508283
public SetRequestAuthResponse setRequestAuth(SetRequestAuthRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = 
                createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("requestAuth", "");
        this.attachRequestToBody(request, internalRequest);
        return invokeHttpClient(internalRequest, SetRequestAuthResponse.class);
    }
595638
public DisableDomainResponse disableDomain(DisableDomainRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DOMAIN, request.getDomain());
        internalRequest.addParameter("disable", "");
        return invokeHttpClient(internalRequest, DisableDomainResponse.class);
    }
359833
public Response api(Request request) throws IOException {
    Request req = new Request();
    req.setMethod(request.getMethod());
    req.setBaseUri(this.host);
    req.setEndpoint("/" + version + "/" + request.getEndpoint());
    req.setBody(request.getBody());
    for (Map.Entry<String, String> header : this.requestHeaders.entrySet()) {
      req.addHeader(header.getKey(), header.getValue());
    }
    for (Map.Entry<String, String> queryParam : request.getQueryParams().entrySet()) {
      req.addQueryParam(queryParam.getKey(), queryParam.getValue());
    }

    return makeCall(req);
  }
1118552
private String getAuthorizationHeaderValue(HttpRequest request, byte[] body) {
		return signingUtils.buildAuthorizationHeaderValue(request, body, oauth1Credentials);
	}
381307
public SetDomainIpACLResponse setDomainIpACL(SetDomainIpACLRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("ipACL","");
        this.attachRequestToBody(request, internalRequest);
        return invokeHttpClient(internalRequest, SetDomainIpACLResponse.class);
    }
1355851
protected boolean isAuthorizationRequest(final HttpServletRequest request, final HttpServletResponse response) {
        val requestPath = request.getRequestURI();
        return doesUriMatchPattern(requestPath, OAuth20Constants.AUTHORIZE_URL);
    }
1231609
public synchronized void setRequest(HttpServletRequest request) {

        if (perThreadRequest == null) {
            perThreadRequest = new ThreadLocal<HttpServletRequest>();
        }
        perThreadRequest.set(request);
    }
88423
protected void configureBasicAuth(HttpRequest request) {
        try {
            String username = getConfig().getUsername();
            String password = getConfig().getPassword();
            String up = username + ":" + password; //$NON-NLS-1$
            String base64 = new String(Base64.encodeBase64(up.getBytes("UTF-8"))); //$NON-NLS-1$
            String authHeader = "Basic " + base64; //$NON-NLS-1$
            request.setHeader("Authorization", authHeader); //$NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
511158
public void setRequest(ServletRequest request) {
        if (request != null) {
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("set request: %s", request));
            }
            this.threadLocalRequests.set((HttpServletRequest) request);
        } else {
            //if null, remove from threadLocalRequests
            // @see WindowTask#run 's finally
            if (logger.isDebugEnabled()) {
                HttpServletRequest tmpRequest = this.threadLocalRequests.get();
                logger.debug(String.format("remove request: %s", tmpRequest));
            }
            this.threadLocalRequests.remove();
        }
    }
768405
public static String extractAccessKey(HttpServletRequest request) {
		if (request == null) {
			return "";
		}
		String accessKey = "";
		String auth = request.getHeader(HttpHeaders.AUTHORIZATION);
		boolean isAnonymousRequest = isAnonymousRequest(request);
		if (StringUtils.isBlank(auth)) {
			auth = request.getParameter("X-Amz-Credential");
			if (!StringUtils.isBlank(auth)) {
				accessKey = StringUtils.substringBetween(auth, "=", "/");
			}
		} else {
			if (isAnonymousRequest) {
				accessKey = StringUtils.substringAfter(auth, "Anonymous").trim();
			} else {
				accessKey = StringUtils.substringBetween(auth, "=", "/");
			}
		}
		if (isAnonymousRequest && StringUtils.isBlank(accessKey)) {
			// try to get access key from parameter
			accessKey = request.getParameter("accessKey");
		}
		return accessKey;
	}
1065941
public boolean isCompliantWithRequestAccept(Request request) {
        if (producedMediaTypes == null || producedMediaTypes.isEmpty() || request == null
                || request.getHeader(HeaderNames.ACCEPT) == null) {
            return true;
        } else {
            for (MediaType mt : producedMediaTypes) {
                if (request.accepts(mt.toString())) {
                    return true;
                }
            }
            return false;
        }
    }
1262320
public static void setCurrentAuthentication(Authentication authentication) {
        RequestContext context = RequestContext.getCurrent();
        if (context != null) {
            setAuthentication(context.getRequest(), authentication);
        }
    }
1223905
public boolean authenticate(HttpServletRequest pRequest) {
        String auth = pRequest.getHeader("Authorization");
        if (auth == null) {
            return false;
        }
        AuthorizationHeaderParser.Result authInfo = AuthorizationHeaderParser.parse(auth);
        return authInfo.isValid() && doAuthenticate(pRequest, authInfo);
    }
595633
public boolean actionModifyAce(HttpServletRequest request) {

        String file = getParamResource();

        // get request parameters
        String name = getParamName();
        String type = getParamType();
        String inherit = request.getParameter(PARAM_INHERIT);
        String overWriteInherited = request.getParameter(PARAM_OVERWRITEINHERITED);
        String responsible = request.getParameter(PARAM_RESPONSIBLE);

        // get the new permissions
        Set<String> permissionKeys = CmsPermissionSet.getPermissionKeys();
        int allowValue = 0;
        int denyValue = 0;
        String key, param;
        int value, paramInt;

        Iterator<String> i = permissionKeys.iterator();
        // loop through all possible permissions
        while (i.hasNext()) {
            key = i.next();
            value = CmsPermissionSet.getPermissionValue(key);
            // set the right allowed and denied permissions from request parameters
            try {
                param = request.getParameter(value + PERMISSION_ALLOW);
                paramInt = Integer.parseInt(param);
                allowValue |= paramInt;
            } catch (Exception e) {
                // can usually be ignored
                if (LOG.isInfoEnabled()) {
                    LOG.info(e.getLocalizedMessage());
                }
            }
            try {
                param = request.getParameter(value + PERMISSION_DENY);
                paramInt = Integer.parseInt(param);
                denyValue |= paramInt;
            } catch (Exception e) {
                // can usually be ignored
                if (LOG.isInfoEnabled()) {
                    LOG.info(e.getLocalizedMessage());
                }
            }
        }

        // get the current Ace to get the current ace flags
        try {
            List<CmsAccessControlEntry> allEntries = getCms().getAccessControlEntries(file, false);
            int flags = 0;
            for (int k = 0; k < allEntries.size(); k++) {
                CmsAccessControlEntry curEntry = allEntries.get(k);
                String curType = getEntryType(curEntry.getFlags(), false);
                I_CmsPrincipal p;
                try {
                    p = CmsPrincipal.readPrincipalIncludingHistory(getCms(), curEntry.getPrincipal());
                } catch (CmsException e) {
                    p = null;
                }
                if (((p != null) && p.getName().equals(name) && curType.equals(type))) {
                    flags = curEntry.getFlags();
                    break;
                } else if (p == null) {
                    // check if it is the case of a role
                    CmsRole role = CmsRole.valueOfId(curEntry.getPrincipal());
                    if ((role != null) && name.equals(role.getRoleName())) {
                        flags = curEntry.getFlags();
                        break;
                    } else if ((curEntry.getPrincipal().equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID)
                        && name.equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME))
                        || (curEntry.getPrincipal().equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID)
                            && name.equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME))) {
                        flags = curEntry.getFlags();
                        break;
                    }
                }
            }

            // modify the ace flags to determine inheritance of the current ace
            if (Boolean.valueOf(inherit).booleanValue()) {
                flags |= CmsAccessControlEntry.ACCESS_FLAGS_INHERIT;
            } else {
                flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_INHERIT;
            }

            // modify the ace flags to determine overwriting of inherited ace
            if (Boolean.valueOf(overWriteInherited).booleanValue()) {
                flags |= CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE;
            } else {
                flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE;
            }

            if (Boolean.valueOf(responsible).booleanValue()) {
                flags |= CmsAccessControlEntry.ACCESS_FLAGS_RESPONSIBLE;
            } else {
                flags &= ~CmsAccessControlEntry.ACCESS_FLAGS_RESPONSIBLE;
            }

            // lock resource if autolock is enabled
            checkLock(getParamResource());
            // try to change the access entry
            if (name.equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.toString())) {
                getCms().chacc(
                    file,
                    type,
                    CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME,
                    allowValue,
                    denyValue,
                    flags);
            } else if (name.equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.toString())) {
                getCms().chacc(
                    file,
                    type,
                    CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME,
                    allowValue,
                    denyValue,
                    flags);
            } else {
                getCms().chacc(file, type, name, allowValue, denyValue, flags);
            }
            return true;
        } catch (CmsException e) {
            m_errorMessages.add(key(Messages.ERR_CHACC_MODIFY_ENTRY_0));
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            return false;
        }
    }
65939
protected Optional<MutableHttpResponse<?>> handleRequest(HttpRequest request) {
        HttpHeaders headers = request.getHeaders();
        Optional<String> originHeader = headers.getOrigin();
        if (originHeader.isPresent()) {

            String requestOrigin = originHeader.get();
            boolean preflight = CorsUtil.isPreflightRequest(request);

            Optional<CorsOriginConfiguration> optionalConfig = getConfiguration(requestOrigin);

            if (optionalConfig.isPresent()) {
                CorsOriginConfiguration config = optionalConfig.get();

                HttpMethod requestMethod = request.getMethod();

                List<HttpMethod> allowedMethods = config.getAllowedMethods();

                if (!isAnyMethod(allowedMethods)) {
                    HttpMethod methodToMatch = preflight ? headers.getFirst(ACCESS_CONTROL_REQUEST_METHOD, HttpMethod.class).orElse(requestMethod) : requestMethod;
                    if (allowedMethods.stream().noneMatch(method -> method.equals(methodToMatch))) {
                        return Optional.of(HttpResponse.status(HttpStatus.FORBIDDEN));
                    }
                }

                if (preflight) {
                    Optional<List> accessControlHeaders = headers.get(ACCESS_CONTROL_REQUEST_HEADERS, Argument.of(List.class, String.class));

                    List<String> allowedHeaders = config.getAllowedHeaders();

                    if (!isAny(allowedHeaders) && accessControlHeaders.isPresent()) {
                        if (!accessControlHeaders.get().stream()
                            .allMatch(header -> allowedHeaders.stream()
                                .anyMatch(allowedHeader -> allowedHeader.equals(header.toString().trim())))) {
                            return Optional.of(HttpResponse.status(HttpStatus.FORBIDDEN));
                        }
                    }

                    MutableHttpResponse<Object> ok = HttpResponse.ok();
                    handleResponse(request, ok);
                    return Optional.of(ok);
                }
            }
        }

        return Optional.empty();
    }
1348235
protected String extractHeaderToken(HttpServletRequest request) {
		Enumeration<String> headers = request.getHeaders("Authorization");
		while (headers.hasMoreElements()) { // typically there is only one (most servers enforce that)
			String value = headers.nextElement();
			if ((value.toLowerCase().startsWith(OAuth2AccessToken.BEARER_TYPE.toLowerCase()))) {
				String authHeaderValue = value.substring(OAuth2AccessToken.BEARER_TYPE.length()).trim();
				// Add this here for the auth details later. Would be better to change the signature of this method.
				request.setAttribute(OAuth2AuthenticationDetails.ACCESS_TOKEN_TYPE,
						value.substring(0, OAuth2AccessToken.BEARER_TYPE.length()).trim());
				int commaIndex = authHeaderValue.indexOf(',');
				if (commaIndex > 0) {
					authHeaderValue = authHeaderValue.substring(0, commaIndex);
				}
				return authHeaderValue;
			}
		}

		return null;
	}
731433
public void setRequest(HttpServletRequest request) {
		WaybackRequest wbRequest = new WaybackRequest();
		wbRequest.extractHttpRequestInfo(request);
		this.wbRequest = wbRequest;
	}