001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.oauth2.sdk; 019 020 021import com.nimbusds.oauth2.sdk.token.AccessToken; 022 023import java.net.URI; 024 025 026/** 027 * Base abstract class for protected resource requests using an OAuth 2.0 028 * access token. 029 * 030 * <p>Related specifications: 031 * 032 * <ul> 033 * <li>OAuth 2.0 (RFC 6749) 034 * </ul> 035 */ 036 public abstract class ProtectedResourceRequest extends AbstractRequest { 037 038 039 /** 040 * The access token (optional). 041 */ 042 private final AccessToken accessToken; 043 044 045 /** 046 * Creates a new protected resource request. 047 * 048 * @param uri The URI of the protected resource. May be 049 * {@code null} if the {@link #toHTTPRequest()} 050 * method is not going to be used. 051 * @param accessToken An access token for the request, {@code null} if 052 * none. 053 */ 054 protected ProtectedResourceRequest(final URI uri, final AccessToken accessToken) { 055 056 super(uri); 057 058 this.accessToken = accessToken; 059 } 060 061 062 /** 063 * Gets the access token for this protected resource request. 064 * 065 * @return The access token, {@code null} if none. 066 */ 067 public AccessToken getAccessToken() { 068 069 return accessToken; 070 } 071 }