Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/auto/Addresses.java
38853 views
/*1* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 803111126* @summary fix krb5 caddr27* @compile -XDignore.symbol.file Addresses.java28* @run main/othervm -Dsun.net.spi.nameservice.provider.1=ns,mock Addresses29*/3031import sun.security.krb5.Config;3233import javax.security.auth.kerberos.KerberosTicket;34import java.net.Inet4Address;35import java.net.InetAddress;3637public class Addresses {3839public static void main(String[] args) throws Exception {4041KDC.saveConfig(OneKDC.KRB5_CONF, new OneKDC(null),42"noaddresses = false",43"extra_addresses = 10.0.0.10, 10.0.0.11 10.0.0.12");44Config.refresh();4546KerberosTicket ticket =47Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false)48.s().getPrivateCredentials(KerberosTicket.class)49.iterator().next();5051InetAddress loopback = InetAddress.getLoopbackAddress();52InetAddress extra1 = InetAddress.getByName("10.0.0.10");53InetAddress extra2 = InetAddress.getByName("10.0.0.11");54InetAddress extra3 = InetAddress.getByName("10.0.0.12");5556boolean loopbackFound = false;57boolean extra1Found = false;58boolean extra2Found = false;59boolean extra3Found = false;60boolean networkFound = false;6162for (InetAddress ia: ticket.getClientAddresses()) {63System.out.println(ia);64if (ia.equals(loopback)) {65loopbackFound = true;66System.out.println(" loopback found");67} else if (ia.equals(extra1)) {68extra1Found = true;69System.out.println(" extra1 found");70} else if (ia.equals(extra2)) {71extra2Found = true;72System.out.println(" extra2 found");73} else if (ia.equals(extra3)) {74extra3Found = true;75System.out.println(" extra3 found");76} else if (ia instanceof Inet4Address) {77networkFound = true;78System.out.println(" another address (" + ia +79"), assumed real network");80}81}8283if (!loopbackFound || !networkFound84|| !extra1Found || !extra2Found || !extra3Found ) {85throw new Exception();86}87}88}899091