All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cosylab.epics.caj.cas.handlers.UsernameResponse Maven / Gradle / Ivy

There is a newer version: 1.1.15
Show newest version
/*
 * Copyright (c) 2004 by Cosylab
 *
 * The full license specifying the redistribution, modification, usage and other
 * rights and obligations is included with the distribution of this project in
 * the file "LICENSE-CAJ". If the license is not included visit Cosylab web site,
 * .
 *
 * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
 * IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, ASSUMES
 * _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE RESULTING FROM THE USE, MODIFICATION,
 * OR REDISTRIBUTION OF THIS SOFTWARE.
 */

package com.cosylab.epics.caj.cas.handlers;

import gov.aps.jca.CAStatus;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;

import com.cosylab.epics.caj.cas.CAJServerContext;
import com.cosylab.epics.caj.cas.CASTransport;
import com.cosylab.epics.caj.impl.Transport;

/**
 * Hostname request handler.
 * @author Matej Sekoranja
 * @version $id$
 */
public class UsernameResponse extends AbstractCASResponseHandler {

	/**
	 * @param context
	 */
	public UsernameResponse(CAJServerContext context) {
		super(context, "Username request");
	}

	/**
	 * @see com.cosylab.epics.caj.impl.handlers.AbstractCAJResponseHandler#internalHandleResponse(java.net.InetSocketAddress, com.cosylab.epics.caj.impl.Transport, java.nio.ByteBuffer[])
	 */
	protected void internalHandleResponse(
		InetSocketAddress responseFrom,
		Transport transport,
		ByteBuffer[] response) {

		CASTransport casTransport = (CASTransport)transport;
		
		// currently this has to occur prior to 
	    // creating channels or its not allowed
		if (casTransport.getChannelCount() != 0)
		{
			sendException(transport, 0, CAStatus.UNAVAILINSERV, response[0], null);
			return;
		}

		String userName = extractString(response[1], 0, payloadSize, false);
		casTransport.setClientUsername(userName); 
		
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy