Java Code Examples for java.util.Vector#addElement()

The following examples show how to use java.util.Vector#addElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: jvm.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
public Vector getCommandLine()
{
    Vector v = new Vector();
    v.addElement(javaCmd);
    v.addElement("-Duser.language=en");
    v.addElement("-Duser.country=US");
    if ( (flags != null) && (!flags.isEmpty()) )
    {
        StringTokenizer st = new StringTokenizer(flags);
        while (st.hasMoreTokens())
        {
            v.addElement(st.nextToken());
        }
    }
    return v;
}
 
Example 2
Source File: Resolver.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Find the URNs for a given system identifier in the current catalog.
 *
 * @param systemId The system ID to locate.
 *
 * @return A vector of URNs that map to the systemId.
 */
private Vector resolveLocalSystemReverse(String systemId) {
    Vector map = new Vector();
    String osname = SecuritySupport.getSystemProperty("os.name");
    boolean windows = (osname.indexOf("Windows") >= 0);
    Enumeration en = catalogEntries.elements();
    while (en.hasMoreElements()) {
        CatalogEntry e = (CatalogEntry) en.nextElement();
        if (e.getEntryType() == SYSTEM
            && (e.getEntryArg(1).equals(systemId)
                || (windows
                    && e.getEntryArg(1).equalsIgnoreCase(systemId)))) {
            map.addElement(e.getEntryArg(0));
        }
    }
    if (map.size() == 0) {
        return null;
    } else {
        return map;
    }
}
 
Example 3
Source File: JpegEncoder.java    From openbd-core with GNU General Public License v3.0 6 votes vote down vote up
public Huffman(int Width, int Height) {

		bits = new Vector();
		bits.addElement(bitsDCluminance);
		bits.addElement(bitsACluminance);
		bits.addElement(bitsDCchrominance);
		bits.addElement(bitsACchrominance);
		val = new Vector();
		val.addElement(valDCluminance);
		val.addElement(valACluminance);
		val.addElement(valDCchrominance);
		val.addElement(valACchrominance);
		initHuf();
		ImageWidth = Width;
		ImageHeight = Height;

	}
 
Example 4
Source File: DOMXSImplementationSourceImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A method to request a list of DOM implementations that support the
 * specified features and versions, as specified in .
 * @param features A string that specifies which features and versions
 *   are required. This is a space separated list in which each feature
 *   is specified by its name optionally followed by a space and a
 *   version number. This is something like: "XML 3.0 Traversal +Events
 *   2.0"
 * @return A list of DOM implementations that support the desired
 *   features.
 */
public DOMImplementationList getDOMImplementationList(String features) {
    final Vector implementations = new Vector();

    // first check whether the CoreDOMImplementation would do
    DOMImplementationList list = super.getDOMImplementationList(features);
    //Add core DOMImplementations
    for (int i=0; i < list.getLength(); i++ ) {
        implementations.addElement(list.item(i));
    }

    DOMImplementation impl = PSVIDOMImplementationImpl.getDOMImplementation();
    if (testImpl(impl, features)) {
        implementations.addElement(impl);
    }

    impl = XSImplementationImpl.getDOMImplementation();
    if (testImpl(impl, features)) {
        implementations.addElement(impl);
    }
    return new DOMImplementationListImpl(implementations);
}
 
Example 5
Source File: LastReq.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a LastReq object.
 * @param encoding a Der-encoded data.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */

public LastReq(DerValue encoding) throws Asn1Exception, IOException {
    Vector<LastReqEntry> v= new Vector<>();
    if (encoding.getTag() != DerValue.tag_Sequence) {
        throw new Asn1Exception(Krb5.ASN1_BAD_ID);
    }
    while (encoding.getData().available() > 0) {
        v.addElement(new LastReqEntry(encoding.getData().getDerValue()));
    }
    if (v.size() > 0) {
        entry = new LastReqEntry[v.size()];
        v.copyInto(entry);
    }
}
 
Example 6
Source File: BreakIteratorTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void TestSentenceBreak() {
    Vector<String> sentenceSelectionData = new Vector<String>();

    sentenceSelectionData.addElement("This is a simple sample sentence. ");
    sentenceSelectionData.addElement("(This is it.) ");
    sentenceSelectionData.addElement("This is a simple sample sentence. ");
    sentenceSelectionData.addElement("\"This isn\'t it.\" ");
    sentenceSelectionData.addElement("Hi! ");
    sentenceSelectionData.addElement("This is a simple sample sentence. ");
    sentenceSelectionData.addElement("It does not have to make any sense as you can see. ");
    sentenceSelectionData.addElement("Nel mezzo del cammin di nostra vita, mi ritrovai in una selva oscura. ");
    sentenceSelectionData.addElement("Che la dritta via aveo smarrita. ");
    sentenceSelectionData.addElement("He said, that I said, that you said!! ");

    sentenceSelectionData.addElement("Don't rock the boat.\u2029");

    sentenceSelectionData.addElement("Because I am the daddy, that is why. ");
    sentenceSelectionData.addElement("Not on my time (el timo.)! ");

    sentenceSelectionData.addElement("So what!!\u2029");

    sentenceSelectionData.addElement("\"But now,\" he said, \"I know!\" ");
    sentenceSelectionData.addElement("Harris thumbed down several, including \"Away We Go\" (which became the huge success Oklahoma!). ");
    sentenceSelectionData.addElement("One species, B. anthracis, is highly virulent.\n");
    sentenceSelectionData.addElement("Wolf said about Sounder:\"Beautifully thought-out and directed.\" ");
    sentenceSelectionData.addElement("Have you ever said, \"This is where \tI shall live\"? ");
    sentenceSelectionData.addElement("He answered, \"You may not!\" ");
    sentenceSelectionData.addElement("Another popular saying is: \"How do you do?\". ");
    sentenceSelectionData.addElement("Yet another popular saying is: \'I\'m fine thanks.\' ");
    sentenceSelectionData.addElement("What is the proper use of the abbreviation pp.? ");
    sentenceSelectionData.addElement("Yes, I am definatelly 12\" tall!!");

    generalIteratorTest(sentenceBreak, sentenceSelectionData);
}
 
Example 7
Source File: Authenticator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encodes an Authenticator object.
 * @return byte array of encoded Authenticator object.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    Vector<DerValue> v = new Vector<>();
    DerOutputStream temp = new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(authenticator_vno));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), cname.getRealm().asn1Encode()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), cname.asn1Encode()));
    if (cksum != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x03), cksum.asn1Encode()));
    }
    temp = new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(cusec));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x04), temp.toByteArray()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x05), ctime.asn1Encode()));
    if (subKey != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x06), subKey.asn1Encode()));
    }
    if (seqNumber != null) {
        temp = new DerOutputStream();
        // encode as an unsigned integer (UInt32)
        temp.putInteger(BigInteger.valueOf(seqNumber.longValue()));
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x07), temp.toByteArray()));
    }
    if (authorizationData != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x08), authorizationData.asn1Encode()));
    }
    DerValue[] der = new DerValue[v.size()];
    v.copyInto(der);
    temp = new DerOutputStream();
    temp.putSequence(der);
    DerOutputStream out = new DerOutputStream();
    out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x02), temp);
    return out.toByteArray();
}
 
Example 8
Source File: MouseModifiersUnitTest_Extra.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static Vector<String> tokenizeModifiers(String modifierList){
    Vector<String> modifiers = new Vector<>();
    StringTokenizer st = new StringTokenizer(modifierList, "+");
    while (st.hasMoreTokens()){
        String tmp = st.nextToken();
        modifiers.addElement(tmp);
        System.out.println("MODIFIER PARSER : "+tmp);
    }
    return modifiers;
}
 
Example 9
Source File: EncAPRepPart.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encodes an EncAPRepPart object.
 * @return byte array of encoded EncAPRepPart object.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    Vector<DerValue> v = new Vector<>();
    DerOutputStream temp = new DerOutputStream();
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
            true, (byte) 0x00), ctime.asn1Encode()));
    temp.putInteger(BigInteger.valueOf(cusec));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
            true, (byte) 0x01), temp.toByteArray()));
    if (subKey != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
                true, (byte) 0x02), subKey.asn1Encode()));
    }
    if (seqNumber != null) {
        temp = new DerOutputStream();
        // encode as an unsigned integer (UInt32)
        temp.putInteger(BigInteger.valueOf(seqNumber.longValue()));
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,
                true, (byte) 0x03), temp.toByteArray()));
    }
    DerValue der[] = new DerValue[v.size()];
    v.copyInto(der);
    temp = new DerOutputStream();
    temp.putSequence(der);
    DerOutputStream out = new DerOutputStream();
    out.write(DerValue.createTag(DerValue.TAG_APPLICATION,
            true, (byte) 0x1B), temp);
    return out.toByteArray();
}
 
Example 10
Source File: CSS.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return an array of all the strings in <code>value</code>
 *         that are separated by whitespace.
 */
static String[] parseStrings(String value) {
    int         current, last;
    int         length = (value == null) ? 0 : value.length();
    Vector<String> temp = new Vector<String>(4);

    current = 0;
    while (current < length) {
        // Skip ws
        while (current < length && Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        last = current;
        while (current < length && !Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        if (last != current) {
            temp.addElement(value.substring(last, current));
        }
        current++;
    }
    String[] retValue = new String[temp.size()];
    temp.copyInto(retValue);
    return retValue;
}
 
Example 11
Source File: CSS.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * @return an array of all the strings in <code>value</code>
 *         that are separated by whitespace.
 */
static String[] parseStrings(String value) {
    int         current, last;
    int         length = (value == null) ? 0 : value.length();
    Vector<String> temp = new Vector<String>(4);

    current = 0;
    while (current < length) {
        // Skip ws
        while (current < length && Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        last = current;
        while (current < length && !Character.isWhitespace
               (value.charAt(current))) {
            current++;
        }
        if (last != current) {
            temp.addElement(value.substring(last, current));
        }
        current++;
    }
    String[] retValue = new String[temp.size()];
    temp.copyInto(retValue);
    return retValue;
}
 
Example 12
Source File: Authenticator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Encodes an Authenticator object.
 * @return byte array of encoded Authenticator object.
 * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
 * @exception IOException if an I/O error occurs while reading encoded data.
 */
public byte[] asn1Encode() throws Asn1Exception, IOException {
    Vector<DerValue> v = new Vector<>();
    DerOutputStream temp = new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(authenticator_vno));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x00), temp.toByteArray()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x01), cname.getRealm().asn1Encode()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x02), cname.asn1Encode()));
    if (cksum != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x03), cksum.asn1Encode()));
    }
    temp = new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(cusec));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x04), temp.toByteArray()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x05), ctime.asn1Encode()));
    if (subKey != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x06), subKey.asn1Encode()));
    }
    if (seqNumber != null) {
        temp = new DerOutputStream();
        // encode as an unsigned integer (UInt32)
        temp.putInteger(BigInteger.valueOf(seqNumber.longValue()));
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x07), temp.toByteArray()));
    }
    if (authorizationData != null) {
        v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0x08), authorizationData.asn1Encode()));
    }
    DerValue der[] = new DerValue[v.size()];
    v.copyInto(der);
    temp = new DerOutputStream();
    temp.putSequence(der);
    DerOutputStream out = new DerOutputStream();
    out.write(DerValue.createTag(DerValue.TAG_APPLICATION, true, (byte) 0x02), temp);
    return out.toByteArray();
}
 
Example 13
Source File: BinaryMember.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get arguments
 */
public Vector getArguments() {
    if (isConstructor() && (getClassDefinition().getSuperClass() == null)) {
        Vector v = new Vector();
        v.addElement(new LocalMember(0, getClassDefinition(), 0,
                                    getClassDefinition().getType(), idThis));
        return v;
    }
    return null;
}
 
Example 14
Source File: PcalTranslate.java    From tlaplus with MIT License 4 votes vote down vote up
private static Vector ExplodeLabelEither(AST.LabelEither ast, 
                                         String next) throws PcalTranslateException {
    /*******************************************************************
    * Analogous to ExplodeLabelIf, except it hasa sequence of clauses  *
    * rather than just the then and else clauses.                      *
    *                                                                  *
    * The result is a pair: the first is a vector of statements        *
    * corresponding to the block before lt1, and the second is         *
    * is a vector of the remaining labeled statements.                 *
    *******************************************************************/
    Vector result1 = new Vector(); /* For the Either object.           */
    Vector result2 = new Vector(); /* The internal labeled statements. */
    AST.Either newEither = new AST.Either();

    /* Construct Either object */
    newEither.col = ast.col;
    newEither.line = ast.line;
    newEither.setOrigin(ast.getOrigin()) ;
    newEither.ors = new Vector() ;
    for (int i = 0; i < ast.clauses.size(); i++) {
      AST.Clause clause = (AST.Clause) ast.clauses.elementAt(i) ;
      Vector res = 
         CopyAndExplodeLastStmtWithGoto(
           clause.unlabOr,
           (clause.labOr.size() > 0) ?
              ((AST.LabeledStmt) clause.labOr.elementAt(0)).label : next
           ) ;
      /**
       * Set clause.broken, which should be true iff clause.labOr or
       * res.elementAt(1) is non-empty.
       */
     if (clause.labOr.size() != 0 || ((Vector) res.elementAt(1)).size() != 0) {
         clause.setBroken(true) ;
     }         
     newEither.ors.addElement((Vector) res.elementAt(0)) ;
     result2.addAll((Vector) res.elementAt(1)) ;
     result2.addAll(ExplodeLabeledStmtSeq(clause.labOr, next)) ;
    } ;
    result1.addElement(newEither);
    return Pair(result1, result2);
}
 
Example 15
Source File: Ssh2Client.java    From j2ssh-maverick with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Get a list of authentication methods for the user.
 * 
 * @param username
 *            the name of the user
 * @return an array of authentication methods, for example { "password",
 *         "publickey" }
 * @throws SshException
 */
public String[] getAuthenticationMethods(String username)
		throws SshException {
	verifyConnection(false);

	if (authenticationMethods == null) {

		if (Log.isDebugEnabled()) {
			Log.debug(this, "Requesting authentication methods");
		}

		String methods = authentication.getAuthenticationMethods(username,
				ConnectionProtocol.SERVICE_NAME);

		if (Log.isDebugEnabled()) {
			Log.debug(this, "Available authentications are "
					+ methods);
		}
		Vector<String> tmp = new Vector<String>();
		int idx;
		while (methods != null) {
			idx = methods.indexOf(',');
			if (idx > -1) {
				tmp.addElement(methods.substring(0, idx));
				methods = methods.substring(idx + 1);
			} else {
				tmp.addElement(methods);
				methods = null;
			}
		}
		authenticationMethods = new String[tmp.size()];
		tmp.copyInto(authenticationMethods);

		/*
		 * if there are no authentication methods, then check if
		 * isAuthenticated if isAuthenticated then need to start the message
		 * pump, as authenticate will not be called
		 */
		if (isAuthenticated()) {
			connection.start();
		}
	}

	return authenticationMethods;
}
 
Example 16
Source File: MessageDispatcher.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Sends a message to a single member (destination = msg.dest) and returns the response. The message's destination
 * must be non-zero !
 */
public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException {
    Vector mbrs=new Vector();
    RspList rsp_list=null;
    Object dest=msg.getDest();
    Rsp rsp;
    GroupRequest _req=null;

    if(dest == null) {
        if(log.isErrorEnabled())
            log.error("the message's destination is null, " +
                    "cannot send message");
        return null;
    }

    mbrs.addElement(dest);   // dummy membership (of destination address)

    _req=new GroupRequest(msg, corr, mbrs, mode, timeout, 0);
    _req.setCaller(local_addr);
    _req.execute();

    if(mode == GroupRequest.GET_NONE) {
        return null;
    }

    rsp_list=_req.getResults();

    if(rsp_list.size() == 0) {
        if(log.isWarnEnabled())
            log.warn(" response list is empty");
        return null;
    }
    if(rsp_list.size() > 1) {
        if(log.isWarnEnabled())
            log.warn("response list contains more that 1 response; returning first response !");
    }
    rsp=(Rsp) rsp_list.elementAt(0);
    if(rsp.wasSuspected()) {
        throw new SuspectedException(dest);
    }
    if(!rsp.wasReceived()) {
        throw new TimeoutException();
    }
    return rsp.getValue();
}
 
Example 17
Source File: ImplementationType.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void copyRemoteMethods(InterfaceType type, Vector list) {

        if (type.isType(TYPE_REMOTE)) {

            // Copy all the unique methods from type...

            Method[] allMethods = type.getMethods();

            for (int i = 0; i < allMethods.length; i++) {
                Method theMethod = allMethods[i];

                if (!list.contains(theMethod)) {
                    list.addElement(theMethod);
                }
            }

            // Now recurse thru all inherited interfaces...

            InterfaceType[] allInterfaces = type.getInterfaces();

            for (int i = 0; i < allInterfaces.length; i++) {
                copyRemoteMethods(allInterfaces[i],list);
            }
        }
    }
 
Example 18
Source File: LdapSchemaParser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * qdescrlist      = [ qdescr *( qdescr ) ]
 * qdescr          = whsp "'" descr "'" whsp
 * descr           = keystring
 */
final private static String[] readQDescrList(String string, int[] pos)
    throws NamingException {

    int begin, end;
    Vector<String> values = new Vector<>(5);

    if (debug) {
        System.err.println("ReadQDescrList: pos="+pos[0]);
    }

    pos[0]++; // skip '('
    skipWhitespace(string, pos);
    begin = pos[0];
    end = string.indexOf(OID_LIST_END, begin);

    if(end == -1) {
        throw new InvalidAttributeValueException ("oidlist has no end "+
                                                  "mark: " + string);
    }

    while(begin < end) {
        String[] one = readQDString(string,  pos);

        if (debug) {
            System.err.println("ReadQDescrList: found '" + one[0] +
                               "' at begin=" + begin + " end =" + end);
        }

        values.addElement(one[0]);
        skipWhitespace(string, pos);
        begin = pos[0];
    }

    pos[0] = end+1; // skip ')'

    String[] answer = new String[values.size()];
    for (int i = 0; i < answer.length; i++) {
        answer[i] = values.elementAt(i);
    }
    return answer;
}
 
Example 19
Source File: LdapClient.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private LdapResult getSearchReply(LdapRequest req,
    int batchSize, LdapResult res, Hashtable<String, Boolean> binaryAttrs)
    throws IOException, NamingException {

    if (batchSize == 0)
        batchSize = Integer.MAX_VALUE;

    if (res.entries != null) {
        res.entries.setSize(0); // clear the (previous) set of entries
    } else {
        res.entries =
            new Vector<>(batchSize == Integer.MAX_VALUE ? 32 : batchSize);
    }

    if (res.referrals != null) {
        res.referrals.setSize(0); // clear the (previous) set of referrals
    }

    BerDecoder replyBer;    // Decoder for response
    int seq;                // Request id

    Attributes lattrs;      // Attribute set read from response
    Attribute la;           // Attribute read from response
    String DN;              // DN read from response
    LdapEntry le;           // LDAP entry representing response
    int[] seqlen;           // Holder for response length
    int endseq;             // Position of end of response

    for (int i = 0; i < batchSize;) {
        replyBer = conn.readReply(req);

        //
        // process search reply
        //
        replyBer.parseSeq(null);                    // init seq
        replyBer.parseInt();                        // req id
        seq = replyBer.parseSeq(null);

        if (seq == LDAP_REP_SEARCH) {

            // handle LDAPv3 search entries
            lattrs = new BasicAttributes(caseIgnore);
            DN = replyBer.parseString(isLdapv3);
            le = new LdapEntry(DN, lattrs);
            seqlen = new int[1];

            replyBer.parseSeq(seqlen);
            endseq = replyBer.getParsePosition() + seqlen[0];
            while ((replyBer.getParsePosition() < endseq) &&
                (replyBer.bytesLeft() > 0)) {
                la = parseAttribute(replyBer, binaryAttrs);
                lattrs.put(la);
            }
            le.respCtls = isLdapv3 ? parseControls(replyBer) : null;

            res.entries.addElement(le);
            i++;

        } else if ((seq == LDAP_REP_SEARCH_REF) && isLdapv3) {

            // handle LDAPv3 search reference
            Vector<String> URLs = new Vector<>(4);

            // %%% Although not strictly correct, some LDAP servers
            //     encode the SEQUENCE OF tag in the SearchResultRef
            if (replyBer.peekByte() ==
                (Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR)) {
                replyBer.parseSeq(null);
            }

            while ((replyBer.bytesLeft() > 0) &&
                (replyBer.peekByte() == Ber.ASN_OCTET_STR)) {

                URLs.addElement(replyBer.parseString(isLdapv3));
            }

            if (res.referrals == null) {
                res.referrals = new Vector<>(4);
            }
            res.referrals.addElement(URLs);
            res.resControls = isLdapv3 ? parseControls(replyBer) : null;

            // Save referral and continue to get next search result

        } else if (seq == LDAP_REP_EXTENSION) {

            parseExtResponse(replyBer, res); //%%% ignore for now

        } else if (seq == LDAP_REP_RESULT) {

            parseResult(replyBer, res, isLdapv3);
            res.resControls = isLdapv3 ? parseControls(replyBer) : null;

            conn.removeRequest(req);
            return res;     // Done with search
        }
    }

    return res;
}
 
Example 20
Source File: PermissionAdminHelperImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public int cmdSetcondpermission(Dictionary<String,?> opts,
                                Reader in,
                                PrintWriter out,
                                Session session)
{
  if (condPermAdmin == null) {
    out.println("Conditional Permission Admin service is not available");
    return 1;
  }
  Vector /* ConditionInfo */<ConditionInfo> cis = new Vector<ConditionInfo>();
  Vector /* PermissionInfo */<PermissionInfo> pis = new Vector<PermissionInfo>();
  String name = (String) opts.get("-name");
  String [] cpis = (String []) opts.get("conditional_permission_info");
  String endChar = null;
  StringBuffer buf = new StringBuffer();
  for (int i = 0; i < cpis.length; ) {
    String cpi = cpis[i];
    if (endChar != null) {
      buf.append(cpi);
      i++;
      if (cpi.endsWith(endChar)) {
        try {
          if (endChar == "]") {
            cis.addElement(new ConditionInfo(buf.toString()));
          } else {
            pis.addElement(new PermissionInfo(buf.toString()));
          }
        } catch (IllegalArgumentException e) {
          out.println("ERROR! Failed to instanciate: " + buf.toString()
              + " " + e.getMessage());
          return 1;
        }
        endChar = null;
        buf.setLength(0);
      } else {
        buf.append(' ');
      }
    } else if (cpi.startsWith("[")) {
      endChar = "]";
    } else if (cpi.startsWith("(")) {
      endChar = ")";
    } else {
      out.println("ERROR! Expected start char '(' or '[', got: " + cpi);
      return 1;
    }
  }
  ConditionInfo [] cia = cis.toArray(new ConditionInfo [cis.size()]);
  PermissionInfo [] pia = pis.toArray(new PermissionInfo [pis.size()]);
  condPermAdmin.setConditionalPermissionInfo(name, cia, pia);
  return 0;
}