当前位置: 首页>>代码示例>>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;未经允许,请勿转载。