类javax.naming.InvalidNameException源码实例Demo

下面列出了怎么用javax.naming.InvalidNameException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk1.8-source-analysis   文件: ResolveResult.java
/**
      * Adds components to the end of remaining name.
      *
      * @param name The components to add. Can be null.
      * @see #getRemainingName
      * @see #setRemainingName
      * @see #appendRemainingComponent
      */
    public void appendRemainingName(Name name) {
//      System.out.println("appendingRemainingName: " + name.toString());
//      Exception e = new Exception();
//      e.printStackTrace();
        if (name != null) {
            if (this.remainingName != null) {
                try {
                    this.remainingName.addAll(name);
                } catch (InvalidNameException e) {
                    // ignore; shouldn't happen for composite name
                }
            } else {
                this.remainingName = (Name)(name.clone());
            }
        }
    }
 
源代码2 项目: jdk8u_jdk   文件: LdapPrincipal.java
/**
 * Compares this principal to the specified object.
 *
 * @param object The object to compare this principal against.
 * @return true if they are equal; false otherwise.
 */
public boolean equals(Object object) {
    if (this == object) {
        return true;
    }
    if (object instanceof LdapPrincipal) {
        try {

            return
                name.equals(getLdapName(((LdapPrincipal)object).getName()));

        } catch (InvalidNameException e) {
            return false;
        }
    }
    return false;
}
 
源代码3 项目: jdk8u-jdk   文件: Rfc2253Parser.java
private Rdn doParse(Rdn rdn) throws InvalidNameException {

            while (cur < len) {
                consumeWhitespace();
                String attrType = parseAttrType();
                consumeWhitespace();
                if (cur >= len || chars[cur] != '=') {
                    throw new InvalidNameException("Invalid name: " + name);
                }
                ++cur;          // consume '='
                consumeWhitespace();
                String value = parseAttrValue();
                consumeWhitespace();

                rdn.put(attrType, Rdn.unescapeValue(value));
                if (cur >= len || chars[cur] != '+') {
                    break;
                }
                ++cur;          // consume '+'
            }
            rdn.sort();
            return rdn;
        }
 
源代码4 项目: Spark   文件: MutualAuthenticationSettingsPanel.java
private void createSelfSignedCertificate() {
idControll.setUpData(commonNameField.getText(), organizationUnitField.getText(), organizationField.getText(), countryField.getText(),
	cityField.getText());
try {
    KeyPair keyPair = idControll.createKeyPair();

    X509Certificate cert = idControll.createSelfSignedCertificate(keyPair);
           if (saveCertToFile.isSelected()) {
               PemBuilder pemBuilder = new PemHelper().new PemBuilder();
               pemBuilder.add(keyPair.getPrivate());
               pemBuilder.add(cert);
               pemBuilder.saveToPemFile(IdentityController.CERT_FILE);
               JOptionPane.showMessageDialog(null,
                       Res.getString("dialog.self.signed.certificate.has.been.created") + IdentityController.SECURITY_DIRECTORY.toString());
           } else {
               try {
                   idControll.addEntryToKeyStore(cert, keyPair.getPrivate());
               } catch (HeadlessException | InvalidNameException | KeyStoreException e) {
                       Log.error("Couldn't save entry to IdentityStore", e);
               }
           }
} catch (NoSuchAlgorithmException | NoSuchProviderException | IOException | OperatorCreationException | CertificateException e1) {
    Log.error("Couldn't create Self Signed Certificate", e1);
}
   }
 
源代码5 项目: jdk1.8-source-analysis   文件: Rfc2253Parser.java
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);
        }
 
源代码6 项目: Tomcat7.0.67   文件: WARDirContext.java
/**
 * 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());
}
 
/**
 * Add and remove a user to the LDAP repository.
 *
 * @throws InvalidNameException
 */
@Test
public void addUser() throws InvalidNameException {

	Person walter = new Person();
	walter.setFullName("Walter White");
	walter.setUid("heisenberg");
	walter.setLastname("White");

	personRepository.save(walter);

	List<Person> people = personRepository.findByUid("heisenberg");

	assertThat(people).hasSize(1).extracting("fullName").contains("Walter White");

	personRepository.delete(people.get(0));
}
 
源代码8 项目: openjdk-jdk8u   文件: Rfc2253Parser.java
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);
        }
 
源代码9 项目: jdk8u60   文件: Rfc2253Parser.java
private String parseStringAttrValue() throws InvalidNameException {

            final int beg = cur;
            int esc = -1;       // index of the most recently escaped character

            while ((cur < len) && !atTerminator()) {
                if (chars[cur] == '\\') {
                    ++cur;              // consume backslash, then what follows
                    esc = cur;
                }
                ++cur;
            }
            if (cur > len) {            // 'twas backslash followed by nothing
                throw new InvalidNameException("Invalid name: " + name);
            }

            // Trim off (unescaped) trailing whitespace.
            int end;
            for (end = cur; end > beg; end--) {
                if (!isWhitespace(chars[end - 1]) || (esc == end - 1)) {
                    break;
                }
            }
            return new String(chars, beg, end - beg);
        }
 
源代码10 项目: freehealth-connector   文件: DistinguishedName.java
public DistinguishedName(X500Principal principal) throws TechnicalConnectorException {
   CertificateParser parser = new CertificateParser(principal.getName("RFC2253"));
   this.setId(parser.getId());
   this.setType(parser.getIdentifier());
   this.setApplicationId(parser.getApplication());

   try {
      List<Rdn> rdns = (new LdapName(principal.getName("RFC1779"))).getRdns();
      Iterator i$ = rdns.iterator();

      while(i$.hasNext()) {
         Rdn rdn = (Rdn)i$.next();
         if (rdn.getType().equals("OU")) {
            String value = this.getValue(rdn.getValue());
            if (!"eHealth-platform Belgium".equals(value) && !value.contains("=")) {
               this.setName(this.getValue(rdn.getValue()));
               break;
            }
         }
      }

   } catch (InvalidNameException var7) {
      throw new IllegalArgumentException("Invalid Principal", var7);
   }
}
 
源代码11 项目: openjdk-8-source   文件: Rdn.java
/**
 * Constructs an Rdn from the given attribute set. See
 * {@link javax.naming.directory.Attributes Attributes}.
 * <p>
 * The string attribute values are not interpreted as
 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
 * formatted RDN strings. That is, the values are used
 * literally (not parsed) and assumed to be unescaped.
 *
 * @param attrSet The non-null and non-empty attributes containing
 * type/value mappings.
 * @throws InvalidNameException If contents of <tt>attrSet</tt> cannot
 *          be used to construct a valid RDN.
 */
public Rdn(Attributes attrSet) throws InvalidNameException {
    if (attrSet.size() == 0) {
        throw new InvalidNameException("Attributes cannot be empty");
    }
    entries = new ArrayList<>(attrSet.size());
    NamingEnumeration<? extends Attribute> attrs = attrSet.getAll();
    try {
        for (int nEntries = 0; attrs.hasMore(); nEntries++) {
            RdnEntry entry = new RdnEntry();
            Attribute attr = attrs.next();
            entry.type = attr.getID();
            entry.value = attr.get();
            entries.add(nEntries, entry);
        }
    } catch (NamingException e) {
        InvalidNameException e2 = new InvalidNameException(
                                    e.getMessage());
        e2.initCause(e);
        throw e2;
    }
    sort(); // arrange entries for comparison
}
 
源代码12 项目: dragonwell8_jdk   文件: Rfc2253Parser.java
private String parseQuotedAttrValue() throws InvalidNameException {

            final int beg = cur;
            ++cur;                      // consume '"'

            while ((cur < len) && chars[cur] != '"') {
                if (chars[cur] == '\\') {
                    ++cur;              // consume backslash, then what follows
                }
                ++cur;
            }
            if (cur >= len) {   // no closing quote
                throw new InvalidNameException("Invalid name: " + name);
            }
            ++cur;      // consume closing quote

            return new String(chars, beg, cur - beg);
        }
 
源代码13 项目: dragonwell8_jdk   文件: Rfc2253Parser.java
private String parseStringAttrValue() throws InvalidNameException {

            final int beg = cur;
            int esc = -1;       // index of the most recently escaped character

            while ((cur < len) && !atTerminator()) {
                if (chars[cur] == '\\') {
                    ++cur;              // consume backslash, then what follows
                    esc = cur;
                }
                ++cur;
            }
            if (cur > len) {            // 'twas backslash followed by nothing
                throw new InvalidNameException("Invalid name: " + name);
            }

            // Trim off (unescaped) trailing whitespace.
            int end;
            for (end = cur; end > beg; end--) {
                if (!isWhitespace(chars[end - 1]) || (esc == end - 1)) {
                    break;
                }
            }
            return new String(chars, beg, end - beg);
        }
 
源代码14 项目: openjdk-8   文件: ResourceRecord.java
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);
}
 
源代码15 项目: openjdk-jdk8u   文件: Rdn.java
/**
 * Constructs an Rdn from the given attribute set. See
 * {@link javax.naming.directory.Attributes Attributes}.
 * <p>
 * The string attribute values are not interpreted as
 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
 * formatted RDN strings. That is, the values are used
 * literally (not parsed) and assumed to be unescaped.
 *
 * @param attrSet The non-null and non-empty attributes containing
 * type/value mappings.
 * @throws InvalidNameException If contents of <tt>attrSet</tt> cannot
 *          be used to construct a valid RDN.
 */
public Rdn(Attributes attrSet) throws InvalidNameException {
    if (attrSet.size() == 0) {
        throw new InvalidNameException("Attributes cannot be empty");
    }
    entries = new ArrayList<>(attrSet.size());
    NamingEnumeration<? extends Attribute> attrs = attrSet.getAll();
    try {
        for (int nEntries = 0; attrs.hasMore(); nEntries++) {
            RdnEntry entry = new RdnEntry();
            Attribute attr = attrs.next();
            entry.type = attr.getID();
            entry.value = attr.get();
            entries.add(nEntries, entry);
        }
    } catch (NamingException e) {
        InvalidNameException e2 = new InvalidNameException(
                                    e.getMessage());
        e2.initCause(e);
        throw e2;
    }
    sort(); // arrange entries for comparison
}
 
源代码16 项目: jdk8u60   文件: ResolveResult.java
/**
      * Adds components to the end of remaining name.
      *
      * @param name The components to add. Can be null.
      * @see #getRemainingName
      * @see #setRemainingName
      * @see #appendRemainingComponent
      */
    public void appendRemainingName(Name name) {
//      System.out.println("appendingRemainingName: " + name.toString());
//      Exception e = new Exception();
//      e.printStackTrace();
        if (name != null) {
            if (this.remainingName != null) {
                try {
                    this.remainingName.addAll(name);
                } catch (InvalidNameException e) {
                    // ignore; shouldn't happen for composite name
                }
            } else {
                this.remainingName = (Name)(name.clone());
            }
        }
    }
 
源代码17 项目: jdk8u-jdk   文件: Rfc2253Parser.java
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);
        }
 
源代码18 项目: jdk8u60   文件: Rfc2253Parser.java
private String parseQuotedAttrValue() throws InvalidNameException {

            final int beg = cur;
            ++cur;                      // consume '"'

            while ((cur < len) && chars[cur] != '"') {
                if (chars[cur] == '\\') {
                    ++cur;              // consume backslash, then what follows
                }
                ++cur;
            }
            if (cur >= len) {   // no closing quote
                throw new InvalidNameException("Invalid name: " + name);
            }
            ++cur;      // consume closing quote

            return new String(chars, beg, cur - beg);
        }
 
源代码19 项目: TencentKona-8   文件: Rfc2253Parser.java
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);
        }
 
public static void removeInstance(String uid, String name, Properties properties) {
	//TODO: theoretically non-threadsafe...

	if (name!=null) {
		log.info("Unbinding factory from JNDI name: " + name);

		try {
			Context ctx = NamingHelper.getInitialContext(properties);
			ctx.unbind(name);
			log.info("Unbound factory from JNDI name: " + name);
		}
		catch (InvalidNameException ine) {
			log.error("Invalid JNDI name: " + name, ine);
		}
		catch (NamingException ne) {
			log.warn("Could not unbind factory from JNDI", ne);
		}

		NAMED_INSTANCES.remove(name);

	}

	INSTANCES.remove(uid);

}
 
源代码21 项目: openjdk-8   文件: LdapPrincipal.java
/**
 * Compares this principal to the specified object.
 *
 * @param object The object to compare this principal against.
 * @return true if they are equal; false otherwise.
 */
public boolean equals(Object object) {
    if (this == object) {
        return true;
    }
    if (object instanceof LdapPrincipal) {
        try {

            return
                name.equals(getLdapName(((LdapPrincipal)object).getName()));

        } catch (InvalidNameException e) {
            return false;
        }
    }
    return false;
}
 
源代码22 项目: TencentKona-8   文件: Rfc2253Parser.java
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;
}
 
源代码23 项目: pdf-sign-check   文件: PDFSignatureInfoParser.java
public static List<PDFSignatureInfo> getPDFSignatureInfo(InputStream is ) throws IOException, CertificateException,
        NoSuchAlgorithmException, InvalidKeyException,
        NoSuchProviderException, SignatureException, InvalidNameException {

    byte[] byteArray = getbyteArray(is);
    return getPDFSignatureInfo(byteArray);
}
 
源代码24 项目: jdk8u60   文件: Rfc2253Parser.java
private String parseAttrValue() throws InvalidNameException {

            if (cur < len && chars[cur] == '#') {
                return parseBinaryAttrValue();
            } else if (cur < len && chars[cur] == '"') {
                return parseQuotedAttrValue();
            } else {
                return parseStringAttrValue();
            }
        }
 
源代码25 项目: jdk8u-jdk   文件: Rdn.java
private void readObject(ObjectInputStream s)
        throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    entries = new ArrayList<>(DEFAULT_SIZE);
    String unparsed = (String) s.readObject();
    try {
        (new Rfc2253Parser(unparsed)).parseRdn(this);
    } catch (InvalidNameException e) {
        // shouldn't happen
        throw new java.io.StreamCorruptedException(
                "Invalid name: " + unparsed);
    }
}
 
源代码26 项目: cxf   文件: DefaultHostnameVerifier.java
static String extractCN(final String subjectPrincipal) throws SSLException {
    if (subjectPrincipal == null) {
        return null;
    }
    try {
        final LdapName subjectDN = new LdapName(subjectPrincipal);
        final List<Rdn> rdns = subjectDN.getRdns();
        for (int i = rdns.size() - 1; i >= 0; i--) {
            final Rdn rds = rdns.get(i);
            final Attributes attributes = rds.toAttributes();
            final Attribute cn = attributes.get("cn");
            if (cn != null) {
                try {
                    final Object value = cn.get();
                    if (value != null) {
                        return value.toString();
                    }
                } catch (NoSuchElementException | NamingException ignore) {
                    //
                }
            }
        }
        return null;
    } catch (InvalidNameException e) {
        throw new SSLException(subjectPrincipal + " is not a valid X500 distinguished name");
    }
}
 
源代码27 项目: hottub   文件: Rfc2253Parser.java
private String parseAttrValue() throws InvalidNameException {

            if (cur < len && chars[cur] == '#') {
                return parseBinaryAttrValue();
            } else if (cur < len && chars[cur] == '"') {
                return parseQuotedAttrValue();
            } else {
                return parseStringAttrValue();
            }
        }
 
源代码28 项目: openjdk-jdk9   文件: ResolveResult.java
/**
  * Adds a single component to the end of remaining name.
  *
  * @param name The component to add. Can be null.
  * @see #getRemainingName
  * @see #appendRemainingName
  */
public void appendRemainingComponent(String name) {
    if (name != null) {
        CompositeName rname = new CompositeName();
        try {
            rname.add(name);
        } catch (InvalidNameException e) {
            // ignore; shouldn't happen for empty composite name
        }
        appendRemainingName(rname);
    }
}
 
源代码29 项目: openjdk-jdk8u-backup   文件: LDAPCertStore.java
private String checkName(String name) throws CertStoreException {
    if (name == null) {
        throw new CertStoreException("Name absent");
    }
    try {
        if (new CompositeName(name).size() > 1) {
            throw new CertStoreException("Invalid name: " + name);
        }
    } catch (InvalidNameException ine) {
        throw new CertStoreException("Invalid name: " + name, ine);
    }
    return name;
}
 
源代码30 项目: Spark   文件: CertificateModel.java
private String extractCommonName(String certName) throws InvalidNameException {
	String name = null;
	LdapName ldapDN = new LdapName(certName);
	for (Rdn rdn : ldapDN.getRdns()) {
		if (rdn.getType().equals("CN")) {
			name = rdn.getValue().toString();
		}
	}
	return name;
}
 
 类所在包
 类方法
 同包方法