1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.net.www.protocol.http;
  27 
  28 import java.io.Serializable;
  29 import java.net.PasswordAuthentication;
  30 
  31 /**
  32  * AuthCacheValue: interface to minimize exposure to authentication cache
  33  * for external users (i.e. plugin)
  34  *
  35  * @author Michael McMahon
  36  */
  37 
  38 public abstract class AuthCacheValue implements Serializable {
  39 
  40     @java.io.Serial
  41     static final long serialVersionUID = 735249334068211611L;
  42 
  43     public enum Type {
  44         Proxy,
  45         Server
  46     };
  47 
  48     /**
  49      * Caches authentication info entered by user.  See cacheKey()
  50      */
  51     protected static AuthCache cache = new AuthCacheImpl();
  52 
  53     public static void setAuthCache (AuthCache map) {
  54         cache = map;
  55     }
  56 
  57     /* Package private ctor to prevent extension outside package */
  58 
  59     AuthCacheValue() {}
  60 
  61     /**
  62      * Proxy or Server
  63      */
  64     abstract Type getAuthType ();
  65 
  66     /**
  67      * Authentication scheme
  68      */
  69     abstract AuthScheme getAuthScheme();
  70 
  71    /**
  72     * name of server/proxy
  73     */
  74     abstract String getHost ();
  75 
  76    /**
  77     * portnumber of server/proxy
  78     */
  79     abstract int getPort();
  80 
  81    /**
  82     * realm of authentication if known
  83     */
  84     abstract String getRealm();
  85 
  86     /**
  87      * root path of realm or the request path if the root
  88      * is not known yet.
  89      */
  90     abstract String getPath();
  91 
  92     /**
  93      * returns http or https
  94      */
  95     abstract String getProtocolScheme();
  96 
  97     /**
  98      * the credentials associated with this authentication
  99      */
 100     abstract PasswordAuthentication credentials();
 101 }