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


Java InvalidNameException類代碼示例

本文整理匯總了Java中javax.naming.InvalidNameException的典型用法代碼示例。如果您正苦於以下問題:Java InvalidNameException類的具體用法?Java InvalidNameException怎麽用?Java InvalidNameException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: getCommonName

import javax.naming.InvalidNameException; //導入依賴的package包/類
public static String getCommonName(X509Certificate cert)
        throws InvalidNameException {
    // use LDAP API to parse the certifiate Subject :)
    // see http://stackoverflow.com/a/7634755/972463
    LdapName ldapDN
            = new LdapName(cert.getSubjectX500Principal().getName());
    String cn = "";
    for (Rdn rdn : ldapDN.getRdns()) {
        if (rdn.getType().equals("CN")) {
            cn = rdn.getValue().toString();
        }
    }
    return cn;
}
 
開發者ID:spyhunter99,項目名稱:installcert,代碼行數:15,代碼來源:InstallCert.java

示例2: testAddAllIntName

import javax.naming.InvalidNameException; //導入依賴的package包/類
/**
 * Test for DIRSERVER-191
 */
@Test
public void testAddAllIntName() throws LdapException, InvalidNameException
{
    LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
    Dn aName = new Dn( "cn=four,cn=three,cn=two,cn=one" );

    assertSame( jName, jName.addAll( 0, new LdapName( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( aName, aName.add( new Dn( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( jName.toString(), aName.toString() );

    assertSame( jName, jName.addAll( 2, new LdapName( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( aName, aName.add( new Dn( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( jName.toString(), aName.toString() );

    assertSame( jName, jName.addAll( jName.size(), new LdapName( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( aName, aName.add( new Dn( "cn=zero,cn=zero.5" ) ) );
    assertNotSame( jName.toString(), aName.toString() );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:22,代碼來源:DnTest.java

示例3: prettyPrintCertificate

import javax.naming.InvalidNameException; //導入依賴的package包/類
public String prettyPrintCertificate(X509Certificate cert, String newLine) throws InvalidNameException, CertificateEncodingException {
    StringBuilder sb = new StringBuilder();

    sb.append("Subject ").append(cert.getSubjectDN()).append(newLine);
    sb.append("   Issuer  ").append(cert.getIssuerDN()).append(newLine);
    sb.append("   CN      ").append(getCommonName(cert)).append(newLine);
    sb.append("   From    ").append(cert.getNotBefore().toString()).append(newLine);
    sb.append("   Util    ").append(cert.getNotAfter().toString()).append(newLine);
    sb.append("   Serial  ").append(cert.getSerialNumber().toString()).append(newLine);
    if (sha1 != null) {
        sha1.update(cert.getEncoded());
        sb.append("   SHA1    ").append(toHexString(sha1.digest())).append(newLine);
    }
    if (md5 != null) {
        md5.update(cert.getEncoded());

        sb.append("   MD5     ").append(toHexString(md5.digest())).append(newLine);
    }
    return sb.toString();
}
 
開發者ID:spyhunter99,項目名稱:installcert,代碼行數:21,代碼來源:InstallCert.java

示例4: parseAttrType

import javax.naming.InvalidNameException; //導入依賴的package包/類
private String parseAttrType() throws InvalidNameException {

            final int beg = cur;
            while (cur < len) {
                char c = chars[cur];
                if (Character.isLetterOrDigit(c) ||
                        c == '.' ||
                        c == '-' ||
                        c == ' ') {
                    ++cur;
                } else {
                    break;
                }
            }
            // Back out any trailing spaces.
            while ((cur > beg) && (chars[cur - 1] == ' ')) {
                --cur;
            }

            if (beg == cur) {
                throw new InvalidNameException("Invalid name: " + name);
            }
            return new String(chars, beg, cur - beg);
        }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:Rfc2253Parser.java

示例5: doLookup

import javax.naming.InvalidNameException; //導入依賴的package包/類
/**
 * Retrieves the named object.
 * 
 * @param strName the name of the object to look up
 * @return the object bound to name
 */
@Override
protected Object doLookup(String strName) {

    Name name;
    try {
        name = getEscapedJndiName(strName);
    } catch (InvalidNameException e) {
        log.info(sm.getString("resources.invalidName", strName), e);
        return null;
    }

    if (name.isEmpty())
        return this;
    Entry entry = treeLookup(name);
    if (entry == null)
        return null;
        
    ZipEntry zipEntry = entry.getEntry();
    if (zipEntry.isDirectory())
        return new WARDirContext(base, entry);
    else
        return new WARResource(entry.getEntry());
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:30,代碼來源:WARDirContext.java

示例6: getGroupResult

import javax.naming.InvalidNameException; //導入依賴的package包/類
public LDAPResult getGroupResult(DirContext ctx, String groupID, String[] attrs)
{
	if( !Check.isEmpty(groupIdField) )
	{
		SingleFilter nv1 = new SingleFilter(OBJECTCLASS, getGroupObject());
		SingleFilter nv2 = new SingleFilter(groupIdField, groupID);
		return searchFirstResultAllBases(ctx, new AndFilter(nv1, nv2), new LdapResultHitsCollector(attrs), true);
	}

	try
	{
		Name name = LDAP.parse(groupID);
		return new LDAPResult(name, getAttributes(ctx, name, attrs));
	}
	catch( InvalidNameException e )
	{
		LOGGER.debug(e, e);
		return null;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:21,代碼來源:LDAP.java

示例7: parseDn

import javax.naming.InvalidNameException; //導入依賴的package包/類
List<Rdn> parseDn() throws InvalidNameException {
    cur = 0;

    // ArrayList<Rdn> rdns =
    //  new ArrayList<Rdn>(len / 3 + 10);  // leave room for growth

    ArrayList<Rdn> rdns =
        new ArrayList<>(len / 3 + 10);  // leave room for growth

    if (len == 0) {
        return rdns;
    }

    rdns.add(doParse(new Rdn()));
    while (cur < len) {
        if (chars[cur] == ',' || chars[cur] == ';') {
            ++cur;
            rdns.add(0, doParse(new Rdn()));
        } else {
            throw new InvalidNameException("Invalid name: " + name);
        }
    }
    return rdns;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:Rfc2253Parser.java

示例8: bind

import javax.naming.InvalidNameException; //導入依賴的package包/類
@Override
public void bind(Name name, Object obj) throws NamingException {
	if (name.isEmpty()) {
		throw new InvalidNameException("Cannot bind empty name");
	}

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter != null)
			throw new NameAlreadyBoundException("Use rebind to override");

		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).bind(nm.getSuffix(1), obj);
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:25,代碼來源:LocalContext.java

示例9: rebind

import javax.naming.InvalidNameException; //導入依賴的package包/類
@Override
public void rebind(Name name, Object obj) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot bind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);

	if (nm.size() == 1) {
		obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv);

		iBindings.put(atom, obj);
	} else {
		Object inter = iBindings.get(atom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).rebind(nm.getSuffix(1), obj);
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:22,代碼來源:LocalContext.java

示例10: unbind

import javax.naming.InvalidNameException; //導入依賴的package包/類
@Override
public void unbind(Name name) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot unbind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);

	if (nm.size() == 1) {
		iBindings.remove(atom);
	} else {
		Object inter = iBindings.get(atom);
		
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		((Context) inter).unbind(nm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:20,代碼來源:LocalContext.java

示例11: createSubcontext

import javax.naming.InvalidNameException; //導入依賴的package包/類
@Override
public Context createSubcontext(Name name) throws NamingException {
	if (name.isEmpty())
		throw new InvalidNameException("Cannot bind empty name");

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter != null)
			throw new NameAlreadyBoundException("Use rebind to override");

		Context child = createCtx(this, atom, iEnv);

		iBindings.put(atom, child);

		return child;
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		return ((Context) inter).createSubcontext(nm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:LocalContext.java

示例12: decodeName

import javax.naming.InvalidNameException; //導入依賴的package包/類
private int decodeName(int pos, DnsName n) throws InvalidNameException {
    if (msg[pos] == 0) {                            // end of name
        n.add(0, "");
        return (pos + 1);
    } else if ((msg[pos] & 0xC0) != 0) {            // name compression
        decodeName(getUShort(pos) & 0x3FFF, n);
        return (pos + 2);
    } else {                                        // append a label
        int len = msg[pos++];
        try {
            n.add(0, new String(msg, pos, len, "ISO-8859-1"));
        } catch (java.io.UnsupportedEncodingException e) {
            // assert false : "ISO-Latin-1 charset unavailable";
        }
        return decodeName(pos + len, n);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:ResourceRecord.java

示例13: decodeSoa

import javax.naming.InvalidNameException; //導入依賴的package包/類
private String decodeSoa(int pos) throws InvalidNameException {
    DnsName mname = new DnsName();
    pos = decodeName(pos, mname);
    DnsName rname = new DnsName();
    pos = decodeName(pos, rname);

    long serial = getUInt(pos);
    pos += 4;
    long refresh = getUInt(pos);
    pos += 4;
    long retry = getUInt(pos);
    pos += 4;
    long expire = getUInt(pos);
    pos += 4;
    long minimum = getUInt(pos);    // now used as negative TTL
    pos += 4;

    return (mname + " " + rname + " " + serial + " " +
            refresh + " " + retry + " " + expire + " " + minimum);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:ResourceRecord.java

示例14: decodeNaptr

import javax.naming.InvalidNameException; //導入依賴的package包/類
private String decodeNaptr(int pos) throws InvalidNameException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:ResourceRecord.java

示例15: constructAuthenticationIdentity

import javax.naming.InvalidNameException; //導入依賴的package包/類
private AuthenticationIdentity constructAuthenticationIdentity(X509Certificate certificate) {
  AuthenticationIdentity identity = new AuthenticationIdentity();
  try {
    LdapName ln = new LdapName(certificate.getSubjectDN().getName());
    for(Rdn rdn : ln.getRdns()) {
      if(rdn.getType().equalsIgnoreCase("GIVENNAME")) {
        identity.setGivenName(rdn.getValue().toString());
      } else if(rdn.getType().equalsIgnoreCase("SURNAME")) {
        identity.setSurName(rdn.getValue().toString());
      } else if(rdn.getType().equalsIgnoreCase("SERIALNUMBER")) {
        identity.setIdentityCode(rdn.getValue().toString().split("-")[1]);
      } else if(rdn.getType().equalsIgnoreCase("C")) {
        identity.setCountry(rdn.getValue().toString());
      }

    }
    return identity;
  } catch (InvalidNameException e) {
    logger.error("Error getting authentication identity from the certificate", e);
    throw new TechnicalErrorException("Error getting authentication identity from the certificate", e);
  }
}
 
開發者ID:SK-EID,項目名稱:smart-id-java-client,代碼行數:23,代碼來源:AuthenticationResponseValidator.java


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