Search in sources :

Example 21 with InvalidNameException

use of javax.naming.InvalidNameException in project wildfly by wildfly.

the class ExceptionMapper method mapException.

public static NamingException mapException(Exception e, CNCtx ctx, NameComponent[] inputName) throws NamingException {
    if (e instanceof NamingException) {
        return (NamingException) e;
    }
    if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
    }
    NamingException ne;
    if (e instanceof NotFound) {
        if (ctx.federation) {
            return tryFed((NotFound) e, ctx, inputName);
        } else {
            ne = new NameNotFoundException();
        }
    } else if (e instanceof CannotProceed) {
        ne = new CannotProceedException();
        NamingContext nc = ((CannotProceed) e).cxt;
        NameComponent[] rest = ((CannotProceed) e).rest_of_name;
        // NotFound doesn't set rest as expected. -RL
        if (inputName != null && (inputName.length > rest.length)) {
            NameComponent[] resolvedName = new NameComponent[inputName.length - rest.length];
            System.arraycopy(inputName, 0, resolvedName, 0, resolvedName.length);
            // Wrap resolved NamingContext inside a CNCtx
            // Guess that its name (which is relative to ctx)
            // is the part of inputName minus rest_of_name
            ne.setResolvedObj(new CNCtx(ctx._orb, nc, ctx._env, ctx.makeFullName(resolvedName)));
        } else {
            ne.setResolvedObj(ctx);
        }
        ne.setRemainingName(org.wildfly.iiop.openjdk.naming.jndi.CNNameParser.cosNameToName(rest));
    } else if (e instanceof InvalidName) {
        ne = new InvalidNameException();
    } else if (e instanceof AlreadyBound) {
        ne = new NameAlreadyBoundException();
    } else if (e instanceof NotEmpty) {
        ne = new ContextNotEmptyException();
    } else {
        ne = new NamingException();
    }
    ne.setRootCause(e);
    return ne;
}
Also used : NameNotFoundException(javax.naming.NameNotFoundException) CannotProceed(org.omg.CosNaming.NamingContextPackage.CannotProceed) NamingContext(org.omg.CosNaming.NamingContext) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) InvalidName(org.omg.CosNaming.NamingContextPackage.InvalidName) InvalidNameException(javax.naming.InvalidNameException) CannotProceedException(javax.naming.CannotProceedException) ContextNotEmptyException(javax.naming.ContextNotEmptyException) NamingException(javax.naming.NamingException) AlreadyBound(org.omg.CosNaming.NamingContextPackage.AlreadyBound) NotEmpty(org.omg.CosNaming.NamingContextPackage.NotEmpty) NotFound(org.omg.CosNaming.NamingContextPackage.NotFound)

Example 22 with InvalidNameException

use of javax.naming.InvalidNameException in project uPortal by Jasig.

the class ReferenceCompositeGroupService method getEntity.

/**
     * Returns an <code>IEntity</code> representing a portal entity. This does not guarantee that
     * the entity actually exists.
     */
public IEntity getEntity(String key, Class type, String svcName) throws GroupsException {
    IIndividualGroupService svc = null;
    if (svcName == null) {
        svc = getDefaultService();
    } else {
        try {
            Name n = GroupService.parseServiceName(svcName);
            svc = getComponentService(n);
        } catch (InvalidNameException ine) {
            throw new GroupsException("Invalid service name.");
        }
    }
    return (svc == null) ? null : svc.getEntity(key, type);
}
Also used : InvalidNameException(javax.naming.InvalidNameException) Name(javax.naming.Name)

Example 23 with InvalidNameException

use of javax.naming.InvalidNameException in project jdk8u_jdk by JetBrains.

the class ResolveResult method appendRemainingComponent.

/**
      * 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);
    }
}
Also used : InvalidNameException(javax.naming.InvalidNameException) CompositeName(javax.naming.CompositeName)

Example 24 with InvalidNameException

use of javax.naming.InvalidNameException in project gerrit by GerritCodeReview.

the class LdapGroupBackend method cnFor.

private static String cnFor(String dn) {
    try {
        LdapName name = new LdapName(dn);
        if (!name.isEmpty()) {
            String cn = name.get(name.size() - 1);
            int index = cn.indexOf('=');
            if (index >= 0) {
                cn = cn.substring(index + 1);
            }
            return cn;
        }
    } catch (InvalidNameException e) {
        log.warn("Cannot parse LDAP dn for cn", e);
    }
    return dn;
}
Also used : InvalidNameException(javax.naming.InvalidNameException) ParameterizedString(com.google.gerrit.common.data.ParameterizedString) LdapName(javax.naming.ldap.LdapName)

Example 25 with InvalidNameException

use of javax.naming.InvalidNameException in project zm-mailbox by Zimbra.

the class CertUtil method getSubjectAttr.

private String getSubjectAttr(String needAttrName, String needAttrOid) {
    String subjectDN = getSubjectDN();
    try {
        LdapName dn = new LdapName(subjectDN);
        List<Rdn> rdns = dn.getRdns();
        for (Rdn rdn : rdns) {
            String type = rdn.getType();
            boolean isOid = type.contains(".");
            boolean matched = (isOid ? type.equals(needAttrOid) : type.equals(needAttrName));
            if (matched) {
                Object value = rdn.getValue();
                if (value == null) {
                    continue;
                }
                if (isOid) {
                    byte[] bytes = (byte[]) value;
                    ASN1InputStream decoder = null;
                    try {
                        decoder = new ASN1InputStream(bytes);
                        DEREncodable encoded = decoder.readObject();
                        DERIA5String str = DERIA5String.getInstance(encoded);
                        return str.getString();
                    } catch (IOException e) {
                        ZimbraLog.account.warn(LOG_PREFIX + "unable to decode " + type, e);
                    } finally {
                        ByteUtil.closeStream(decoder);
                    }
                } else {
                    return value.toString();
                }
            }
        }
    } catch (InvalidNameException e) {
        ZimbraLog.account.warn(LOG_PREFIX + "Invalid subject dn value" + subjectDN, e);
    }
    return null;
}
Also used : ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) DERIA5String(org.bouncycastle.asn1.DERIA5String) InvalidNameException(javax.naming.InvalidNameException) DEREncodable(org.bouncycastle.asn1.DEREncodable) ASN1Object(org.bouncycastle.asn1.ASN1Object) ASN1TaggedObject(org.bouncycastle.asn1.ASN1TaggedObject) DEROctetString(org.bouncycastle.asn1.DEROctetString) DERIA5String(org.bouncycastle.asn1.DERIA5String) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) IOException(java.io.IOException) Rdn(javax.naming.ldap.Rdn) LdapName(javax.naming.ldap.LdapName)

Aggregations

InvalidNameException (javax.naming.InvalidNameException)27 CompositeName (javax.naming.CompositeName)10 LdapName (javax.naming.ldap.LdapName)8 Name (javax.naming.Name)6 NameNotFoundException (javax.naming.NameNotFoundException)5 Rdn (javax.naming.ldap.Rdn)5 ArrayList (java.util.ArrayList)4 NotContextException (javax.naming.NotContextException)4 URISyntaxException (java.net.URISyntaxException)3 Context (javax.naming.Context)3 NamingException (javax.naming.NamingException)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ConnectException (java.net.ConnectException)2 RemoteException (java.rmi.RemoteException)2 LinkedList (java.util.LinkedList)2 AuthenticationException (javax.naming.AuthenticationException)2 ConfigurationException (javax.naming.ConfigurationException)2 ContextNotEmptyException (javax.naming.ContextNotEmptyException)2 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)2