2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A *
2N/A */
2N/A
2N/A// CSAAdvert.java: Message class for SLP CSAAdvert message
2N/A// Author: James Kempf
2N/A// Created On: Fri Oct 10 10:48:05 1997
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Tue Oct 27 10:57:41 1998
2N/A// Update Count: 95
2N/A//
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.io.*;
2N/A
2N/A
2N/A/**
2N/A * The CSAAdvert class models the SLP SAAdvert message, client side.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/A
2N/Aclass CSAAdvert extends SrvLocMsgImpl {
2N/A
2N/A ServiceURL URL = null; // The DA's service URL
2N/A Hashtable authBlock = null; // Scope auth blocks.
2N/A Vector attrs = new Vector(); // The attributes.
2N/A
2N/A // Construct a CSAAdvert from the input stream.
2N/A
2N/A CSAAdvert(SLPHeaderV2 hdr, DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A super(hdr, SrvLocHeader.SAAdvert);
2N/A
2N/A // Parse in SA's service URL.
2N/A
2N/A StringBuffer buf = new StringBuffer();
2N/A
2N/A byte[] urlBytes = hdr.getString(buf, dis);
2N/A
2N/A try {
2N/A
2N/A URL = new ServiceURL(buf.toString(), ServiceURL.LIFETIME_NONE);
2N/A
2N/A } catch (IllegalArgumentException ex) {
2N/A
2N/A throw
2N/A new ServiceLocationException(
2N/A ServiceLocationException.PARSE_ERROR,
2N/A "malformed_url",
2N/A new Object[] {ex.getMessage()});
2N/A
2N/A }
2N/A
2N/A // Validate the service URL.
2N/A
2N/A ServiceType serviceType = URL.getServiceType();
2N/A
2N/A if (!serviceType.equals(Defaults.SA_SERVICE_TYPE)) {
2N/A throw
2N/A new ServiceLocationException(
2N/A ServiceLocationException.PARSE_ERROR,
2N/A "not_right_url",
2N/A new Object[] {URL, "SA"});
2N/A
2N/A }
2N/A
2N/A // Parse in the scope list.
2N/A
2N/A byte[] scopeBytes = hdr.getString(buf, dis);
2N/A
2N/A hdr.scopes =
2N/A hdr.parseCommaSeparatedListIn(buf.toString(), true);
2N/A
2N/A // Unescape scopes.
2N/A
2N/A hdr.unescapeScopeStrings(hdr.scopes);
2N/A
2N/A // Validate scope list.
2N/A
2N/A DATable.validateScopes(hdr.scopes, hdr.locale);
2N/A
2N/A // Parse in attributes.
2N/A
2N/A byte attrBytes[] = hdr.parseAttributeVectorIn(attrs, dis, false);
2N/A
2N/A // Construct bytes for auth.
2N/A
2N/A Object[] message = new Object[6];
2N/A
2N/A // None of the strings have leading length fields, so add them here
2N/A ByteArrayOutputStream abaos = new ByteArrayOutputStream();
2N/A hdr.putInteger(urlBytes.length, abaos);
2N/A message[0] = abaos.toByteArray();
2N/A message[1] = urlBytes;
2N/A
2N/A abaos = new ByteArrayOutputStream();
2N/A hdr.putInteger(attrBytes.length, abaos);
2N/A message[2] = abaos.toByteArray();
2N/A message[3] = attrBytes;
2N/A
2N/A abaos = new ByteArrayOutputStream();
2N/A hdr.putInteger(scopeBytes.length, abaos);
2N/A message[4] = abaos.toByteArray();
2N/A message[5] = scopeBytes;
2N/A
2N/A // Parse in an auth block if there.
2N/A
2N/A authBlock = hdr.parseSignatureIn(message, dis);
2N/A
2N/A // Set number of replies.
2N/A
2N/A hdr.iNumReplies = 1;
2N/A
2N/A }
2N/A}