/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
// SLPV1SSrvMsg.java: SLPv1 server side service rqst/reply.
// Author: James Kempf
// Created On: Thu Sep 10 15:33:58 1998
// Last Modified By: James Kempf
// Last Modified On: Fri Nov 6 14:03:00 1998
// Update Count: 41
//
/**
* The SLPV1SSrvMsg class models the SLP server side service request message.
*
* @author James Kempf
*/
// For eating whitespace.
// Comma for list parsing.
// Logical operators.
// Logical operator corner case needs this.
// Comparison/Assignment operators.
// Parens.
// LDAP present operator
// Wildcard operator.
// Character code for parsing.
// For creating a null reply.
protected SLPV1SSrvMsg() {}
// Construct a SLPV1SSrvMsg from the input stream.
throws ServiceLocationException, IOException {
}
// Construct an empty SLPV1SSrvMsg, for monolingual off.
throws ServiceLocationException {
return msg;
}
// Initialize the message from the input stream.
throws ServiceLocationException, IOException {
// First get the previous responder.
// Now get the raw query.
// Parse the raw query to pull out the service type, scope,
// and query.
try {
// Get the scope.
// Special case if scope is empty (meaning the next
// token will be a slash).
scope = "";
} else {
// Validate the scope name.
}
}
// Set up scopes vector.
// Substitute default scope here.
}
// Parsing the query is complicated by opaques having slashes.
String q = "";
while (st.hasMoreTokens()) {
}
// Drop off the final backslash, error if none.
if (!q.endsWith("/")) {
throw
"v1_query_error",
}
// Save header char code for parsing.
// Convert the query into a V2 query.
convertQuery();
// If the query is for "service:directory-agent", then we
// mark it as having been multicast, because that is the
// only kind of multicast that we accept for SLPv1. Anybody
// who unicasts this to us will time out.
}
// Construct description.
" service type=``" +
serviceType + "''\n" +
" query=``" +
query + "''");
} catch (NoSuchElementException ex) {
throw
"v1_query_error",
}
}
// Make a reply message.
throws ServiceLocationException {
// Edit out abstract types and nonService: URLs.
while (en.hasMoreElements()) {
// Reject if abstract type or nonservice: URL.
}
}
// keep this info so SAs can drop 0 replies
// Write out the size of the list.
// Write out the size of the list.
while (en.hasMoreElements()) {
}
// We ignore the signatures because we only do V1 compatibility
// for nonprotected scopes.
return hdr;
}
// Convert the query to a V2 query.
void convertQuery()
throws ServiceLocationException {
// Check for empty query.
return;
}
// Check for query join.
// Rewrite to a standard query.
}
// Now rewrite the query into v2 format.
}
// Rewrite a query join as a conjunction.
throws ServiceLocationException {
// Turn infix expression into prefix.
boolean lastTokComma = true;
int numEx = 0;
while (tk.hasMoreElements()) {
if (lastTokComma) {
throw
"v1_query_error",
} else {
lastTokComma = true;
}
} else {
lastTokComma = false;
throw
"v1_query_error",
}
// Put in parens
numEx++;
}
}
throw
"v1_query_error",
}
if (numEx > 1) {
}
}
// Rewrite a v1 query into v2 format. This includes character escaping.
throws ServiceLocationException {
// Parse a logical expression.
// Initialize parse tables in terminal.
// Parse through the expression.
try {
} catch (IOException ex) {
throw
"v1_query_error",
}
}
// Do the actual parsing, using the passed-in stream tokenizer.
private void
throws ServiceLocationException, IOException {
int tok = 0;
boolean ret = true;
do {
// We should be at the beginning a parenthesized
// where list.
if (tok == OPEN_PAREN) {
// Get the next token. Eat whitespace in the process.
// If it's a logOp, then process as a logical expression.
// This handles the following nasty case:
//
// (,-==the rest of it)
// Need to check for escape as first thing.
} else {
// cause we can't push back twice
}
} else {
}
break;
break;
} else {
// It's a terminal expression. Push back the last token
// and parse the terminal.
break;
}
} else {
throw
"v1_query_error",
}
} while (true);
// Since terminals are allowed alone at the top level,
// we need to check here whether anything else is
// in the query.
if (start) {
// The line should have ended by now.
throw
"v1_query_error",
}
}
}
// Rewrite a logical expression.
private void
throws ServiceLocationException, IOException {
// Append paren and operator to buffer.
int tok = 0;
do {
if (tok == OPEN_PAREN) {
// So parseInternal() sees a parenthesized list.
// Go back to parseInternal.
} else if (tok == CLOSE_PAREN) {
// Append the character to the buffer and return.
return;
} else {
throw
"v1_query_error",
}
// Error if we've not caught ourselves before this.
throw
"v1_query_error",
}
// Parse a terminal. Opening paren has been got.
boolean firstEscaped)
throws ServiceLocationException, IOException {
int tok = 0;
// Gather the tag and value.
throw
"v1_query_error",
}
// Parse the tag.
throw
"v1_query_error",
}
// Unescape tag.
charCode);
// Now escape in v2 format,
// Parse the operator.
// If this was a keyword operator, then add present
// operator and closing paren and return.
return;
}
// Parse value by reading up to the next close paren.
// Returned value will be in v2 format.
// Construct the comparision depending on the operator.
// If the value is an integer, we can construct a query
// that will exclude the number.
try {
// Bump the integer up and down to catch numbers on both
// sides of the required number. Be careful not to
// overstep bounds.
}
}
}
} catch (NumberFormatException ex) {
// It's not an integer. We can construct a query expression
// that will not always work. The query rules out advertisments
// where the attribute value doesn't match and there are
// no other attributes or values, and advertisements
// that don't contain the attribute, but it doesn't rule out
// a multivalued attribute with other values or if there
// are other attributes. The format of the query is:
// "(&(<tag>=*)(!(<tag>=<value>))).
}
int n = 0;
try {
} catch (NumberFormatException ex) {
// It's a parse error here.
throw
"v1_query_error",
}
// We don't attempt to handle something that would cause
// arithmetic overflow.
throw
"v1_query_error",
}
// Construct a query that includes everything
// to the correct side.
} else {
}
} else {
// Simple, single operator. Just add it with the
// value.
// Need to distinguish less and greater equal.
} else {
}
}
}
// Gather tokens with embedded whitespace and return.
throws ServiceLocationException, IOException {
// Take care of corner case here.
if (ampStart) {
ampStart = false;
}
do {
} else {
break;
}
} while (true);
}
throws ServiceLocationException, IOException {
// If the token is a close paren, then this was a keyword
// (e.g. "(foo)". Return the present operator.
if ((char)tok == CLOSE_PAREN) {
return PRESENT;
}
throw
"v1_query_error",
}
// Get the next token.
// Look for dual character operators.
// Here, we can have either "!=", "<=", ">=", or "==".
// Anything else is wrong.
throw
"v1_query_error",
}
// Assign the right dual operator.
} else if (compOp == GREATER_OP) {
}
// Error if the comparison operator was something other
// than ``<'' or ``>'' and there is no equal. This
// rules out ``!'' or ``='' alone.
throw
"v1_query_error",
} else {
// Push back the last token if it wasn't a two character operator.
}
return compOp;
}
throws ServiceLocationException, IOException {
int tok = 0;
// Eat leading whitespace.
// If the first value is a paren, then we've got an
// opaque.
if ((char)tok == OPEN_PAREN) {
// Collect all tokens up to the closing paren.
do {
// It's a closing paren. break out of the loop.
if ((char)tok == CLOSE_PAREN) {
break;
} else {
throw
"v1_query_error",
}
} while (true);
// Eat whitespace until closing paren.
if ((char)tok != CLOSE_PAREN) {
throw
"v1_query_error",
}
} else {
// Error if just a closed paren.
if (tok == CLOSE_PAREN) {
throw
"v1_query_error",
}
do {
// Append the token if a WORD
(tok != CLOSE_PAREN)) {
// Otherwise, it's a token char, so append.
}
} while (tok != CLOSE_PAREN);
}
// If a wildcard, remove wildcard stars here for later re-insertion.
boolean wildstart = false;
boolean wildend = false;
wildstart = true;
}
wildend = true;
}
// Evaluate the value.
// Now convert to v2 format, and return.
strval =
false);
// Add wildcards back in.
if (wildstart) {
}
if (wildend) {
}
} else {
}
return strval;
}
// Eat whitespace.
throws IOException {
}
return tok;
}
}