ok2c commented on code in PR #399: URL: https://github.com/apache/httpcomponents-client/pull/399#discussion_r1045756872
########## httpclient5/src/main/java/org/apache/hc/client5/http/auth/BearerToken.java: ########## @@ -0,0 +1,120 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ +package org.apache.hc.client5.http.auth; + +import java.io.Serializable; +import java.security.Principal; +import java.util.Objects; + +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; +import org.apache.hc.core5.util.Args; + +/** + * Opaque token {@link Credentials} usually representing a set of claims, often encrypted + * or signed. The JWT (JSON Web Token) is among most widely used tokens used at the time + * of writing. + * + * @since 5.3 + */ +@Contract(threading = ThreadingBehavior.IMMUTABLE) +public class BearerToken implements Credentials, Serializable { + + private final Principal principal; + private final String token; + + /** + * The constructor with the user principal and token arguments. + * + * @param userPrincipal the user principal + * @param token the token + * + * @see BasicUserPrincipal + * @see NTUserPrincipal + */ + public BearerToken(final Principal userPrincipal, final String token) { + super(); + this.principal = Args.notNull(userPrincipal, "User principal"); Review Comment: @michael-o No matter what perspective, HTTP requests are always executed on someone's behalf and tokens is not something you find lying on the ground. They are acquired for a specific principal. It is bogus only if you make it bogus. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org