001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020 package javax.mail; 021 022 import java.net.InetAddress; 023 024 /** 025 * @version $Rev: 467553 $ $Date: 2006-10-25 00:01:51 -0400 (Wed, 25 Oct 2006) $ 026 */ 027 public abstract class Authenticator { 028 private InetAddress host; 029 private int port; 030 private String prompt; 031 private String protocol; 032 private String username; 033 034 synchronized PasswordAuthentication authenticate(InetAddress host, int port, String protocol, String prompt, String username) { 035 this.host = host; 036 this.port = port; 037 this.protocol = protocol; 038 this.prompt = prompt; 039 this.username = username; 040 return getPasswordAuthentication(); 041 } 042 043 protected final String getDefaultUserName() { 044 return username; 045 } 046 047 protected PasswordAuthentication getPasswordAuthentication() { 048 return null; 049 } 050 051 protected final int getRequestingPort() { 052 return port; 053 } 054 055 protected final String getRequestingPrompt() { 056 return prompt; 057 } 058 059 protected final String getRequestingProtocol() { 060 return protocol; 061 } 062 063 protected final InetAddress getRequestingSite() { 064 return host; 065 } 066 }