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// CAttrMsg.java: Message class for SLP attribute
2N/A// reply.
2N/A// Author: James Kempf Created On: Thu Oct 9 15:17:36 1997
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Tue Oct 27 10:57:38 1998
2N/A// Update Count: 107
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 CAttrMsg class models the SLP client side attribute message.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/Aclass CAttrMsg extends SrvLocMsgImpl {
2N/A
2N/A // Vector of ServiceLocationAttribute objects
2N/A Vector attrList = new Vector();
2N/A Hashtable attrAuthBlock = null; // auth block list for objects
2N/A
2N/A // Only used for testing.
2N/A
2N/A protected CAttrMsg() { }
2N/A
2N/A // Construct a CAttrMsg from the byte input stream.
2N/A
2N/A CAttrMsg(SLPHeaderV2 hdr, DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A super(hdr, SrvLocHeader.AttrRply);
2N/A
2N/A // Don't parse the rest if there's an error.
2N/A
2N/A if (hdr.errCode != ServiceLocationException.OK) {
2N/A return;
2N/A
2N/A }
2N/A
2N/A // Ignore if overflow.
2N/A
2N/A if (hdr.overflow) {
2N/A return;
2N/A
2N/A }
2N/A
2N/A // Parse in the potentially authenticated attribute list.
2N/A
2N/A attrAuthBlock =
2N/A hdr.parseAuthenticatedAttributeVectorIn(attrList, dis, true);
2N/A
2N/A // Verify authentication, if necessary.
2N/A
2N/A if (attrAuthBlock != null) {
2N/A AuthBlock.verifyAll(attrAuthBlock);
2N/A }
2N/A
2N/A // Set the number of replies.
2N/A
2N/A hdr.iNumReplies = attrList.size();
2N/A
2N/A }
2N/A
2N/A // Construct a CAttrMsg payload from the arguments. This will be
2N/A // an AttrRqst message.
2N/A
2N/A CAttrMsg(Locale locale, ServiceURL url, Vector scopes, Vector tags)
2N/A throws ServiceLocationException {
2N/A
2N/A this.hdr = new SLPHeaderV2(SrvLocHeader.AttrRqst, false, locale);
2N/A
2N/A constructPayload(url.toString(), scopes, tags);
2N/A
2N/A }
2N/A
2N/A // Construct a CAttrMsg payload from the arguments. This will be
2N/A // an AttrRqst message.
2N/A
2N/A CAttrMsg(Locale locale, ServiceType type, Vector scopes, Vector tags)
2N/A throws ServiceLocationException {
2N/A
2N/A this.hdr = new SLPHeaderV2(SrvLocHeader.AttrRqst, false, locale);
2N/A
2N/A constructPayload(type.toString(), scopes, tags);
2N/A
2N/A }
2N/A
2N/A // Convert the message into bytes for the payload buffer.
2N/A
2N/A protected void constructPayload(String typeOrURL,
2N/A Vector scopes,
2N/A Vector tags)
2N/A throws ServiceLocationException {
2N/A
2N/A SLPHeaderV2 hdr = (SLPHeaderV2)this.hdr;
2N/A hdr.scopes = (Vector)scopes.clone();
2N/A
2N/A // Set up previous responders.
2N/A
2N/A hdr.previousResponders = new Vector();
2N/A
2N/A ByteArrayOutputStream baos = new ByteArrayOutputStream();
2N/A
2N/A // Write out the service type or URL.
2N/A
2N/A hdr.putString(typeOrURL, baos);
2N/A
2N/A // Escape scope strings for transmission.
2N/A
2N/A hdr.escapeScopeStrings(scopes);
2N/A
2N/A // Parse out the scopes.
2N/A
2N/A hdr.parseCommaSeparatedListOut(scopes, baos);
2N/A
2N/A // Escape tags going out.
2N/A
2N/A hdr.escapeTags(tags);
2N/A
2N/A // Parse out the tags
2N/A
2N/A hdr.parseCommaSeparatedListOut(tags, baos);
2N/A
2N/A // Retrieve the configured SPI, if any
2N/A String spi = "";
2N/A if (SLPConfig.getSLPConfig().getHasSecurity()) {
2N/A LinkedList spiList = AuthBlock.getSPIList("sun.net.slp.SPIs");
2N/A if (spiList != null && !spiList.isEmpty()) {
2N/A // There can be only one configured SPI for UAs
2N/A spi = (String) spiList.getFirst();
2N/A }
2N/A }
2N/A
2N/A hdr.putString(spi, baos);
2N/A
2N/A // Set payload.
2N/A
2N/A hdr.payload = baos.toByteArray();
2N/A }
2N/A
2N/A}