001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2019 microBean™.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
014 * implied.  See the License for the specific language governing
015 * permissions and limitations under the License.
016 */
017package org.microbean.jersey.netty;
018
019import java.net.URI; // for javadoc only
020
021import java.security.Principal;
022
023import javax.ws.rs.core.SecurityContext;
024
025import org.glassfish.jersey.server.ApplicationHandler; // for javadoc only
026
027/**
028 * A fallback {@link SecurityContext} implementation that {@linkplain
029 * #getUserPrincipal() provides no user <code>Principal</code>},
030 * {@linkplain #isUserInRole(String) has no role or user database}, is
031 * {@linkplain #isSecure() not secure}, and that {@linkplain
032 * #getAuthenticationScheme() does not require authentication}.
033 *
034 * @author <a href="https://about.me/lairdnelson"
035 * target="_parent">Laird Nelson</a>
036 *
037 * @see SecurityContext
038 */
039public class SecurityContextAdapter implements SecurityContext {
040
041
042  /*
043   * Constructors.
044   */
045
046
047  /**
048   * Creates a new {@link SecurityContextAdapter}.
049   */
050  public SecurityContextAdapter() {
051    super();
052  }
053
054
055  /*
056   * Instance methods.
057   */
058  
059
060  /**
061   * Returns {@code false} in all cases.
062   *
063   * @param role ignored by this implementation; may be {@code null}
064   *
065   * @return {@code false} in all cases
066   *
067   * @see SecurityContext#isUserInRole(String)
068   */
069  @Override
070  public boolean isUserInRole(final String role) {
071    return false;
072  }
073
074  /**
075   * Returns {@code false} in all cases.
076   *
077   * @return {@code false} in all cases
078   *
079   * @see SecurityContext#isSecure()
080   */
081  @Override
082  public boolean isSecure() {
083    return false;
084  }
085
086  /**
087   * Returns {@code null} when invoked.
088   *
089   * @return {@code null} when invoked
090   *
091   * @see SecurityContext#getUserPrincipal()
092   */
093  @Override
094  public Principal getUserPrincipal() {
095    return null;
096  }
097
098  /**
099   * Returns {@code null} when invoked.
100   *
101   * @return {@code null} when invoked
102   *
103   * @see SecurityContext#getAuthenticationScheme()
104   */
105  @Override
106  public String getAuthenticationScheme() {
107    return null;
108  }
109
110};