View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.app.web.base.login;
17  
18  import org.lastaflute.web.login.credential.LoginCredential;
19  
20  /**
21   * SPNEGO authentication credential implementation.
22   *
23   * This class represents login credentials obtained through SPNEGO (Security Provider
24   * Negotiation Protocol) authentication. It contains the username extracted from the
25   * SPNEGO authentication process, typically from a Kerberos ticket.
26   */
27  public class SpnegoCredential implements LoginCredential, FessCredential {
28  
29      /** The username extracted from SPNEGO authentication. */
30      private final String username;
31  
32      /**
33       * Constructs a new SpnegoCredential with the specified username.
34       *
35       * @param username The username obtained from SPNEGO authentication
36       */
37      public SpnegoCredential(final String username) {
38          this.username = username;
39      }
40  
41      /**
42       * Gets the user identifier from this credential.
43       *
44       * @return The username from SPNEGO authentication
45       */
46      @Override
47      public String getUserId() {
48          return username;
49      }
50  
51      /**
52       * Returns a string representation of this credential.
53       *
54       * @return A string representation containing the username in braces
55       */
56      @Override
57      public String toString() {
58          return "{" + username + "}";
59      }
60  
61  }