當前位置: 首頁>>代碼示例>>Java>>正文


Java InitialDirContext.getAttributes方法代碼示例

本文整理匯總了Java中javax.naming.directory.InitialDirContext.getAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java InitialDirContext.getAttributes方法的具體用法?Java InitialDirContext.getAttributes怎麽用?Java InitialDirContext.getAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.directory.InitialDirContext的用法示例。


在下文中一共展示了InitialDirContext.getAttributes方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lookupMailHosts

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static String[] lookupMailHosts(String domainName) throws NamingException {
	InitialDirContext iDirC = new InitialDirContext();
	Attributes attributes = iDirC.getAttributes("dns:/" + domainName, new String[] { "MX" });
	Attribute attributeMX = attributes.get("MX");
	if (attributeMX == null) {
		return (new String[] { domainName });
	}
	String[][] pvhn = new String[attributeMX.size()][2];
	for (int i = 0; i < attributeMX.size(); i++) {
		pvhn[i] = ("" + attributeMX.get(i)).split("\\s+");
	}
	Arrays.sort(pvhn, new Comparator<String[]>() {
		public int compare(String[] o1, String[] o2) {
			return (Integer.parseInt(o1[0]) - Integer.parseInt(o2[0]));
		}
	});
	String[] sortedHostNames = new String[pvhn.length];
	for (int i = 0; i < pvhn.length; i++) {
		sortedHostNames[i] = pvhn[i][1].endsWith(".") ? pvhn[i][1].substring(0, pvhn[i][1].length() - 1) : pvhn[i][1];
	}
	return sortedHostNames;
}
 
開發者ID:Protryon,項目名稱:AvunaHTTPD-Java,代碼行數:23,代碼來源:EmailRouter.java

示例2: getServerAddress

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
/**
 * Returns a server's address and port for the specified hostname, looking up the SRV record if possible
 */
private static String[] getServerAddress(String par0Str)
{
    try
    {
        String var1 = "com.sun.jndi.dns.DnsContextFactory";
        Class.forName("com.sun.jndi.dns.DnsContextFactory");
        Hashtable var2 = new Hashtable();
        var2.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
        var2.put("java.naming.provider.url", "dns:");
        var2.put("com.sun.jndi.dns.timeout.retries", "1");
        InitialDirContext var3 = new InitialDirContext(var2);
        Attributes var4 = var3.getAttributes("_minecraft._tcp." + par0Str, new String[] {"SRV"});
        String[] var5 = var4.get("srv").get().toString().split(" ", 4);
        return new String[] {var5[3], var5[2]};
    }
    catch (Throwable var6)
    {
        return new String[] {par0Str, Integer.toString(25565)};
    }
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:24,代碼來源:ServerAddress.java

示例3: lookupSrv

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static String[] lookupSrv(String p_lookupSrv_0_)
{
    try
    {
        String s1 = "com.sun.jndi.dns.DnsContextFactory";
        Class.forName("com.sun.jndi.dns.DnsContextFactory");
        Hashtable hashtable = new Hashtable();
        hashtable.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
        hashtable.put("java.naming.provider.url", "dns:");
        hashtable.put("com.sun.jndi.dns.timeout.retries", "1");
        InitialDirContext initialdircontext = new InitialDirContext(hashtable);
        Attributes attributes = initialdircontext.getAttributes("_minecraft._tcp." + p_lookupSrv_0_, new String[] {"SRV"});
        String[] astring = attributes.get("srv").get().toString().split(" ", 4);
        return new String[] {astring[3], astring[2]};
    }
    catch (Throwable throwable)
    {
        return new String[] {p_lookupSrv_0_, Integer.toString(25565)};
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:21,代碼來源:RealmsServerAddress.java

示例4: getServerAddress

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static String[] getServerAddress(String p_78863_0_)
{
    try
    {
        String s1 = "com.sun.jndi.dns.DnsContextFactory";
        Class.forName("com.sun.jndi.dns.DnsContextFactory");
        Hashtable hashtable = new Hashtable();
        hashtable.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
        hashtable.put("java.naming.provider.url", "dns:");
        hashtable.put("com.sun.jndi.dns.timeout.retries", "1");
        InitialDirContext initialdircontext = new InitialDirContext(hashtable);
        Attributes attributes = initialdircontext.getAttributes("_minecraft._tcp." + p_78863_0_, new String[] {"SRV"});
        String[] astring = attributes.get("srv").get().toString().split(" ", 4);
        return new String[] {astring[3], astring[2]};
    }
    catch (Throwable throwable)
    {
        return new String[] {p_78863_0_, Integer.toString(25565)};
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:21,代碼來源:ServerAddress.java

示例5: func_78863_b

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static String[] func_78863_b(String p_78863_0_) {
   try {
      String var1 = "com.sun.jndi.dns.DnsContextFactory";
      Class.forName("com.sun.jndi.dns.DnsContextFactory");
      Hashtable var2 = new Hashtable();
      var2.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
      var2.put("java.naming.provider.url", "dns:");
      var2.put("com.sun.jndi.dns.timeout.retries", "1");
      InitialDirContext var3 = new InitialDirContext(var2);
      Attributes var4 = var3.getAttributes("_minecraft._tcp." + p_78863_0_, new String[]{"SRV"});
      String[] var5 = var4.get("srv").get().toString().split(" ", 4);
      return new String[]{var5[3], var5[2]};
   } catch (Throwable var6) {
      return new String[]{p_78863_0_, Integer.toString(25565)};
   }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:17,代碼來源:ServerAddress.java

示例6: getServerAddress

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
/**
 * Returns a server's address and port for the specified hostname, looking up the SRV record if possible
 */
private static String[] getServerAddress(String par0Str)
{
    try
    {
        String s1 = "com.sun.jndi.dns.DnsContextFactory";
        Class.forName("com.sun.jndi.dns.DnsContextFactory");
        Hashtable hashtable = new Hashtable();
        hashtable.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
        hashtable.put("java.naming.provider.url", "dns:");
        hashtable.put("com.sun.jndi.dns.timeout.retries", "1");
        InitialDirContext initialdircontext = new InitialDirContext(hashtable);
        Attributes attributes = initialdircontext.getAttributes("_minecraft._tcp." + par0Str, new String[] {"SRV"});
        String[] astring = attributes.get("srv").get().toString().split(" ", 4);
        return new String[] {astring[3], astring[2]};
    }
    catch (Throwable throwable)
    {
        return new String[] {par0Str, Integer.toString(25565)};
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:24,代碼來源:ServerAddress.java

示例7: getMXForDomain

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static List<MXRecord> getMXForDomain(String aDomain) throws NamingException {
	final InitialDirContext ctx = new InitialDirContext();
	final Attributes attributes = ctx.getAttributes("dns:/" + aDomain,
			new String[] { "MX" });
	final Attribute attr = attributes.get("MX");

	final List<MXRecord> list = new ArrayList<MXRecord>();
	
	// RFC 974
	if (attr == null) {
		list.add(new MXRecord(0, aDomain));
	} else {
		// split pref from hostname
		for (int i = 0; i < attr.size(); i++) {
			Object object = attr.get(i);
			if (object != null && object instanceof String) {
				String[] split = ((String) object).split("\\s+");
				if (split != null && split.length == 2) {
					Integer weight = Integer.parseInt(split[0]);
					list.add(new MXRecord(weight, split[1]));
				}
			}
		}
	}
	
	// sort (according to weight of mxrecord)
	Collections.sort(list);
	
	return list;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:31,代碼來源:MailSender.java

示例8: defaultLookup

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private List<DnsEntry> defaultLookup(InitialDirContext context, String url, Type... types) throws NamingException {
	try {
		Set<String> attr = new HashSet<String>();
		for (Type t : types) attr.add(t.toString());
		Attributes attributes = context.getAttributes(url, attr.toArray(new String[attr.size()]));
		return DnsParser.parse(attributes, types);
	} catch (NamingException e) {
		logger.error(e.getMessage());
		throw e;
	}
}
 
開發者ID:ecolabardini,項目名稱:jdig,代碼行數:12,代碼來源:DnsService.java

示例9: getCname

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
private static String getCname( InitialDirContext idc, String host ) throws NamingException {
	Attributes attrs = idc.getAttributes( host, CNAME_ATTRIBS );
	Attribute attr = attrs.get( CNAME_ATTRIB );

	try {
		return attr.get( 0 ).toString();
	} catch ( Exception ex ) {
		return host;
	}
}
 
開發者ID:nguyenexpeditions,項目名稱:kosmos,代碼行數:11,代碼來源:DnsHelper.java

示例10: getRevName

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
public static String getRevName(String oipAddr) throws NamingException {
	
	String ipAddr = oipAddr;
	try{
		Properties env = new Properties();
		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
		InitialDirContext idc = new InitialDirContext(env);
		
		  String revName = null;
		  String[] quads = ipAddr.split("\\.");
		 
		  //StringBuilder would be better, I know.
		  ipAddr = "";
		 
		  for (int i = quads.length - 1; i >= 0; i--) {
		    ipAddr += quads[i] + ".";
		  }
		 
		  ipAddr += "in-addr.arpa.";
		  Attributes attrs = idc.getAttributes(ipAddr, new String[] {"PTR"});
		  Attribute attr = attrs.get("PTR");
		 
		  if (attr != null) {
		    revName = (String) attr.get(0);
		  }
		  
		  return revName;
	}catch (Exception e){
		
		 return oipAddr;
	}
	 
	 
}
 
開發者ID:AcademicTorrents,項目名稱:AcademicTorrents-Downloader,代碼行數:35,代碼來源:VuzeATDownloadEngineStatus.java

示例11: doAuthenticate

import javax.naming.directory.InitialDirContext; //導入方法依賴的package包/類
/**
 * Perform actual authentication the user
 */
public boolean doAuthenticate(HashMap userProps) throws Exception {
	if (ApplicationProperties
			.getProperty("tmtbl.authenticate.ldap.provider") == null)
		throw new Exception("Ldap provider is not set.");

	String principal = ApplicationProperties
			.getProperty("tmtbl.authenticate.ldap.principal");
	if (principal == null)
		throw new Exception("Ldap principal is not set.");

	String query = ApplicationProperties
			.getProperty("tmtbl.authenticate.ldap.query");
	if (query == null)
		throw new Exception("Ldap query is not set.");

	String n = (String) userProps.get("username");
	String p = (String) userProps.get("password");

	Hashtable<String, String> env = getEnv();
	env.put(Context.SECURITY_PRINCIPAL, principal.replaceAll("%", n));
	env.put(Context.SECURITY_CREDENTIALS, p);
	InitialDirContext cx = new InitialDirContext(env);

	String idAttributeName = ApplicationProperties.getProperty(
			"tmtbl.authenticate.ldap.externalId", "uid");
	Attributes attributes = cx.getAttributes(query.replaceAll("%", n),
			new String[] { idAttributeName });

	Attribute idAttribute = attributes.get(idAttributeName);
	if (idAttribute != null) {
		sLog.debug("Ldap authentication passed ... ");
		setAuthSucceeded(true);
		iExternalUid = (String) idAttribute.get();
		try {
			if (iExternalUid != null
					&& ApplicationProperties
							.getProperty("tmtbl.authenticate.ldap.externalId.format") != null)
				iExternalUid = new DecimalFormat(
						ApplicationProperties
								.getProperty("tmtbl.authenticate.ldap.externalId.format"))
						.format(Long.parseLong(iExternalUid));
		} catch (NumberFormatException e) {
		}
		setUser(n);
		return true;
	}

	return false;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:53,代碼來源:LdapAuthenticateModule.java


注:本文中的javax.naming.directory.InitialDirContext.getAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。