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, 2001 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A *
2N/A */
2N/A
2N/A// SSrvReg.java: Message class for SLP service registration request.
2N/A// Author: James Kempf
2N/A// Created On: Thu Oct 9 14:47:48 1997
2N/A// Last Modified By: Jason Goldschmidt
2N/A// Last Modified On: Thu Apr 5 14:46:29 2001
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 SSrvReg class models the server side SLP service registration. The
2N/A * default class does SLPv2 regs, but subclasses can do other versions
2N/A * by redefining the initialize() and makeReply() messages.
2N/A *
2N/A * @author James Kempf
2N/A */
2N/A
2N/Aclass SSrvReg extends SrvLocMsgImpl {
2N/A
2N/A ServiceURL URL = null; // the service URL.
2N/A String serviceType = ""; // service type.
2N/A Vector attrList = new Vector(); // ServiceLocationAttribute objects.
2N/A Hashtable URLSignature = null; // signature for URL.
2N/A Hashtable attrSignature = null; // the signatures for the attributes.
2N/A
2N/A // Construct a SSrvReg from the input stream.
2N/A
2N/A SSrvReg(SrvLocHeader hdr, DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A super(hdr, SrvLocHeader.SrvReg);
2N/A
2N/A this.initialize(dis);
2N/A
2N/A }
2N/A
2N/A // Initialize the object from the input stream.
2N/A
2N/A void initialize(DataInputStream dis)
2N/A throws ServiceLocationException, IOException {
2N/A
2N/A SLPServerHeaderV2 hdr = (SLPServerHeaderV2)getHeader();
2N/A StringBuffer buf = new StringBuffer();
2N/A
2N/A // Parse in the service URL
2N/A
2N/A Hashtable table = new Hashtable();
2N/A
2N/A URL =
2N/A hdr.parseServiceURLIn(dis,
2N/A table,
2N/A ServiceLocationException.INVALID_REGISTRATION);
2N/A
2N/A URLSignature = (Hashtable)table.get(URL);
2N/A
2N/A // Parse in service type name.
2N/A
2N/A hdr.getString(buf, dis);
2N/A
2N/A // Validate and set URL type.
2N/A
2N/A ServiceType t = new ServiceType(buf.toString());
2N/A
2N/A if (!(URL.getServiceType()).isServiceURL() &&
2N/A !t.equals(URL.getServiceType())) {
2N/A URL.setServiceType(t);
2N/A
2N/A }
2N/A
2N/A // Parse in the scope list.
2N/A
2N/A hdr.parseScopesIn(dis);
2N/A
2N/A // Parse in the attribute list.
2N/A
2N/A attrSignature =
2N/A hdr.parseAuthenticatedAttributeVectorIn(attrList, dis, false);
2N/A
2N/A hdr.constructDescription("SrvReg",
2N/A " URL=``" +
2N/A URL + "''\n" +
2N/A " service type=``" +
2N/A serviceType + "''\n" +
2N/A " attribute list=``" +
2N/A attrList + "''\n" +
2N/A " URL signature=" +
2N/A AuthBlock.desc(URLSignature) + "\n" +
2N/A " attribute signature=" +
2N/A AuthBlock.desc(attrSignature) + "\n");
2N/A }
2N/A
2N/A // Return a SrvAck. We ignore the existing flag, since in V2, fresh comes
2N/A // in. In this case, all we need to do is clone the header.
2N/A
2N/A SrvLocMsg makeReply(boolean existing) {
2N/A
2N/A SLPServerHeaderV2 hdr =
2N/A ((SLPServerHeaderV2)getHeader()).makeReplyHeader();
2N/A
2N/A // Construct description.
2N/A
2N/A hdr.constructDescription("SrvAck", "");
2N/A
2N/A return hdr;
2N/A
2N/A }
2N/A}