Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/krb5/config/NamingManager.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*/2223package javax.naming.spi;2425import com.sun.jndi.dns.DnsContext;26import java.util.Hashtable;27import javax.naming.Context;28import javax.naming.NamingException;29import javax.naming.directory.Attribute;30import javax.naming.directory.Attributes;31import javax.naming.directory.BasicAttribute;32import javax.naming.directory.BasicAttributes;3334/**35* A fake javax.naming.spi.NamingManager. It allows reading a DNS36* record without contacting a real server.37*38* See DNS.java and dns.sh.39*/40public class NamingManager {41NamingManager() {}42public static Context getURLContext(43String scheme, Hashtable<?,?> environment)44throws NamingException {45return new DnsContext("", null, new Hashtable<String,String>()) {46public Attributes getAttributes(String name, String[] attrIds)47throws NamingException {48return new BasicAttributes() {49public Attribute get(String attrID) {50BasicAttribute ba = new BasicAttribute(attrID);51ba.add("1 1 99 b.com.");52ba.add("0 0 88 a.com."); // 2nd has higher priority53return ba;54}55};56}57};58}59}606162