001/* 002 * Copyright 2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.revetsec.soklet; 018 019import com.revetsec.oauth.BearerToken; 020import com.revetsec.oauth.BearerTokenResult; 021import com.google.errorprone.annotations.CheckReturnValue; 022import com.soklet.Request; 023import org.jspecify.annotations.NonNull; 024 025import javax.annotation.concurrent.ThreadSafe; 026 027/** 028 * Raw Authorization-header transport for Soklet resource servers. Parsing a bearer credential grants no identity 029 * or permission; the application validates it through core and makes its own scope and object decisions. 030 * 031 * @author <a href="https://www.revetkn.com">Mark Allen</a> 032 * @since 1.0.0 033 */ 034@ThreadSafe 035public final class SokletBearer { 036 037 private SokletBearer() { 038 // Non-instantiable 039 } 040 041 /** 042 * Parses all materialized Authorization values as an absent, unverified present or malformed result. 043 * Every materialized header value is retained, including identical duplicates and differently cased field names. 044 * Query, body and cookies are never bearer transports. Core owns the credential grammar and size limit. 045 * 046 * @param request the resource request 047 * @return the raw-header parsing outcome 048 * @throws NullPointerException if request is null 049 * @since 1.0.0 050 */ 051 @CheckReturnValue 052 public static @NonNull BearerTokenResult bearerTokenResultFor(@NonNull Request request) { 053 return BearerToken.fromAuthorizationHeaderValuesResult(SokletOAuth.collectHeaderValues(request, "Authorization")); 054 } 055 056}