Examples of DXNamingEnumeration


Examples of com.ca.commons.naming.DXNamingEnumeration

        else if (name.size() == 2)
            itemBase = "ou=gamma";
        else if (name.size() == 3)
            itemBase = "ou=delta";

        DXNamingEnumeration testEnumeration = new DXNamingEnumeration();
        for (int i = 0; i < num; i++)
        {
            String itemName = itemBase + i;
            testEnumeration.add(new SearchResult(itemName, null, getTestAttributes(itemName)));
        }

        return testEnumeration;
    }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

    static NamingEnumeration parseSearchResponse(String response, String searchBase)
            throws NamingException
    {
        checkForError(response);

        DXNamingEnumeration en = new DXNamingEnumeration();

        Matcher responseMatcher = searchResultEntry.matcher(response);

// cycle through the available entries
        while (responseMatcher.find())
        {
            String dn = responseMatcher.group(1);

            BasicAttributes atts = new BasicAttributes();

            if (dn.indexOf("requestID") > -1) // what numb nut would put a requestID in a searchResultEntry??
            {
                int reqPos = dn.indexOf("requestID");
                int endPos = dn.lastIndexOf('"', reqPos);
                dn = dn.substring(0, endPos);
            }

            if (dn.indexOf("&") > -1)
                dn = unescape(dn);

            log.finest("Parsing DSML: read DN: " + dn);

            // turn pure pristine LDAP DN into un unbelievably screwed up JNDI Composite name, and then
            // store it as a string SO NO ONE CAN EVER REALLY TELL WHAT THE HELL IT IS.  God JNDI is
            // broken - what a (*&*^ joke.  Object Oriented?  Yeah, we've heard of that...

            dn = new CompositeName(dn).toString();

            log.finest("converted DN to: " + dn);

            String attribute = responseMatcher.group(2);

            Matcher attributeMatcher = searchResultAttribute.matcher(attribute);

            // cycle through individual attributes
            while (attributeMatcher.find())
            {
                String attributeName = attributeMatcher.group(1);

                BasicAttribute att = new BasicAttribute(attributeName);


                String attributeValues = attributeMatcher.group(2);

                log.finest("Parsing DSML: Attribute Name " + attributeName + " length: " + attributeValues.length());

                Matcher valueMatcher = searchResultAttributeValues.matcher(attributeValues);

                while (valueMatcher.find())
                {
                    String typeInfo = valueMatcher.group(1);

                    String type = "string"; // the default value is string

                    if (typeInfo != null && typeInfo.length() > 6)
                    {
// don't bother using regexp - faster to use string handling (if insanely clever might modify attributeValues regexp??)
                        int typeInfoStart = typeInfo.indexOf("type=\"");
                        int typeInfoEnd = typeInfo.indexOf('\"', typeInfoStart + 6);
                        if (typeInfoStart != -1 && typeInfoEnd > typeInfoStart)
                        {
                            type = typeInfo.substring(typeInfoStart + 6, typeInfoEnd)// extract the type; e.g. xsd:base64Binary
                            if ((typeInfoStart = type.indexOf(':')) > -1)              // trim any namespace from the type (e.g. 'xsd:')
                                type = type.substring(typeInfoStart + 1);
                        }
                    }
                    String value = valueMatcher.group(2);

                    if (type.equals("string"))  // this is the usual case, and the default
                    {
                        if (value != null && value.indexOf('&') > -1)
                            value = unescape(value);
                        att.add(value);
                    }
                    else if (type.equals("anyURI"))
                        throw new NamingException("CA JNDI DSML Provider does not support 'anyURI' values");
                    else if (type.equals("base64Binary"))
                    {
                        try
                        {

                            System.out.println("PROCESSING BINARY VALUE " + attributeName);
                            byte[] data = CBBase64.decode(value);
                            System.out.println("RAW DATA: " + value.length() + " byte data " + data.length);
                            att.add(CBBase64.decode(value));
                        }
                        catch (CBBase64EncodingException e)
                        {
                            NamingException ne = new NamingException("unable to parse base64 value in entry: " + dn);
                            ne.setRootCause(e);
                            throw ne;
                        }
                    }
                }
                atts.put(att);
            }

            SearchResult currentResult = new SearchResult(dn, null, atts);

            // The search result sets 'is relative' to true by default.  Check if the
            // DN in the search result contains the search base, if so set 'is relative'
            // to false so that the search base is NOT added to the DN again.  In otherwords
            // check if the full DN has been returned in the search result...
            if(dn.endsWith(searchBase))
                currentResult.setRelative(false);

            en.add(currentResult);
        }

        log.finest("Parsing DSML: final enumeration - \n" + en.toString());

        return en;
    }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

        {
            if (br != null) br.close();
        }


        DXNamingEnumeration results1 = new DXNamingEnumeration(DsmlContext.parseSearchResponse(bigSchema.toString(), ""));

        assertEquals(results1.size(), 1);

        SearchResult result = (SearchResult) results1.next();

        String dn = result.getName();

        assertEquals(dn, "cn=schema");

        OrderedAttributes atts = new OrderedAttributes(result.getAttributes());

        DXNamingEnumeration attEnum = new DXNamingEnumeration(atts.getAll());

        attEnum.sort();

        assertEquals(attEnum.size(), 7);

        Object[] attributeArray = attEnum.toArray();

        assertEquals(((Attribute)attributeArray[0]).getID(), "attributeTypes");

        assertEquals(((Attribute)attributeArray[6]).getID(), "objectClasses");

        DXNamingEnumeration objectClassesValues = new DXNamingEnumeration(((Attribute)attributeArray[6]).getAll());

        objectClassesValues.sort();

        String[] values = objectClassesValues.toStringArray();

        int len = values.length;

        assertEquals(263, len);
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

            }
        }

        public NamingEnumeration getAll()
        {
            DXNamingEnumeration sortedByID = new DXNamingEnumeration();
            NamingEnumeration IDs = getIDs();
            while (IDs.hasMoreElements())
            {
                Attribute att = this.get((String) IDs.nextElement());
                sortedByID.add(att);
            }
            return sortedByID;
        }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

        }

        public NamingEnumeration getIDs()
        {
            Enumeration original = super.getIDs();
            DXNamingEnumeration sortedEnum = new DXNamingEnumeration(original);
            sortedEnum.sort();
            return sortedEnum;

        }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

        }

        public NamingEnumeration getAll()
                throws NamingException
        {
            DXNamingEnumeration sortedByID = new DXNamingEnumeration();

            for (int i = 0; i < size(); i++)
            {
                Object val = this.get(i);
                sortedByID.add(val);
            }
            return sortedByID;
        }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

     */

    protected DataQuery doSearchQuery(DataQuery request)
            throws NamingException
    {
        DXNamingEnumeration en = unthreadedSearch(request.requestDN(), request.filter(), request.searchLevel(), request.returnAttributes());
        request.setEnum(en);
        return finish(request);
    }
View Full Code Here

Examples of com.ca.commons.naming.DXNamingEnumeration

        ButtonRegister br = JXplorer.getButtonRegister();
        br.registerItem(br.BOOKMARKS, addBookmark);

    Properties propertyList = CBUtility.readPropertyFile("bookmarks.txt");

    DXNamingEnumeration keys = new DXNamingEnumeration(propertyList.keys());

        if(keys.size() > 0)
        setMenuItem(bookmarkMenu, bookmarkListener, new String[] {"-", "", "", "", ""} );

        Hashtable bookmarkTable = new Hashtable();

    while (keys.hasMoreElements())
    {
      String key = keys.nextElement().toString();
      if (key.toLowerCase().startsWith("dn"))
                bookmarkTable.put(key.substring(key.indexOf(".")+1), propertyList.getProperty(key));
    }

        DXNamingEnumeration en = new DXNamingEnumeration(bookmarkTable.keys());
        en.sort();

        int size = en.size();

        String[] bookmarkVals = new String[size];
        String[] bookmarkNams = new String[size];

        int j=0;
        while(en.hasMore())
        {
            bookmarkNams[j] = (String)en.next();
            bookmarkVals[j] = (String)bookmarkTable.get(bookmarkNams[j]);
            j++;
        }

    if (size>15)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.