001/* 002 * JGrapes Event Driven Framework 003 * Copyright (C) 2022 Michael N. Lipp 004 * 005 * This program is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, but 011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU General Public License along 016 * with this program; if not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jgrapes.mail; 020 021import jakarta.mail.internet.AddressException; 022import jakarta.mail.internet.InternetAddress; 023import java.io.UnsupportedEncodingException; 024import java.security.Principal; 025 026/** 027 * A variant of {@link InternetAddress} that can be used as a 028 * {@link Principal}. 029 */ 030public class InternetAddressPrincipal extends InternetAddress 031 implements Principal { 032 033 private static final long serialVersionUID = -6900967855203936680L; 034 035 /** 036 * See {@link InternetAddress#InternetAddress()}. 037 */ 038 public InternetAddressPrincipal() { 039 super(); 040 } 041 042 /** 043 * See {@link InternetAddress#InternetAddress(String, boolean))}. 044 * 045 * @param address the address 046 * @param strict the strict 047 * @throws AddressException the address exception 048 */ 049 public InternetAddressPrincipal(String address, boolean strict) 050 throws AddressException { 051 super(address, strict); 052 } 053 054 /** 055 * See {@link InternetAddress#InternetAddress(String, String, String)))}. 056 * 057 * @param address the address 058 * @param personal the personal 059 * @param charset the charset 060 * @throws UnsupportedEncodingException the unsupported encoding exception 061 */ 062 public InternetAddressPrincipal(String address, String personal, 063 String charset) throws UnsupportedEncodingException { 064 super(address, personal, charset); 065 } 066 067 /** 068 * See {@link InternetAddress#InternetAddress(String, String)))}. 069 * 070 * @param address the address 071 * @param personal the personal 072 * @throws UnsupportedEncodingException the unsupported encoding exception 073 */ 074 public InternetAddressPrincipal(String address, String personal) 075 throws UnsupportedEncodingException { 076 super(address, personal); 077 } 078 079 /** 080 * See {@link InternetAddress#InternetAddress(String)))}. 081 * 082 * @param address the address 083 * @throws AddressException the address exception 084 */ 085 public InternetAddressPrincipal(String address) throws AddressException { 086 super(address); 087 } 088 089 @Override 090 public String getName() { 091 return getAddress(); 092 } 093 094}