beepcore-java-commits Mailing List for Java BEEP Core (Page 12)
Status: Beta
Brought to you by:
huston
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(22) |
Aug
(1) |
Sep
|
Oct
(16) |
Nov
(60) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(3) |
Feb
|
Mar
(4) |
Apr
(2) |
May
(13) |
Jun
|
Jul
|
Aug
(10) |
Sep
(34) |
Oct
(27) |
Nov
(2) |
Dec
(2) |
| 2003 |
Jan
|
Feb
|
Mar
(3) |
Apr
(15) |
May
(11) |
Jun
(14) |
Jul
(5) |
Aug
(1) |
Sep
(24) |
Oct
(4) |
Nov
(26) |
Dec
(1) |
| 2004 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:41
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/tls
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/profile/tls
Modified Files:
TLSProfile.java
Log Message:
New *DataStream
Index: TLSProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/tls/TLSProfile.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** TLSProfile.java 2001/07/12 07:09:10 1.11
--- TLSProfile.java 2001/10/31 00:32:38 1.12
***************
*** 95,100 ****
public static TLSProfile getDefaultInstance() throws BEEPException
{
! return
getInstance("org.beepcore.beep.profile.tls.ptls.TLSProfilePureTLS");
}
--- 95,110 ----
public static TLSProfile getDefaultInstance() throws BEEPException
{
! try {
! return
getInstance("org.beepcore.beep.profile.tls.ptls.TLSProfilePureTLS");
+ } catch (NoClassDefFoundError e) {
+ }
+
+ try {
+ return
+ getInstance("org.beepcore.beep.profile.tls.jsse.TLSProfileJSSE");
+ } catch (NoClassDefFoundError e) {
+ throw new BEEPException("TLS not installed");
+ }
}
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:41
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/util
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/util
Added Files:
BufferSegment.java
Log Message:
New *DataStream
--- NEW FILE: BufferSegment.java ---
package org.beepcore.beep.util;
/**
* A <code>BufferSegment</code> represents a BEEP Frame payload and holds
* the BEEP Frames's Header, Trailer and the message payload.
*
* It contains a byte array an offset into the array and the
* length from the offset.
*
* @author Huston Franklin
* @version $Revision: 1.1 $, $Date: 2001/10/31 00:32:38 $
*/
public class BufferSegment {
/**
* Constructor BufferSegment
*
* @param data A byte array containing a BEEP Frame payload.
*/
public BufferSegment(byte[] data)
{
this.data = data;
this.offset = 0;
this.length = data.length;
}
/**
* Constructor BufferSegment
*
* @param data A byte array containing a BEEP Frame payload.
* @param offset Indicates the begining position of the BEEP Frame
* payload in the byte array <code>data</code>.
* @param length Number of valid bytes in the byte array starting from
* <code>offset</code>.
*/
public BufferSegment(byte[] data, int offset, int length)
{
this.data = data;
this.offset = offset;
this.length = length;
}
public byte[] getData()
{
return this.data;
}
public int getOffset()
{
return this.offset;
}
public int getLength()
{
return this.length;
}
private byte[] data;
private int offset;
private int length;
}
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:41
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/profile/sasl/otp
Modified Files:
OTPAuthenticator.java SASLOTPProfile.java
Log Message:
New *DataStream
Index: OTPAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/OTPAuthenticator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** OTPAuthenticator.java 2001/07/30 13:48:15 1.8
--- OTPAuthenticator.java 2001/10/31 00:32:38 1.9
***************
*** 142,146 ****
state = STATE_STARTED;
channel = ch;
! channel.setDataListener(this);
}
--- 142,146 ----
state = STATE_STARTED;
channel = ch;
! channel.setMessageListener(this);
}
***************
*** 738,742 ****
{
message.sendRPY(new StringDataStream(new Blob(Blob.STATUS_COMPLETE).toString()));
! channel.setDataListener(null);
}
catch(BEEPException x)
--- 738,742 ----
{
message.sendRPY(new StringDataStream(new Blob(Blob.STATUS_COMPLETE).toString()));
! channel.setMessageListener(null);
}
catch(BEEPException x)
Index: SASLOTPProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/SASLOTPProfile.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** SASLOTPProfile.java 2001/06/28 15:42:49 1.5
--- SASLOTPProfile.java 2001/10/31 00:32:38 1.6
***************
*** 166,170 ****
"Blobbed64 Challenge is=>" + data);
}
! channel.setDataListener(temp);
if(blob != null)
sendProfile(channel.getSession(), URI, blob.toString(),
--- 166,170 ----
"Blobbed64 Challenge is=>" + data);
}
! channel.setMessageListener(temp);
if(blob != null)
sendProfile(channel.getSession(), URI, blob.toString(),
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/core Modified Files: ByteDataStream.java Channel.java Frame.java Message.java MessageListener.java MessageMSG.java MessageStatus.java ProfileRegistry.java Session.java StringDataStream.java TuningProfile.java Added Files: InputDataStream.java InputDataStreamAdapter.java MimeHeaders.java OutputDataStream.java Log Message: New *DataStream --- NEW FILE: InputDataStream.java --- /* * InputDataStream.java $Revision: 1.1 $ $Date: 2001/10/31 00:32:37 $ * * Copyright (c) 2001 Huston Franklin. All rights reserved. * * The contents of this file are subject to the Blocks Public License (the * "License"); You may not use this file except in compliance with the License. * * You may obtain a copy of the License at http://www.invisible.net/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * */ package org.beepcore.beep.core; import java.util.Enumeration; import java.util.Iterator; import java.util.LinkedList; import org.beepcore.beep.util.BufferSegment; /** * <code>InputDataStream</code> holds a stream of * <code>BufferSegments</code>(s) and provides accessor methods to * that stream. * <p> * <b>Note that this implementation is not synchronized.</b> If * multiple threads access a <code>InputDataStream</code> * concurrently, data may be inconsistent or lost. * * @see org.beepcore.beep.util.BufferSegment * * @author Huston Franklin * @version $Revision: 1.1 $, $Date: 2001/10/31 00:32:37 $ */ public class InputDataStream { /** * Creates a <code>InputDataStream</code>. */ InputDataStream() { } /** * Creates a <code>InputDataStream</code>. * For use with in <code>Channel</code>. * * @param channel Is notified as BufferSegments are read this allows the * Channel to update the receive window. */ InputDataStream(Channel channel) { this.channel = channel; } /** * Creates a <code>InputDataStream</code>. * * @param buf The first buffer in the data stream. */ InputDataStream(BufferSegment buf) { this.add(buf); } /** * Creates a <code>InputDataStream</code>. * * @param buf The first buffer in the data stream. */ InputDataStream(BufferSegment buf, boolean complete) { this(buf); if (complete) { this.setComplete(); } } void add(BufferSegment segment) { if( this.closed) { if (this.channel != null) { this.channel.freeReceiveBufferBytes(segment.getLength()); } return; } synchronized (this.buffers) { this.buffers.addLast(segment); this.buffers.notify(); } this.availableBytes += segment.getLength(); } public int available() { return this.availableBytes; // int bytesAvailable = 0; // synchronized (this.buffers) { // Iterator i = this.buffers.iterator(); // while (i.hasNext()) { // bytesAvailable += ((BufferSegment) i.next()).getLength(); // } // } // return bytesAvailable; } /** * @todo doc */ public boolean availableSegment() { return (this.buffers.isEmpty() == false); } /** * @todo doc */ public void close() { this.closed = true; while (this.availableSegment()) { this.getNextSegment(); } } /** * @todo doc */ public InputDataStreamAdapter getInputStream() { if (stream == null) { stream = new InputDataStreamAdapter(this); } return stream; } /** * @todo doc */ public BufferSegment getNextSegment() { BufferSegment b; synchronized (buffers) { b = (BufferSegment) buffers.removeFirst(); } if (this.channel != null) { this.channel.freeReceiveBufferBytes(b.getLength()); } this.availableBytes -= b.getLength(); return b; } public BufferSegment waitForNextSegment() throws InterruptedException { synchronized (buffers) { if (availableSegment() == false) { buffers.wait(); } return getNextSegment(); } } public boolean isClosed() { return closed; } /** * Returns <code>true</code> if no more bytes will be added to * those currently available on this stream. Returns * <code>false</code> if more bytes are expected. */ public boolean isComplete() { return this.complete; } void setComplete() { this.complete = true; // @todo notify objects waiting for more buffers. } LinkedList buffers = new LinkedList(); private int availableBytes = 0; private Channel channel = null; private boolean closed = false; private boolean complete = false; private InputDataStreamAdapter stream = null; } /** * Returns the content type of a <code>InputDataStrea</code>. If * the <code>BufferSegment</code> containing the content type * hasn't been received yet, the method blocks until it is * received. * * @return Content type. * * @throws BEEPException * @deprecated */ // public String getContentType() throws BEEPException // { // return this.getInputStream().getContentType(); // } /** * Returns the value of the MIME entity header which corresponds * to the given <code>name</code>. If the <code>BufferSegment</code> * containing the content type hasn't been received yet, the * method blocks until it is received. * * @param name Name of the entity header. * @return String Value of the entity header. * * @throws BEEPException * @deprecated */ // public String getHeaderValue(String name) throws BEEPException // { // return this.getInputStream().getHeaderValue(name); // } /** * Returns an <code>Enumeration</code> of all the MIME entity * header names belonging to this <code>InputDataStream</code>. * If the <code>BufferSegment</code> containing the content type * hasn't been received yet, the method blocks until it is * received. * * @throws BEEPException * @deprecated */ // public Enumeration getHeaderNames() throws BEEPException // { // return this.getInputStream().getHeaderNames(); // } /** * Returns the transfer encoding of a <code>InputDataStrea</code>. * If the <code>BufferSegment</code> containing the content type * hasn't been received yet, the method blocks until it is * received. * * @throws BEEPException * @deprecated */ // public String getTransferEncoding() throws BEEPException // { // return this.getInputStream().getTransferEncoding(); // } --- NEW FILE: InputDataStreamAdapter.java --- package org.beepcore.beep.core; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Enumeration; import java.util.Hashtable; import org.beepcore.beep.util.BufferSegment; import org.beepcore.beep.util.Log; public class InputDataStreamAdapter extends java.io.InputStream { InputDataStreamAdapter(InputDataStream ids) { this.ids = ids; } public int available() { if (this.state != STATE_HEADERS_PARSED) { parseHeaders(); if (this.state != STATE_HEADERS_PARSED) { return 0; } } if (this.pos == this.curBuf.getLength()) { setNextBuffer(); } return (this.curBuf.getLength() - this.pos) + this.ids.available(); } public void close() { ids.close(); } /** * Returns the content type of a <code>FrameDataStrea</code>. If the * <code>Frame</code> containing the content type hasn't been received yet, * the method blocks until it is received. * * @return Content type. * * @throws BEEPException */ public String getContentType() throws BEEPException { return this.getHeaderValue(MimeHeaders.CONTENT_TYPE); } /** * Returns the value of the MIME entity header which corresponds * to the given <code>name</code>. If the <code>Frame</code> * containing the content type hasn't been received yet, the * method blocks until it is received. * * @param name Name of the entity header. * @return String Value of the entity header. * * @throws BEEPException */ public String getHeaderValue(String name) throws BEEPException { waitAvailable(); return (String) this.mimeHeaders.get(name); } /** * Returns an <code>Enumeration</code> of all the MIME entity header names * belonging to this <code>FrameDataStream</code>. If the * <code>Frame</code> containing the content type hasn't been received yet, * the method blocks until it is received. * * @throws BEEPException */ public Enumeration getHeaderNames() throws BEEPException { waitAvailable(); return this.mimeHeaders.keys(); } /** * Returns the transfer encoding of a <code>FrameDataStrea</code>. If the * <code>Frame</code> containing the content type hasn't been received yet, * the method blocks until it is received. * * @return Content type. * * @throws BEEPException */ public String getTransferEncoding() throws BEEPException { return this.getHeaderValue(MimeHeaders.CONTENT_TRANSFER_ENCODING); } public int read() throws IOException { if (waitAvailable() == -1) { return -1; } return internalRead(); } public int read(byte[] b) throws IOException { return read(b, 0, b.length); } public int read(byte[] b, int off, int len) throws IOException { if (off == -1 || len == -1 || off + len > b.length) throw new IndexOutOfBoundsException(); int bytesRead = 0; while (bytesRead < len) { if (waitAvailable() == -1) { if (bytesRead == 0) { return -1; } else { break; } } int n = internalRead(b, off + bytesRead, len - bytesRead); if (n == 0 && ids.isClosed()) { return bytesRead != 0 ? bytesRead : -1; } bytesRead += n; } return bytesRead; } public long skip(long n) throws IOException { if (n > Integer.MAX_VALUE) { return 0; } int bytesSkipped = 0; while (bytesSkipped < n && ids.isClosed() == false) { if (waitAvailable() == -1) { break; } int i = Math.min(((int) n) - bytesSkipped, curBuf.getLength() - pos); pos += i; bytesSkipped += i; } return bytesSkipped; } /** * This version of read() does not block if there are no bytes * available. */ private int internalRead() { if (setNextBuffer() == false) { return -1; } int b = curBuf.getData()[curBuf.getOffset() + pos] & 0xff; pos++; return b; } /** * This version of read(byte[], int, int) does not block if * there are no bytes available. */ private int internalRead(byte[] b, int off, int len) { int bytesRead = 0; while (bytesRead < len) { if (setNextBuffer() == false) { break; } int n = Math.min(len - bytesRead, curBuf.getLength() - pos); System.arraycopy(curBuf.getData(), curBuf.getOffset() + pos, b, off + bytesRead, n); pos += n; bytesRead += n; } return bytesRead; } private void parseHeaders() { while (true) { switch (state) { case STATE_INIT: state = STATE_PARSING_NAME; break; case STATE_PARSING_NAME: parseName(); if (state == STATE_PARSING_NAME) { return; } break; case STATE_PARSING_NAME_TERMINATOR: parseNameTerminator(); if (state == STATE_PARSING_NAME_TERMINATOR) { return; } break; case STATE_PARSING_VALUE: parseValue(); if (state == STATE_PARSING_VALUE) { return; } break; case STATE_PARSING_VALUE_TERMINATOR: parseValueTerminator(); if (state == STATE_PARSING_VALUE_TERMINATOR) { return; } break; case STATE_PARSING_HEADERS_TERMINATOR: parseHeadersTerminator(); if (state == STATE_PARSING_HEADERS_TERMINATOR) { return; } break; case STATE_HEADERS_PARSED: return; } } } private void parseHeadersTerminator() { int b = internalRead(); // move off of the LF if (b == -1) { return; } if (this.mimeHeaders.get(MimeHeaders.CONTENT_TYPE) == null) { this.mimeHeaders.put(MimeHeaders.CONTENT_TYPE, MimeHeaders.DEFAULT_CONTENT_TYPE); } if (mimeHeaders.get(MimeHeaders.CONTENT_TRANSFER_ENCODING) == null) { mimeHeaders.put(MimeHeaders.CONTENT_TRANSFER_ENCODING, MimeHeaders.DEFAULT_CONTENT_TRANSFER_ENCODING); } state = STATE_HEADERS_PARSED; } private void parseName() { int b = internalRead(); if (b == -1) { return; } if (b == CR) { state = STATE_PARSING_HEADERS_TERMINATOR; return; } name.write((byte) b); // find the ':' while (true) { b = internalRead(); if (b == -1) { return; } if (b == COLON) { state = STATE_PARSING_NAME_TERMINATOR; return; } name.write((byte) b); } } private void parseNameTerminator() { int b = internalRead(); // we are pointing to ':' move off of ' ' if (b == -1) { return; } state = STATE_PARSING_VALUE; } private void parseValue() { while (true) { int b = internalRead(); if (b == -1) { return; } if (b == CR) { state = STATE_PARSING_VALUE_TERMINATOR; return; } value.write((byte) b); } } private void parseValueTerminator() { int b = internalRead(); // move off of LF if (b == -1) { return; } try { this.mimeHeaders.put(name.toString("UTF-8"), value.toString("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 not supported"); } name.reset(); value.reset(); state = STATE_PARSING_NAME; } /** * If there are no bytes remaining in the current buffer move to * the next one if it exists. */ private boolean setNextBuffer() { while (pos == curBuf.getLength()) { if (ids.availableSegment() == false) { return false; } curBuf = ids.getNextSegment(); pos = 0; } return true; } /** * Wait until available() != 0 */ private int waitAvailable() { int n; if ((n = available()) > 0) { return n; } synchronized (ids.buffers) { while ((n = available()) == 0) { if (ids.isComplete() == true) { // no more bytes to read() and none are // expected, return -1 return -1; } // no bytes available to read, but more are // expected... block try { ids.buffers.wait(); } catch (InterruptedException e) { Log.logEntry(Log.SEV_ERROR, e); } } return n; } } private static final BufferSegment zeroLength = new BufferSegment(new byte[0]); private int pos = 0; private BufferSegment curBuf = zeroLength; private static final int LF = 10; private static final int CR = 13; private static final int COLON = 58; private static final int STATE_INIT = 0; private static final int STATE_PARSING_NAME = 1; private static final int STATE_PARSING_NAME_TERMINATOR = 2; private static final int STATE_PARSING_VALUE = 3; private static final int STATE_PARSING_VALUE_TERMINATOR = 4; private static final int STATE_PARSING_HEADERS_TERMINATOR = 5; private static final int STATE_HEADERS_PARSED = 6; private int state = STATE_INIT; private ByteArrayOutputStream name = new ByteArrayOutputStream(32); private ByteArrayOutputStream value = new ByteArrayOutputStream(32); private static final int DEFAULT_HEADER_TABLE_SIZE = 2; private Hashtable mimeHeaders = new Hashtable(DEFAULT_HEADER_TABLE_SIZE); private InputDataStream ids; } --- NEW FILE: MimeHeaders.java --- package org.beepcore.beep.core; import java.util.Enumeration; import java.util.Hashtable; import org.beepcore.beep.util.BufferSegment; public class MimeHeaders { /** * The default <code>DataStream</code> content type * ("application/octet-stream"). */ public static final String DEFAULT_CONTENT_TYPE = "application/octet-stream"; /** * The default <code>DataStream</code> content transfer encoding * ("binary"). */ public static final String DEFAULT_CONTENT_TRANSFER_ENCODING = "binary"; /** * <code>DataStream</code> content type ("application/beep+xml"); */ public static final String BEEP_XML_CONTENT_TYPE = "application/beep+xml"; /** * */ public static final String CONTENT_TYPE = "Content-Type"; /** * */ public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; private static final String NAME_VALUE_SEPARATOR = ": "; private static final String HEADER_SUFFIX = "\r\n"; private static final int HEADER_FORMAT_LENGTH = NAME_VALUE_SEPARATOR.length() + HEADER_SUFFIX.length(); // guessing most hashtables will only contain the 2 default values private static final int DEFAULT_HEADER_TABLE_SIZE = 2; private static final int MAX_BUFFER_SIZE = 128; // length of header portion of data stream private int lenHeaders = HEADER_SUFFIX.length(); private Hashtable mimeHeadersTable = new Hashtable(DEFAULT_HEADER_TABLE_SIZE); /** * Creates <code>MimeHeaders</code> using the default content type * <code>DEFAULT_CONTENT_TYPE</code> and default content transfre encoding * <code>DEFAULT_CONTENT_TRANSFER_ENCODING</code>. */ public MimeHeaders() { this(DEFAULT_CONTENT_TYPE, DEFAULT_CONTENT_TRANSFER_ENCODING); } /** * Creates <code>MimeHeaders</code> using the specified content type and * the <code>DEFAULT_CONTENT_TRANSFER_ENCODING</code> content transfer * encoding. */ public MimeHeaders(String contentType) { this(contentType, DEFAULT_CONTENT_TRANSFER_ENCODING); } /** * Creates <code>MimeHeaders</code> using the specified content type and * content transfer encoding. */ public MimeHeaders(String contentType, String transferEncoding) { this.setContentType(contentType); this.setTransferEncoding(transferEncoding); } /** * Returns the value of the MIME entity header <code>Content-Type</code>. */ public String getContentType() { return this.getHeaderValue(CONTENT_TYPE); } /** * Retrieves the correspoding <code>value</code> to a given a MIME entity * header <code>name</code>. * * @param name Name of the MIME entity header. * @return The <code>value</code> of the MIME entity header. * * @throws BEEPException */ public String getHeaderValue(String name) { return (String) this.mimeHeadersTable.get(name); } /** * Returns an <code>Enumeration</code> of all the names of the MIME entity * headers. * Use this call in conjunction with <code>getHeaderValue</code> to iterate * through all the corresponding MIME entity header <code>value</code>(s). * * @return An <code>Enumeration</code> of all the MIME entity header * names. */ public Enumeration getHeaderNames() { return this.mimeHeadersTable.keys(); } /** * Returns the value of the MIME entity header * <code>Content-Transfer-Encoding</code>. */ public String getTransferEncoding() { return this.getHeaderValue(CONTENT_TRANSFER_ENCODING); } /** * Removes the <code>name</code> and <code>value</code> of a MIME entity * header from the data stream. Returns <code>true</code> if the * <code>name</code> was successfully removed. * * @param name Name of the header to be removed from the data stream. * * @return Returns </code>true<code> if header was removed. Otherwise, * returns <code>false</code>. */ public boolean removeHeader(String name) { String value = (String) mimeHeadersTable.get(name); /** * @todo change to not allow the removal of content-type and * transfer-encoding. */ if (value != null) { if (this.mimeHeadersTable.remove(name) != null) { if ((name.equals(CONTENT_TYPE) && value.equals(DEFAULT_CONTENT_TYPE)) || (name.equals(CONTENT_TRANSFER_ENCODING) && value.equals(DEFAULT_CONTENT_TRANSFER_ENCODING))) { // don't decrement the length, these are default values } else { this.lenHeaders -= name.length() + value.length() + this.HEADER_FORMAT_LENGTH; } return true; } } return false; } /** * Sets the content type of a <code>DataStream</code>. * * @param contentType */ public void setContentType(String contentType) { this.setHeader(CONTENT_TYPE, contentType); } /** * Adds a MIME entity header to this data stream. * * @param name Name of the MIME enitity header. * @param value Value of the MIME entity header. */ public void setHeader(String name, String value) { if (this.mimeHeadersTable.containsKey(name)) { removeHeader(name); } this.mimeHeadersTable.put(name, value); if ((name.equals(CONTENT_TYPE) && value.equals(DEFAULT_CONTENT_TYPE)) || (name.equals(CONTENT_TRANSFER_ENCODING) && value.equals(DEFAULT_CONTENT_TRANSFER_ENCODING))) { // these are default values, don't add to len } else { this.lenHeaders += name.length() + value.length() + this.HEADER_FORMAT_LENGTH; } } /** * Sets the content transfer encoding of a <code>DataStream</code> * * @param transferEncoding */ public void setTransferEncoding(String transferEncoding) { this.setHeader(CONTENT_TRANSFER_ENCODING, transferEncoding); } public BufferSegment getBufferSegment() { byte[] headersBytes = new byte[this.lenHeaders]; int offsetHeaders = 0; // read the headers Enumeration headers = mimeHeadersTable.keys(); while (headers.hasMoreElements()) { String name = (String) headers.nextElement(); String value = (String) mimeHeadersTable.get(name); if ((name.equals(CONTENT_TYPE) && value.equals(DEFAULT_CONTENT_TYPE)) || (name.equals(CONTENT_TRANSFER_ENCODING) && value.equals(DEFAULT_CONTENT_TRANSFER_ENCODING))) { // these are default values that don't need to be added // to the payload continue; } // copy name System.arraycopy(name.getBytes(), 0, headersBytes, offsetHeaders, name.length()); offsetHeaders += name.length(); // ": " System.arraycopy(NAME_VALUE_SEPARATOR.getBytes(), 0, headersBytes, offsetHeaders, NAME_VALUE_SEPARATOR.length()); offsetHeaders += NAME_VALUE_SEPARATOR.length(); // copy value System.arraycopy(value.getBytes(), 0, headersBytes, offsetHeaders, value.length()); offsetHeaders += value.length(); // CRLF System.arraycopy(this.HEADER_SUFFIX.getBytes(), 0, headersBytes, offsetHeaders, this.HEADER_SUFFIX.length()); offsetHeaders += this.HEADER_SUFFIX.length(); } // read the CRLF that separates the headers and the data System.arraycopy(this.HEADER_SUFFIX.getBytes(), 0, headersBytes, offsetHeaders, this.HEADER_SUFFIX.length()); offsetHeaders += this.HEADER_SUFFIX.length(); return new BufferSegment(headersBytes); } } --- NEW FILE: OutputDataStream.java --- /* * OutputDataStream.java $Revision: 1.1 $ $Date: 2001/10/31 00:32:37 $ * * Copyright (c) 2001 Huston Franklin. All rights reserved. * * The contents of this file are subject to the Blocks Public License (the * "License"); You may not use this file except in compliance with the License. * * You may obtain a copy of the License at http://www.invisible.net/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * */ package org.beepcore.beep.core; import java.util.LinkedList; import org.beepcore.beep.util.BufferSegment; /** * <code>OutputDataStream</code> represents a BEEP message's payload as a * stream. * * @author Huston Franklin * @version $Revision: 1.1 $, $Date: 2001/10/31 00:32:37 $ */ public class OutputDataStream { /** * Creates an <code>OutputDataStream</code> without any mime * headers. It is the responsibility of the application to ensure * the mime headers exist in the first <code>BufferSegment</code> * added. */ public OutputDataStream() { this.mimeHeaders = null; } /** * Creates an <code>OutputDataStream</code> using the specified * mime headers. * * @param headers Mime headers to be prepended to the buffers in * the stream. */ protected OutputDataStream(MimeHeaders headers) { this.mimeHeaders = headers; } /** * Creates an <code>OutputDataStream</code> using the specified * mime headers. * * @param headers Mime headers to be prepended to the buffers in * the stream. */ protected OutputDataStream(MimeHeaders headers, BufferSegment buf) { this.mimeHeaders = headers; this.add(buf); } public void add(BufferSegment segment) { this.buffers.addLast(segment); } /** * @deprecated */ public void close() { this.setComplete(); } /** * Returns <code>true</code> if no more bytes will be added to * those currently available on this stream. Returns * <code>false</code> if more bytes are expected. */ public boolean isComplete() { return this.complete; } public void setComplete() { this.complete = true; } boolean availableSegment() { return (buffers.isEmpty() == false); } BufferSegment getNextSegment(int maxLength) { if (this.headersSent == false) { if (this.mimeHeaders != null) { this.buffers.addFirst(mimeHeaders.getBufferSegment()); } this.headersSent = true; } BufferSegment b = (BufferSegment)buffers.getFirst(); if (curOffset != 0 || maxLength < b.getLength()) { int origLength = b.getLength(); b = new BufferSegment(b.getData(), b.getOffset() + curOffset, Math.min(maxLength, origLength - curOffset)); if (curOffset + b.getLength() != origLength) { curOffset += b.getLength(); return b; } } buffers.removeFirst(); curOffset = 0; return b; } protected final MimeHeaders mimeHeaders; private LinkedList buffers = new LinkedList(); private boolean complete = false; private boolean headersSent = false; private int curOffset = 0; } Index: ByteDataStream.java =================================================================== RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/ByteDataStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ByteDataStream.java 2001/04/24 22:52:02 1.3 --- ByteDataStream.java 2001/10/31 00:32:37 1.4 *************** *** 1,7 **** - /* * ByteDataStream.java $Revision$ $Date$ * ! * Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved. * * The contents of this file are subject to the Blocks Public License (the --- 1,6 ---- /* * ByteDataStream.java $Revision$ $Date$ * ! * Copyright (c) 2001 Huston Franklin. All rights reserved. * * The contents of this file are subject to the Blocks Public License (the *************** *** 18,26 **** package org.beepcore.beep.core; ! import java.io.ByteArrayInputStream; ! import java.io.InputStream; ! import java.io.IOException; ! import java.io.UnsupportedEncodingException; --- 17,24 ---- package org.beepcore.beep.core; + + import java.util.Enumeration; ! import org.beepcore.beep.util.BufferSegment; *************** *** 36,56 **** * @see org.beepcore.beep.core.DataStream * - * @author Eric Dixon * @author Huston Franklin - * @author Jay Kint - * @author Scott Pead * @version $Revision$, $Date$ */ ! public class ByteDataStream extends InputStreamDataStream { - ByteDataStream(String contentType, String transferEncoding) - { - super( contentType, transferEncoding, null ); - } - /** ! * Creates a <code>ByteDataStream</code> from a <code>byte[]</code> with a ! * content type of <code>DEFAULT_CONTENT_TYPE</code> and a transfer encoding ! * of <code>DEFAULT_CONTENT_TRANSFER_ENCODING</code>. * * @param data A <code>byte[]</code> representing a message's payload. --- 34,47 ---- * @see org.beepcore.beep.core.DataStream * * @author Huston Franklin * @version $Revision$, $Date$ */ ! public class ByteDataStream extends OutputDataStream { /** ! * Creates a <code>ByteDataStream</code> from a ! * <code>byte[]</code> with a content type of ! * <code>DEFAULT_CONTENT_TYPE</code> and a transfer encoding of ! * <code>DEFAULT_CONTENT_TRANSFER_ENCODING</code>. * * @param data A <code>byte[]</code> representing a message's payload. *************** *** 58,62 **** public ByteDataStream(byte[] data) { ! super(new ByteArrayInputStream(data)); } --- 49,53 ---- public ByteDataStream(byte[] data) { ! this(data, 0, data.length); } *************** *** 71,75 **** public ByteDataStream(String contentType, byte[] data) { ! super(contentType, new ByteArrayInputStream(data)); } --- 62,66 ---- public ByteDataStream(String contentType, byte[] data) { ! this(contentType, data, 0, data.length); } *************** *** 86,90 **** byte[] data) { ! super(contentType, transferEncoding, new ByteArrayInputStream(data)); } --- 77,81 ---- byte[] data) { ! this(contentType, transferEncoding, data, 0, data.length); } *************** *** 102,106 **** public ByteDataStream(byte[] data, int offset, int length) { ! super(new ByteArrayInputStream(data, offset, length)); } --- 93,98 ---- public ByteDataStream(byte[] data, int offset, int length) { ! super(new MimeHeaders(), ! new BufferSegment(data, offset, length)); } *************** *** 119,123 **** int length) { ! super(contentType, new ByteArrayInputStream(data, offset, length)); } --- 111,116 ---- int length) { ! super(new MimeHeaders(contentType), ! new BufferSegment(data, offset, length)); } *************** *** 138,166 **** byte[] data, int offset, int length) { ! super(contentType, transferEncoding, ! new ByteArrayInputStream(data, offset, length)); } ! void setData( byte[] data ) { ! this.data = new ByteArrayInputStream(data); } /** ! * Returns this data stream as an <code>InputStream</code> */ ! public InputStream getInputStream() { ! return this.data; } /** ! * Returns <code>true</code> if no more bytes will be added to those ! * currently available, if any, on this stream. Returns ! * <code>false</code> if more bytes are expected. */ ! public boolean isComplete() { ! return true; } } --- 131,237 ---- byte[] data, int offset, int length) { ! super(new MimeHeaders(contentType, transferEncoding), ! new BufferSegment(data, offset, length)); } ! /** ! * Returns <code>true</code> if no more bytes will be added to those ! * currently available, if any, on this stream. Returns ! * <code>false</code> if more bytes are expected. ! */ ! public boolean isComplete() { ! return true; } /** ! * @deprecated */ ! public void setContentType(String contentType) { ! this.mimeHeaders.setContentType(contentType); } /** ! * @deprecated */ ! public String getContentType() throws BEEPException { ! return this.mimeHeaders.getContentType(); ! } ! ! /** ! * @deprecated ! */ ! public void setTransferEncoding(String transferEncoding) ! { ! this.mimeHeaders.setTransferEncoding(transferEncoding); ! } ! ! /** ! * @deprecated ! */ ! public String getTransferEncoding() throws BEEPException ! { ! return this.mimeHeaders.getTransferEncoding(); ! } ! ! /** ! * Adds a MIME entity header to this data stream. ! * ! * @param name Name of the MIME enitity header. ! * @param value Value of the MIME entity header. ! * @deprecated ! */ ! public void setHeader(String name, String value) ! { ! this.mimeHeaders.setHeader(name, value); ! } ! ! /** ! * Retrieves the correspoding <code>value</code> to a given a MIME entity ! * header <code>name</code>. ! * ! * @param name Name of the MIME entity header. ! * @return The <code>value</code> of the MIME entity header. ! * ! * @throws BEEPException ! * @deprecated ! */ ! public String getHeaderValue(String name) throws BEEPException ! { ! return this.mimeHeaders.getHeaderValue(name); ! } ! ! /** ! * Returns an <code>Enumeration</code> of all the names of the MIME entity ! * headers in this data stream. ! * Use this call in conjunction with <code>getHeaderValue</code> to iterate ! * through all the corresponding MIME entity header <code>value</code>(s) ! * in this data stream. ! * ! * @return An <code>Enumeration</code> of all the MIME entity header ! * names. ! * ! * @throws BEEPException ! */ ! public Enumeration getHeaderNames() throws BEEPException ! { ! return this.mimeHeaders.getHeaderNames(); ! } ! ! /** ! * Removes the <code>name</code> and <code>value</code> of a MIME entity ! * header from the data stream. Returns <code>true</code> if the ! * <code>name</code> was successfully removed. ! * ! * @param name Name of the header to be removed from the data stream. ! * ! * @return Returns </code>true<code> if header was removed. Otherwise, ! * returns <code>false</code>. ! */ ! public boolean removeHeader(String name) ! { ! return this.mimeHeaders.removeHeader(name); } } Index: Channel.java =================================================================== RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Channel.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** Channel.java 2001/07/30 12:59:03 1.15 --- Channel.java 2001/10/31 00:32:37 1.16 *************** *** 22,25 **** --- 22,26 ---- import java.util.*; + import org.beepcore.beep.util.BufferSegment; import org.beepcore.beep.util.Log; *************** *** 60,63 **** --- 61,66 ---- "Reply received for a message never sent."; private static final int MAX_PAYLOAD_SIZE = 4096; + private static final BufferSegment zeroLengthSegment = + new BufferSegment(new byte[0]); /** @todo check this */ *************** *** 81,85 **** /** receiver of messages (or partial messages) */ ! private DataListener listener; /** number of last message sent */ --- 84,88 ---- /** receiver of messages (or partial messages) */ ! private MessageListener listener; /** number of last message sent */ *************** *** 98,101 **** --- 101,107 ---- private LinkedList recvMSGQueue; + /** messages queued to be sent */ + private LinkedList pendingSendMessages; + /** size of the frames */ private int frameSize; *************** *** 128,134 **** private int waitTimeForPeer; - /** semaphore for waiting until all ANS have been */ - private int msgsPending; - private boolean notifyOnFirstFrame; --- 134,137 ---- *************** *** 154,158 **** * @see org.beepcore.beep.core.DataListener */ ! protected Channel(String profile, String number, DataListener listener, Session session) { --- 157,161 ---- * @see org.beepcore.beep.core.DataListener */ ! protected Channel(String profile, String number, MessageListener listener, Session session) { *************** *** 167,170 **** --- 170,174 ---- lastMessageSent = 1; + pendingSendMessages = new LinkedList(); sentMSGQueue = Collections.synchronizedList(new LinkedList()); recvMSGQueue = new LinkedList(); *************** *** 175,179 **** prevAckno = 0; prevWindowUsed = 0; - msgsPending = 0; peerWindowSize = DEFAULT_WINDOW_SIZE; waitTimeForPeer = 0; --- 179,182 ---- *************** *** 194,199 **** // Add a MSG to the SentMSGQueue to fake channel into accepting the // greeting which comes in an unsolicited RPY. ! Message m = new Message(this, 0, null, Message.MESSAGE_TYPE_MSG); ! sentMSGQueue.add(new MessageStatus(m, rl)); state = STATE_OK; --- 197,202 ---- // Add a MSG to the SentMSGQueue to fake channel into accepting the // greeting which comes in an unsolicited RPY. ! sentMSGQueue.add(new MessageStatus(this, Message.MESSAGE_TYPE_MSG, 0, ! null, rl)); state = STATE_OK; *************** *** 347,368 **** /** ! * Sets the <code>DataListener</code> for this channel. * * @param ml */ ! public void setDataListener(DataListener ml) { ! ! // @todo can this be called consecutively with different listeners? ! // if so, should it return the old listener? ! // if not, should we prevent it? this.listener = ml; } /** * Returns the message listener for this channel. - * */ ! public DataListener getDataListener() { return this.listener; --- 350,369 ---- /** ! * Sets the <code>MessageListener</code> for this channel. * * @param ml + * @returns The previous MessageListener or null if none was set. */ ! public MessageListener setMessageListener(MessageListener ml) { ! MessageListener tmp = this.listener; this.listener = ml; + return tmp; } /** * Returns the message listener for this channel. */ ! public MessageListener getMessageListener() { return this.listener; *************** *** 379,401 **** /** - * Sends a message of type ANS. - * - * @param stream Data to send in the form of <code>DataStream</code>. - * - * @see DataStream - * @see MessageStatus - * @see #sendNUL - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendANS(DataStream stream) throws BEEPException - { - return this.currentMSG.sendANS(stream); - } - - /** * Sends a message of type MSG. * --- 380,383 ---- *************** *** 411,415 **** * @throws BEEPException if an error is encoutered. */ ! public MessageStatus sendMSG(DataStream stream, ReplyListener replyListener) throws BEEPException --- 393,397 ---- * @throws BEEPException if an error is encoutered. */ ! public MessageStatus sendMSG(OutputDataStream stream, ReplyListener replyListener) throws BEEPException *************** *** 431,438 **** // create a new request ! status = ! new MessageStatus(new Message(this, lastMessageSent, stream, ! Message.MESSAGE_TYPE_MSG), ! replyListener); // message 0 was the greeting, it was already sent, inc the counter --- 413,418 ---- // create a new request ! status = new MessageStatus(this, Message.MESSAGE_TYPE_MSG, ! lastMessageSent, stream, replyListener); // message 0 was the greeting, it was already sent, inc the counter *************** *** 455,622 **** /** - * Sends a message of type MSG. - * - * @param stream Data to send in the form of <code>DataStream</code>. - * @param frameListener A "one-shot" listener that will handle replies - * to this sendMSG listener. - * - * @see DataStream - * @see MessageStatus - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - */ - MessageStatus sendMSG(DataStream stream, - FrameListener frameListener) - throws BEEPException - { - MessageStatus status; - - if (state != STATE_OK) { - switch (state) { - case STATE_ERROR : - throw new BEEPException(ERR_CHANNEL_ERROR_STATE); - case STATE_UNINITIALISED : - throw new BEEPException(ERR_CHANNEL_UNINITIALISED_STATE); - default : - throw new BEEPException(ERR_CHANNEL_UNKNOWN_STATE); - } - } - - synchronized (this) { - - // create a new request - status = - new MessageStatus(new Message(this, lastMessageSent, stream, - Message.MESSAGE_TYPE_MSG), - frameListener); - - // message 0 was the greeting, it was already sent, inc the counter - ++lastMessageSent; - } - - // put this in the list of messages waiting - // may want to put an expiration or something in here so they - // don't just stay around taking up space. - // @todo it's a synchronized list, you don't have to sync - synchronized (sentMSGQueue) { - sentMSGQueue.add(status); - } - - // send it on the session - sendToPeer(status); - - return status; - } - - /** - * Sends a message of type NUL. - * - * @see MessageStatus - * @see #sendANS - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendNUL() throws BEEPException - { - Message m = this.currentMSG; - this.currentMSG = null; - - return m.sendNUL(); - } - - /** - * Sends a message of type RPY. - * - * @param stream Data to send in the form of <code>DataStream</code>. - * - * @see DataStream - * @see MessageStatus - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendRPY(DataStream stream) throws BEEPException - { - Message m = this.currentMSG; - this.currentMSG = null; - - return m.sendRPY(stream); - } - - /** - * Sends a message of type ERR. - * - * @param error Error to send in the form of <code>BEEPError</code>. - * - * @see BEEPError - * @see MessageStatus - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendERR(BEEPError error) throws BEEPException - { - Message m = this.currentMSG; - this.currentMSG = null; - - return m.sendERR(error); - } - - /** - * Sends a message of type ERR. - * - * @param code <code>code</code> attibute in <code>error</code> element. - * @param diagnostic Message for <code>error</code> element. - * - * @see MessageStatus - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendERR(int code, String diagnostic) - throws BEEPException - { - Message m = this.currentMSG; - this.currentMSG = null; - - return m.sendERR(code, diagnostic); - } - - /** - * Sends a message of type ERR. - * - * @param code <code>code</code> attibute in <code>error</code> element. - * @param diagnostic Message for <code>error</code> element. - * @param xmlLang <code>xml:lang</code> attibute in <code>error</code> - * element. - * - * @see MessageStatus - * - * @return MessageStatus - * - * @throws BEEPException if an error is encoutered. - * @deprecated - */ - public MessageStatus sendERR(int code, String diagnostic, String xmlLang) - throws BEEPException - { - Message m = this.currentMSG; - this.currentMSG = null; - - return m.sendERR(code, diagnostic, xmlLang); - } - - /** * get the number of this <code>Channel</code> as a <code>String</code> * --- 435,438 ---- *************** *** 659,663 **** if (m == null) { m = new MessageMSG(this, frame.getMsgno(), ! new FrameDataStream(true)); recvMSGQueue.addLast(m); --- 475,479 ---- if (m == null) { m = new MessageMSG(this, frame.getMsgno(), ! new InputDataStream(this)); recvMSGQueue.addLast(m); *************** *** 665,670 **** } ! ((FrameDataStream) m.getDataStream()).add(frame); // The MessageListener interface only allows one message // up to be processed at a time so if this is not the --- 481,493 ---- } ! Iterator i = frame.getPayload(); ! while (i.hasNext()) { ! m.getDataStream().add((BufferSegment)i.next()); ! } + if (frame.isLast()) { + m.getDataStream().setComplete(); + } + // The MessageListener interface only allows one message // up to be processed at a time so if this is not the *************** *** 718,724 **** mstatus = (MessageStatus) sentMSGQueue.get(0); - sentMSG = mstatus.getMessage(); ! if (sentMSG.getMsgno() != frame.getMsgno()) { // @todo shutdown session (we think) --- 541,546 ---- mstatus = (MessageStatus) sentMSGQueue.get(0); ! if (mstatus.getMsgno() != frame.getMsgno()) { // @todo shutdown session (we think) *************** *** 789,793 **** if (m == null) { m = new Message(this, frame.getMsgno(), frame.getAnsno(), ! new FrameDataStream(true)); if (!frame.isLast()) { --- 611,615 ---- if (m == null) { m = new Message(this, frame.getMsgno(), frame.getAnsno(), ! new InputDataStream(this)); if (!frame.isLast()) { *************** *** 804,808 **** if (recvReplyQueue.size() == 0) { m = new Message(this, frame.getMsgno(), ! new FrameDataStream(true), frame.getMessageType()); --- 626,630 ---- if (recvReplyQueue.size() == 0) { m = new Message(this, frame.getMsgno(), ! new InputDataStream(this), frame.getMessageType()); *************** *** 831,836 **** } ! ((FrameDataStream) m.getDataStream()).add(frame); // notify message listener if this message has not been // notified before and notifyOnFirstFrame is set, the --- 653,665 ---- } ! Iterator i = frame.getPayload(); ! while (i.hasNext()) { ! m.getDataStream().add((BufferSegment)i.next()); ! } + if (frame.isLast()) { + m.getDataStream().setComplete(); + } + // notify message listener if this message has not been // notified before and notifyOnFirstFrame is set, the *************** *** 881,886 **** Message currentMessage = null; int msgno = frame.getMsgno(); - ReplyListener replyListener = null; - FrameListener frameListener = null; if (state != STATE_OK) { --- 710,713 ---- *************** *** 921,925 **** } } else { ! int expectedMsgno; synchronized (sentMSGQueue) { --- 748,752 ---- } } else { ! MessageStatus mstatus; synchronized (sentMSGQueue) { *************** *** 928,941 **** } ! MessageStatus mstatus = ! (MessageStatus) sentMSGQueue.get(0); ! expectedMsgno = mstatus.getMessage().getMsgno(); } ! if (frame.getMsgno() != expectedMsgno) { throw new BEEPException(ERR_CHANNEL_MESSAGE_NUMBER_PREFIX + frame.getMsgno() + ERR_CHANNEL_MIDDLE ! + expectedMsgno); } } --- 755,766 ---- } ! mstatus = (MessageStatus) sentMSGQueue.get(0); } ! if (frame.getMsgno() != mstatus.getMsgno()) { throw new BEEPException(ERR_CHANNEL_MESSAGE_NUMBER_PREFIX + frame.getMsgno() + ERR_CHANNEL_MIDDLE ! + mstatus.getMsgno()); } } *************** *** 970,977 **** } - if (listener instanceof FrameListener) { - frameListener = (FrameListener) this.listener; - } - if (frame.getMessageType() != Message.MESSAGE_TYPE_MSG) { MessageStatus mstatus; --- 795,798 ---- *************** *** 984,1034 **** mstatus = (MessageStatus) sentMSGQueue.get(0); ! if (mstatus.getMessage().getMsgno() != frame.getMsgno()) { throw new BEEPException("Received reply out of order"); } - - FrameListener l = mstatus.getFrameListener(); - - if (l != null) { - frameListener = l; - - // if this is the last frame and on a reply type (NUL, - // RPY, or ERR) - if ((frame.isLast() == true) - && (frame.getMessageType() - != Message.MESSAGE_TYPE_ANS)) { - sentMSGQueue.remove(0); - } - } } } - - if (frameListener != null) { - - // call the frame listener and then subtract that from the used - try { - frameListener.receiveFrame(frame); - - recvWindowUsed -= frame.getSize(); ! if (session.updateMyReceiveBufferSize(this, prevAckno, ! recvSequence, ! prevWindowUsed, ! recvWindowUsed, ! recvWindowSize)) { ! prevAckno = recvSequence; ! prevWindowUsed = recvWindowUsed; ! } ! } catch (BEEPException e) { ! // @todo change this to do the right thing ! throw new BEEPException(e.getMessage()); ! } ! } else { ! try { ! receiveFrame(frame); ! } catch (BEEPException e) { ! // @todo change this to do the right thing ! throw new BEEPException(e.getMessage()); ! } } --- 805,819 ---- mstatus = (MessageStatus) sentMSGQueue.get(0); ! if (mstatus.getMsgno() != frame.getMsgno()) { throw new BEEPException("Received reply out of order"); } } } ! try { ! receiveFrame(frame); ! } catch (BEEPException e) { ! // @todo change this to do the right thing ! throw new BEEPException(e.getMessage()); } *************** *** 1046,1050 **** } ! MessageStatus sendMessage(Message m) throws BEEPException { if (state != STATE_OK) { --- 831,835 ---- } ! void sendMessage(MessageStatus m) throws BEEPException { if (state != STATE_OK) { *************** *** 1059,1077 **** } - // create a new request - MessageStatus status = new MessageStatus(m); - // send it on the session ! sendToPeer(status); ! return status; } synchronized void sendToPeer(MessageStatus status) throws BEEPException { - Message message = status.getMessage(); Frame frame = null; int available = 0; ! DataStream stream; byte[] payload; int sessionBufferSize; --- 844,973 ---- } // send it on the session ! sendToPeer(m); ! } ! void sendToPeer(MessageStatus status) throws BEEPException ! { ! synchronized (pendingSendMessages) { ! pendingSendMessages.add(status); ! } ! sendQueuedMessages(); ! } ! ! private synchronized void sendQueuedMessages() throws BEEPException ! { ! while (true) { ! MessageStatus status; ! ! synchronized (pendingSendMessages) { ! if (pendingSendMessages.isEmpty()) { ! return; ! } ! status = (MessageStatus) pendingSendMessages.removeFirst(); ! } ! ! sendFrames(status); ! ! if (status.getMessageStatus() != ! MessageStatus.MESSAGE_STATUS_SENT) ! { ! synchronized (pendingSendMessages) { ! pendingSendMessages.addFirst(status); ! } ! return; ! } ! } ! } ! ! private void sendFrames(MessageStatus status) ! throws BEEPException ! { ! int sessionBufferSize = session.getMaxFrameSize(); ! OutputDataStream ds = status.getMessageData(); ! ! do { ! synchronized (this) { ! Frame frame; ! // create a frame ! frame = new Frame(status.getMessageType(), ! status.getChannel(), status.getMsgno(), ! false, ! sentSequence, 0, status.getAnsno()); ! ! // make sure the other peer can accept something ! if (peerWindowSize == 0) { ! try { ! wait(); ! } catch (InterruptedException e) { ! throw new RuntimeException("caught InterruptedException"); ! } ! ! // wait until there is something to send up to ! // our timeout ! if (peerWindowSize == 0) { ! throw new BEEPException("Time expired waiting " + ! "for peer."); ! } ! } ! ! int maxToSend = ! Math.min(sessionBufferSize, peerWindowSize); ! ! int size = 0; ! while (size < maxToSend) { ! ... [truncated message content] |
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:40
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/profile/sasl/anonymous
Modified Files:
AnonymousAuthenticator.java
Log Message:
New *DataStream
Index: AnonymousAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous/AnonymousAuthenticator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** AnonymousAuthenticator.java 2001/07/30 13:48:15 1.9
--- AnonymousAuthenticator.java 2001/10/31 00:32:37 1.10
***************
*** 132,136 ****
}
state = STATE_STARTED;
! ch.setDataListener(this);
channel = ch;
}
--- 132,136 ----
}
state = STATE_STARTED;
! ch.setMessageListener(this);
channel = ch;
}
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:40
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/echo
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/profile/echo
Modified Files:
EchoProfile.java
Log Message:
New *DataStream
Index: EchoProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/echo/EchoProfile.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** EchoProfile.java 2001/07/20 23:26:13 1.8
--- EchoProfile.java 2001/10/31 00:32:37 1.9
***************
*** 56,60 ****
{
Log.logEntry(Log.SEV_DEBUG, "EchoCCL StartChannel Callback");
! channel.setDataListener(this);
}
--- 56,60 ----
{
Log.logEntry(Log.SEV_DEBUG, "EchoCCL StartChannel Callback");
! channel.setMessageListener(this);
}
***************
*** 62,66 ****
{
Log.logEntry(Log.SEV_DEBUG, "EchoCCL CloseChannel Callback");
! channel.setDataListener(null);
channel.setAppData(null);
}
--- 62,66 ----
{
Log.logEntry(Log.SEV_DEBUG, "EchoCCL CloseChannel Callback");
! channel.setMessageListener(null);
channel.setAppData(null);
}
***************
*** 84,103 ****
public void run() {
! byte[] buf = new byte[4096];
! ByteArrayOutputStream data = new ByteArrayOutputStream();
! DataStream ds = message.getDataStream();
! InputStream is = ds.getInputStream();
!
! while (true) {
try {
! int n = is.read(buf);
!
! if (n == -1) {
! break;
! }
!
! data.write(buf, 0, n);
! } catch (IOException e) {
message.getChannel().getSession().terminate(e.getMessage());
return;
--- 84,94 ----
public void run() {
! OutputDataStream data = new OutputDataStream();
! InputDataStream ds = message.getDataStream();
! while (ds.isComplete() == false || ds.availableSegment()) {
try {
! data.add(ds.waitForNextSegment());
! } catch (InterruptedException e) {
message.getChannel().getSession().terminate(e.getMessage());
return;
***************
*** 105,110 ****
}
try {
! message.sendRPY(new ByteDataStream(data.toByteArray()));
} catch (BEEPException e) {
try {
--- 96,103 ----
}
+ data.setComplete();
+
try {
! message.sendRPY(data);
} catch (BEEPException e) {
try {
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:40
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib
In directory usw-pr-cvs1:/tmp/cvs-serv24137/src/org/beepcore/beep/lib
Modified Files:
ChannelPool.java NullReplyListener.java Reply.java
SharedChannel.java
Log Message:
New *DataStream
Index: ChannelPool.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/ChannelPool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ChannelPool.java 2001/07/18 21:03:41 1.3
--- ChannelPool.java 2001/10/31 00:32:37 1.4
***************
*** 20,24 ****
import org.beepcore.beep.core.BEEPException;
! import org.beepcore.beep.core.DataListener;
import org.beepcore.beep.core.Session;
--- 20,24 ----
import org.beepcore.beep.core.BEEPException;
! import org.beepcore.beep.core.MessageListener;
import org.beepcore.beep.core.Session;
***************
*** 155,159 ****
* @throws BEEPException
*/
! synchronized public SharedChannel getSharedChannel(String profile, DataListener listener)
throws BEEPException
{
--- 155,159 ----
* @throws BEEPException
*/
! synchronized public SharedChannel getSharedChannel(String profile, MessageListener listener)
throws BEEPException
{
Index: NullReplyListener.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/NullReplyListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** NullReplyListener.java 2001/04/16 20:02:16 1.2
--- NullReplyListener.java 2001/10/31 00:32:37 1.3
***************
*** 46,58 ****
public void receiveRPY(Message message)
{
! ((FrameDataStream)message.getDataStream()).close();
}
public void receiveERR(Message message)
{
! ((FrameDataStream)message.getDataStream()).close();
}
public void receiveANS(Message message)
{
! ((FrameDataStream)message.getDataStream()).close();
}
public void receiveNUL(Message message)
--- 46,58 ----
public void receiveRPY(Message message)
{
! message.getDataStream().close();
}
public void receiveERR(Message message)
{
! message.getDataStream().close();
}
public void receiveANS(Message message)
{
! message.getDataStream().close();
}
public void receiveNUL(Message message)
Index: Reply.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/Reply.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Reply.java 2001/04/26 18:33:14 1.4
--- Reply.java 2001/10/31 00:32:37 1.5
***************
*** 79,87 ****
synchronized public Message getNextReply() throws BEEPInterruptedException
{
- if (this.complete) {
- throw new NoSuchElementException();
- }
-
if (this.replies.size() == 0) {
try {
this.wait();
--- 79,87 ----
synchronized public Message getNextReply() throws BEEPInterruptedException
{
if (this.replies.size() == 0) {
+ if (this.complete) {
+ throw new NoSuchElementException();
+ }
+
try {
this.wait();
Index: SharedChannel.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/lib/SharedChannel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** SharedChannel.java 2001/07/03 20:51:28 1.3
--- SharedChannel.java 2001/10/31 00:32:37 1.4
***************
*** 1,3 ****
-
/*
* SharedChannel.java $Revision$ $Date$
--- 1,2 ----
***************
*** 8,12 ****
* "License"); You may not use this file except in compliance with the License.
*
! * You may obtain a copy of the License at http://www.invisible.net/
*
* Software distributed under the License is distributed on an "AS IS" basis,
--- 7,11 ----
* "License"); You may not use this file except in compliance with the License.
*
! * You may obtain a copy of the License at http://www.beepcore.org/
*
* Software distributed under the License is distributed on an "AS IS" basis,
***************
*** 22,29 ****
import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.Channel;
- import org.beepcore.beep.core.DataListener;
- import org.beepcore.beep.core.DataStream;
import org.beepcore.beep.core.Message;
import org.beepcore.beep.core.MessageStatus;
import org.beepcore.beep.core.ReplyListener;
import org.beepcore.beep.core.Session;
--- 21,28 ----
import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.Channel;
import org.beepcore.beep.core.Message;
+ import org.beepcore.beep.core.MessageListener;
import org.beepcore.beep.core.MessageStatus;
+ import org.beepcore.beep.core.OutputDataStream;
import org.beepcore.beep.core.ReplyListener;
import org.beepcore.beep.core.Session;
***************
*** 65,69 ****
{
super(channel.getProfile(), String.valueOf(channel.getNumber()),
! channel.getDataListener(), channel.getSession());
this.channel = channel;
--- 64,68 ----
{
super(channel.getProfile(), String.valueOf(channel.getNumber()),
! channel.getMessageListener(), channel.getSession());
this.channel = channel;
***************
*** 89,115 ****
/**
- * Send a message of type ANS. Sends <code>stream</code> as message's
- * payload.
- * An ANS type message is one of many to be sent in response and must be
- * terminated with a NUL.
- *
- * @param stream <code>DataStream</code> to send.
- *
- * @see DataStream
- * @see MessageStatus
- * @see #sendNUL
- *
- * @return MessageStutas Can be queried to get status information about the
- * message.
- *
- * @throws BEEPException
- * @deprecated
- */
- public MessageStatus sendANS(DataStream stream) throws BEEPException
- {
- return channel.sendANS(stream);
- }
-
- /**
* Send a message of type MSG. Sends <code>stream</code> as message's
* payload.
--- 88,91 ----
***************
*** 128,132 ****
* @deprecated
*/
! public MessageStatus sendMSG(DataStream stream, ReplyListener replyListener)
throws BEEPException
{
--- 104,109 ----
* @deprecated
*/
! public MessageStatus sendMSG(OutputDataStream stream,
! ReplyListener replyListener)
throws BEEPException
{
***************
*** 135,236 ****
/**
- * Send a NUL message type to terminate a sequence of ANSs.
- * Note: If the stream is not complete, then the send will block
- * until it is finished.
- *
- * @return MessageStutas Can be queried to get status information about the
- * message.
- *
- * @see MessageStatus
- *
- * @throws BEEPException
- * @deprecated
- */
- public MessageStatus sendNUL() throws BEEPException
- {
- return channel.sendNUL();
- }
-
- /**
- * Send a message of type RPY. Sends <code>stream</code> as message's
- * payload.
- * Note: If the stream is not complete, then the send will block
- * until it is finished (a <code>read</code> returns a -1).
- *
- * @param stream <code>DataStream</code> that is read to send data.
- *
- * @return MessageStutas Can be queried to get status information about the
- * message.
- *
- * @see DataStream
- * @see MessageStatus
- *
- * @throws BEEPException
- * @deprecated
- */
- public MessageStatus sendRPY(DataStream stream) throws BEEPException
- {
- return channel.sendRPY(stream);
- }
-
- /**
- * Sends a message of type ERR.
- *
- * @param error Error to send in the form of <code>BEEPError</code>.
- *
- * @see BEEPError
- * @see MessageStatus
- *
- * @return MessageStatus
- *
- * @throws BEEPException if an error is encoutered.
- * @deprecated
- */
- public MessageStatus sendERR(BEEPError error) throws BEEPException
- {
- return channel.sendERR(error);
- }
-
- /**
- * Sends a message of type ERR.
- *
- * @param code <code>code</code> attibute in <code>error</code> element.
- * @param diagnostic Message for <code>error</code> element.
- *
- * @see MessageStatus
- *
- * @return MessageStatus
- *
- * @throws BEEPException if an error is encoutered.
- * @deprecated
- */
- public MessageStatus sendERR(int code, String diagnostic)
- throws BEEPException
- {
- return channel.sendERR(code, diagnostic);
- }
-
- /**
- * Sends a message of type ERR.
- *
- * @param code <code>code</code> attibute in <code>error</code> element.
- * @param diagnostic Message for <code>error</code> element.
- * @param xmlLang <code>xml:lang</code> attibute in <code>error</code>
- * element.
- *
- * @see MessageStatus
- *
- * @return MessageStatus
- *
- * @throws BEEPException if an error is encoutered.
- * @deprecated
- */
- public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
- throws BEEPException
- {
- return channel.sendERR(code, diagnostic, xmlLang);
- }
-
- /**
* Sets the <code>DataListener</code> for this <code>SharedChannel</code>.
*
--- 112,115 ----
***************
*** 239,245 ****
*
*/
! public void setDataListener(DataListener dl)
{
! channel.setDataListener(dl);
}
--- 118,124 ----
*
*/
! public MessageListener setMessageListener(MessageListener dl)
{
! return channel.setMessageListener(dl);
}
***************
*** 259,265 ****
}
! public DataListener getDataListener()
{
! return channel.getDataListener();
}
--- 138,144 ----
}
! public MessageListener getMessageListener()
{
! return channel.getMessageListener();
}
***************
*** 314,318 ****
*
*/
! public Reply sendRequest(DataStream ds) throws BEEPException
{
Reply r = new Reply();
--- 193,197 ----
*
*/
! public Reply sendRequest(OutputDataStream ds) throws BEEPException
{
Reply r = new Reply();
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:32:40
|
Update of /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example
In directory usw-pr-cvs1:/tmp/cvs-serv24137/example/org/beepcore/beep/example
Modified Files:
Bing.java
Log Message:
New *DataStream
Index: Bing.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example/Bing.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Bing.java 2001/07/29 03:57:39 1.3
--- Bing.java 2001/10/31 00:32:37 1.4
***************
*** 22,26 ****
import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.Channel;
! import org.beepcore.beep.core.DataStream;
import org.beepcore.beep.core.ProfileRegistry;
import org.beepcore.beep.core.Session;
--- 22,26 ----
import org.beepcore.beep.core.BEEPException;
import org.beepcore.beep.core.Channel;
! import org.beepcore.beep.core.InputDataStream;
import org.beepcore.beep.core.ProfileRegistry;
import org.beepcore.beep.core.Session;
***************
*** 31,34 ****
--- 31,36 ----
import org.beepcore.beep.transport.tcp.AutomatedTCPSessionCreator;
import org.beepcore.beep.transport.tcp.TCPSession;
+ import org.beepcore.beep.util.ConsoleLog;
+ import org.beepcore.beep.util.Log;
/**
***************
*** 116,120 ****
// Get the reply to the request
! DataStream ds = reply.getNextReply().getDataStream();
InputStream is = ds.getInputStream();
--- 118,122 ----
// Get the reply to the request
! InputDataStream ds = reply.getNextReply().getDataStream();
InputStream is = ds.getInputStream();
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:08:47
|
Update of /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example
In directory usw-pr-cvs1:/tmp/cvs-serv19099
Modified Files:
Beepd.java
Log Message:
Added started message
Index: Beepd.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example/Beepd.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Beepd.java 2001/06/28 15:42:49 1.4
--- Beepd.java 2001/10/31 00:08:45 1.5
***************
*** 207,210 ****
--- 207,212 ----
((Beepd) i.next()).start();
}
+
+ System.out.println("Beepd: started");
}
|
|
From: Huston F. <hu...@us...> - 2001-10-31 00:04:29
|
Update of /cvsroot/beepcore-java/beepcore-java
In directory usw-pr-cvs1:/tmp/cvs-serv18205
Modified Files:
build.xml
Log Message:
changed target names
Index: build.xml
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/build.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** build.xml 2001/07/19 21:42:39 1.13
--- build.xml 2001/10/31 00:04:22 1.14
***************
*** 54,58 ****
<target name="core" depends="init">
<mkdir dir="${core.build.dir}"/>
! <javac srcdir="${core.src.dir}/" destdir="${core.build.dir}" >
<include name="**/core/*.java"/>
<include name="**/lib/*.java"/>
--- 54,58 ----
<target name="core" depends="init">
<mkdir dir="${core.build.dir}"/>
! <javac srcdir="${core.src.dir}/" destdir="${core.build.dir}" >
<include name="**/core/*.java"/>
<include name="**/lib/*.java"/>
***************
*** 121,127 ****
</target>
! <target name="example-compile" depends="core-jar,sasl-jar">
<mkdir dir="${example.build.dir}"/>
! <javac srcdir="${example.src.dir}/" destdir="${example.build.dir}" >
<include name="**/*.java"/>
<exclude name="**/util/Log4JLog.java"/>
--- 121,127 ----
</target>
! <target name="example-compile" depends="core-jar,sasl">
<mkdir dir="${example.build.dir}"/>
! <javac srcdir="${example.src.dir}/" destdir="${example.build.dir}" >
<include name="**/*.java"/>
<exclude name="**/util/Log4JLog.java"/>
***************
*** 154,158 ****
<target name="test" depends="example">
<mkdir dir="${test.build.dir}"/>
! <javac srcdir="${test.src.dir}/" destdir="${test.build.dir}" >
<include name="**/*.java"/>
<classpath>
--- 154,158 ----
<target name="test" depends="example">
<mkdir dir="${test.build.dir}"/>
! <javac srcdir="${test.src.dir}/" destdir="${test.build.dir}" deprecation="on" >
<include name="**/*.java"/>
<classpath>
***************
*** 165,171 ****
</target>
! <target name="sasl" depends="core">
<mkdir dir="${sasl.build.dir}"/>
! <javac srcdir="${sasl.src.dir}/" destdir="${sasl.build.dir}" >
<include name="**/sasl/**/*.java"/>
<classpath>
--- 165,171 ----
</target>
! <target name="sasl-compile" depends="core">
<mkdir dir="${sasl.build.dir}"/>
! <javac srcdir="${sasl.src.dir}/" destdir="${sasl.build.dir}" deprecation="on" >
<include name="**/sasl/**/*.java"/>
<classpath>
***************
*** 176,180 ****
</target>
! <target name="sasl-jar" depends="sasl">
<mkdir dir="${release.dir}/lib"/>
<jar jarfile="${release.dir}/lib/${sasl.jar.name}"
--- 176,180 ----
</target>
! <target name="sasl" depends="sasl-compile">
<mkdir dir="${release.dir}/lib"/>
<jar jarfile="${release.dir}/lib/${sasl.jar.name}"
***************
*** 184,188 ****
</target>
! <target name="sasl-doc" depends="sasl-jar">
<mkdir dir="${sasl.doc.dir}"/>
<javadoc packagenames="${sasl.packages}"
--- 184,188 ----
</target>
! <target name="sasl-doc" depends="sasl">
<mkdir dir="${sasl.doc.dir}"/>
<javadoc packagenames="${sasl.packages}"
|
|
From: Huston F. <hu...@us...> - 2001-08-14 14:41:30
|
Update of /cvsroot/beepcore-java/beepcore-java/tls/org/beepcore/beep/profile/tls/ptls
In directory usw-pr-cvs1:/tmp/cvs-serv6581/org/beepcore/beep/profile/tls/ptls
Modified Files:
TLSProfilePureTLS.java TLSProfilePureTLSPemInit.java
Log Message:
Fix to terminate session if client authentication fails
Index: TLSProfilePureTLS.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/tls/org/beepcore/beep/profile/tls/ptls/TLSProfilePureTLS.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** TLSProfilePureTLS.java 2001/07/12 07:09:10 1.2
--- TLSProfilePureTLS.java 2001/08/14 14:41:27 1.3
***************
*** 1,3 ****
-
/*
* TLSProfilePureTLS.java $Revision$ $Date$
--- 1,2 ----
***************
*** 37,40 ****
--- 36,40 ----
import java.io.FileInputStream;
import java.io.ByteArrayInputStream;
+ import java.io.IOException;
***************
*** 96,99 ****
--- 96,101 ----
// property names
// public static final String PROPERTY_PEER_AUTHENTICATION_REQUIRED = "Peer Authentication Required";
+ public static final String PROPERTY_CLIENT_AUTH_REQUIRED =
+ "Client Authenticaton Required";
public static final String PROPERTY_CIPHER_SUITE = "Cipher Suite";
public static final String PROPERTY_CERTIFICATES = "Certificates";
***************
*** 241,265 ****
policy.negotiateTLS(true); // we don't support SSL v3
! policy.acceptUnverifiableCertificates(false);
! policy.checkCertificateDates(true);
! policy.requireClientAuth(true);
! needPeerAuth = true;
context.setPolicy(policy);
- // set whether or not peer must send a certificate
- // @todo add support for anonymous but encrypted communication
- // if( config.get( PROPERTY_PEER_AUTHENTICATION_REQUIRED ) != null ) {
- // if( !config.get( PROPERTY_PEER_AUTHENTICATION_REQUIRED ).getClass().getName().equals( "Boolean" )) {
- // throw new BEEPException( "Configuration for " +
- // PROPERTY_PEER_AUTHENTICATION_REQUIRED +
- // " must be Boolean." );
- // }
- // needPeerAuth = ((Boolean) config.get( PROPERTY_PEER_AUTHENTICATION_REQUIRED )).booleanValue();
- // policy.requireClientAuth( needPeerAuth );
- // policy.acceptUnverifiableCertificates( true );
- // policy.checkCertificateDates( false );
- // }
// set the cipher suites
if (config.get(PROPERTY_CIPHER_SUITE) != null) {
--- 243,265 ----
policy.negotiateTLS(true); // we don't support SSL v3
!
! // set whether or not peer must send a certificate
! if (config.get(PROPERTY_CLIENT_AUTH_REQUIRED) instanceof String &&
! Boolean.valueOf((String) config.get(PROPERTY_CLIENT_AUTH_REQUIRED )).booleanValue() == false) {
! policy.acceptUnverifiableCertificates(true);
! policy.checkCertificateDates(false);
! policy.requireClientAuth(false);
!
! needPeerAuth = false;
! } else {
! policy.acceptUnverifiableCertificates(false);
! policy.checkCertificateDates(true);
! policy.requireClientAuth(true);
! needPeerAuth = true;
! }
context.setPolicy(policy);
// set the cipher suites
if (config.get(PROPERTY_CIPHER_SUITE) != null) {
***************
*** 359,364 ****
throws StartChannelException
{
! try {
! TCPSession oldSession = (TCPSession) channel.getSession();
// if the data is <ready/> then respond with <proceed/>
--- 359,363 ----
throws StartChannelException
{
! TCPSession oldSession = (TCPSession) channel.getSession();
// if the data is <ready/> then respond with <proceed/>
***************
*** 372,377 ****
}
! // Freeze this Peer
! // Send a profile back with data in the 3rd argument
this.begin(channel, URI, data);
--- 371,380 ----
}
! // Freeze this Peer
! // SSLDebug.setDebug( SSLDebug.DEBUG_ALL );
! SSLSocket newSocket = null;
! SessionCredential peerCred = null;
! try {
! // Send a profile back with dat "<proceed />"
this.begin(channel, URI, data);
***************
*** 379,390 ****
context.setPolicy(policy);
- SessionCredential peerCred = null;
Socket oldSocket = oldSession.getSocket();
! SSLSocket newSocket =
new SSLSocket(context, oldSocket.getInputStream(),
oldSocket.getOutputStream(),
oldSocket.getInetAddress().getHostName(),
oldSocket.getPort(), SSLSocket.SERVER);
// get the credentials of the peer
Vector cc = null;
--- 382,406 ----
context.setPolicy(policy);
Socket oldSocket = oldSession.getSocket();
! newSocket =
new SSLSocket(context, oldSocket.getInputStream(),
oldSocket.getOutputStream(),
oldSocket.getInetAddress().getHostName(),
oldSocket.getPort(), SSLSocket.SERVER);
+ } catch (BEEPException e) {
+ Log.logEntry(Log.SEV_ERROR, e.getMessage());
+ e.printStackTrace();
+ oldSession.terminate(e.getMessage());
+ } catch (SSLThrewAlertException e) {
+ Log.logEntry(Log.SEV_ERROR, e.getMessage());
+ e.printStackTrace();
+ oldSession.terminate(e.getMessage());
+ } catch (IOException e) {
+ Log.logEntry(Log.SEV_ERROR, e.getMessage());
+ e.printStackTrace();
+ oldSession.terminate(e.getMessage());
+ }
+ try {
// get the credentials of the peer
Vector cc = null;
***************
*** 392,395 ****
--- 408,430 ----
if (needPeerAuth) {
cc = newSocket.getCertificateChain();
+ if (cc == null) {
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "No certificate chain when there should " +
+ "be one. ");
+ throw new StartChannelException(550, "No certificate " +
+ "chain when there " +
+ "should be one. ");
+ }
+ Enumeration enum = cc.elements();
+ while (enum.hasMoreElements()) {
+ X509Cert cert = (X509Cert) enum.nextElement();
+ String subject = cert.getSubjectName().getNameString();
+ String issuer = cert.getIssuerName().getNameString();
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "Name = " + subject + " issued by " + issuer);
+ }
+ } else {
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "No peer authentication needed");
}
***************
*** 533,536 ****
--- 568,580 ----
oldSocket.getPort(), SSLSocket.CLIENT);
+ } catch (SSLThrewAlertException e) {
+ session.terminate(e.getMessage());
+ throw new BEEPException(e.getMessage());
+ } catch (IOException e) {
+ session.terminate(e.getMessage());
+ throw new BEEPException(e.getMessage());
+ }
+
+ try {
// get the credentials of the peer
Vector cc = null;
***************
*** 538,541 ****
--- 582,602 ----
if (needPeerAuth) {
cc = newSocket.getCertificateChain();
+ if (cc == null) {
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE, "No certificate " +
+ "chain when there should be one. ");
+ throw new BEEPException("No certificate chain when " +
+ "there should be one. ");
+ }
+ Enumeration enum = cc.elements();
+ while (enum.hasMoreElements()) {
+ X509Cert cert = (X509Cert) enum.nextElement();
+ String subject = cert.getSubjectName().getNameString();
+ String issuer = cert.getIssuerName().getNameString();
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "Name = " + subject + " issued by " + issuer);
+ }
+ } else {
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "No peer authentication needed");
}
***************
*** 702,711 ****
/**
! * allows an initializer class to set the allowed ciphers for the profile.
! * The initializers are profile classes with a custom {@link init} method
! * that takes the array of ciphers as a <code>short []</code> from a given source, such as a
! * file or database and calls this method. The numbers in the array for
! * the ciphers are defined in the <a href="http://www.ietf.org/rfc/rfc2246.txt">TLS spec</a>
! * in Appendix A.
* @param ciphers
*/
--- 763,774 ----
/**
! * allows an initializer class to set the allowed ciphers for the
! * profile. The initializers are profile classes with a custom
! * {@link init} method that takes the array of ciphers as a
! * <code>short []</code> from a given source, such as a file or
! * database and calls this method. The numbers in the array for
! * the ciphers are defined in the
! * <a href="http://www.ietf.org/rfc/rfc2246.txt">TLS spec</a> in
! * Appendix A.
* @param ciphers
*/
***************
*** 726,743 ****
}
}
! // /**
! // * sets whether or not the the peer we're talking to must be authenticated
! // * @param needAuth
! // */
! // void setNeedPeerAuthentication( boolean needAuth ) {
! // needPeerAuth = needAuth;
! // policy.requireClientAuth( needPeerAuth );
! // }
! // SSLPolicyInt getPolicy() {
! // return policy;
! // }
! // SSLContext getContext() {
! // return context;
! // }
}
--- 789,812 ----
}
}
+
+ /**
+ * sets whether or not the the peer we're talking to must be authenticated
+ * @param needAuth
+ */
+ void setNeedPeerAuthentication( boolean needAuth ) {
+
+ if (needAuth == false) {
+ policy.acceptUnverifiableCertificates(true);
+ policy.checkCertificateDates(false);
+ policy.requireClientAuth(false);
! needPeerAuth = false;
! } else {
! policy.acceptUnverifiableCertificates(false);
! policy.checkCertificateDates(true);
! policy.requireClientAuth(true);
!
! needPeerAuth = true;
! }
! }
}
Index: TLSProfilePureTLSPemInit.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/tls/org/beepcore/beep/profile/tls/ptls/TLSProfilePureTLSPemInit.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** TLSProfilePureTLSPemInit.java 2001/07/09 05:57:05 1.1
--- TLSProfilePureTLSPemInit.java 2001/08/14 14:41:27 1.2
***************
*** 1,3 ****
-
/*
* TLSProfilePureTLSPemInit.java $Revision$ $Date$
--- 1,2 ----
***************
*** 55,58 ****
--- 54,59 ----
* @see #init
*/
+ public static final String PROPERTY_CLIENT_AUTH_REQUIRED =
+ "Client Authenticaton Required";
public static final String PROPERTY_CIPHER_SUITE = "Cipher Suite";
public static final String PROPERTY_CERTIFICATES = "Certificates";
***************
*** 114,125 ****
// set whether or not peer must send a certificate
! // if( config.get( PROPERTY_PEER_AUTHENTICATION_REQUIRED ) != null ) {
! // if( new Boolean( (String) config.get( PROPERTY_PEER_AUTHENTICATION_REQUIRED )).booleanValue() == true ) {
! // tlsp.setNeedPeerAuthentication( true );
! // }
! // else {
! // tlsp.setNeedPeerAuthentication( false );
! // }
! // }
// set the cipher suites
if (config.get(PROPERTY_CIPHER_SUITE) != null) {
--- 115,125 ----
// set whether or not peer must send a certificate
! if (config.get(PROPERTY_CLIENT_AUTH_REQUIRED) != null) {
! if (new Boolean((String) config.get(PROPERTY_CLIENT_AUTH_REQUIRED)).booleanValue() == true) {
! tlsp.setNeedPeerAuthentication(true);
! } else {
! tlsp.setNeedPeerAuthentication(false);
! }
! }
// set the cipher suites
if (config.get(PROPERTY_CIPHER_SUITE) != null) {
***************
*** 183,186 ****
--- 183,210 ----
// (client)
try {
+ // set the certificate(s) by which we are known. We can
+ // actually verify clients with several root certificates,
+ // but this is the certificates that we present according
+ // to the negotiated cipher suite. We assume that the
+ // peer has a root that is in common with us.
+ String certFile = (String) config.get(PROPERTY_CERTIFICATES);
+ BufferedReader certbr =
+ new BufferedReader(new FileReader(certFile));
+ StringBuffer certType = new StringBuffer();
+ Vector certs = new Vector();
+
+ while (true) {
+ byte[] cert = WrappedObject.loadObject(certbr, "CERTIFICATE",
+ certType);
+
+ if (cert == null) {
+ break;
+ }
+
+ certs.add(cert);
+ }
+
+ tlsp.setCertChain(certs);
+
String keyFile = (String) config.get(PROPERTY_PRIVATE_KEY);
BufferedReader keybr =
***************
*** 208,235 ****
tlsp.setPrivateKey(key);
-
- // set the certificate(s) by which we are known. We can
- // actually verify clients with several root certificates, but
- // this is the certificates that we present according to the negotiated
- // cipher suite. We assume that the peer has a root that is in common
- // with us.
- String certFile = (String) config.get(PROPERTY_CERTIFICATES);
- BufferedReader certbr =
- new BufferedReader(new FileReader(certFile));
- StringBuffer certType = new StringBuffer();
- Vector certs = new Vector();
-
- while (true) {
- byte[] cert = WrappedObject.loadObject(certbr, "CERTIFICATE",
- certType);
-
- if (cert == null) {
- break;
- }
-
- certs.add(cert);
- }
-
- tlsp.setCertChain(certs);
// verify that the object passed in is either a list or a String
--- 232,235 ----
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:48:18
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp
In directory usw-pr-cvs1:/tmp/cvs-serv16685/otp
Modified Files:
OTPAuthenticator.java
Log Message:
Changed to only log blob contents on ABORT
Index: OTPAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/OTPAuthenticator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** OTPAuthenticator.java 2001/07/30 13:07:11 1.7
--- OTPAuthenticator.java 2001/07/30 13:48:15 1.8
***************
*** 810,822 ****
}
- if (blob.getData() != null) {
- Log.logEntry(Log.SEV_DEBUG, OTP_AUTH,
- "OTPAuthenticator receiveRPY got an RPY=>"
- + blob.getData());
- }
String status = blob.getStatus();
if ((status != null)
&& status.equals(SASLProfile.SASL_STATUS_ABORT)) {
sendAbort = false;
abort(ERR_PEER_ABORTED + blob.getData());
--- 810,820 ----
}
String status = blob.getStatus();
if ((status != null)
&& status.equals(SASLProfile.SASL_STATUS_ABORT)) {
+ Log.logEntry(Log.SEV_DEBUG, OTP_AUTH,
+ "OTPAuthenticator receiveRPY got an RPY=>"
+ + blob.getData());
sendAbort = false;
abort(ERR_PEER_ABORTED + blob.getData());
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:48:18
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous
In directory usw-pr-cvs1:/tmp/cvs-serv16685/anonymous
Modified Files:
AnonymousAuthenticator.java
Log Message:
Changed to only log blob contents on ABORT
Index: AnonymousAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous/AnonymousAuthenticator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** AnonymousAuthenticator.java 2001/07/30 13:07:11 1.8
--- AnonymousAuthenticator.java 2001/07/30 13:48:15 1.9
***************
*** 375,387 ****
}
- if (blob.getData() != null) {
- Log.logEntry(Log.SEV_DEBUG,
- "Anonymous Authenticator receiveRPY=>"
- + blob.getData());
- }
String status = blob.getStatus();
if ((status != null)
&& status.equals(SASLProfile.SASL_STATUS_ABORT)) {
sendAbort = false;
abort(ERR_PEER_ABORTED);
--- 375,385 ----
}
String status = blob.getStatus();
if ((status != null)
&& status.equals(SASLProfile.SASL_STATUS_ABORT)) {
+ Log.logEntry(Log.SEV_DEBUG,
+ "Anonymous Authenticator receiveRPY=>"
+ + blob.getData());
sendAbort = false;
abort(ERR_PEER_ABORTED);
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:10:50
|
Update of /cvsroot/beepcore-java/beepcore-java/tls/org/beepcore/beep/profile/tls/jsse
In directory usw-pr-cvs1:/tmp/cvs-serv9285/jsse
Modified Files:
TLSProfileJSSE.java
Log Message:
Chaned printStackTrace to logEntry
Index: TLSProfileJSSE.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/tls/org/beepcore/beep/profile/tls/jsse/TLSProfileJSSE.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** TLSProfileJSSE.java 2001/07/12 07:09:10 1.2
--- TLSProfileJSSE.java 2001/07/30 13:10:47 1.3
***************
*** 634,644 ****
}
}
} catch (java.io.IOException e) {
! e.printStackTrace();
!
throw new BEEPException(ERR_TLS_SOCKET);
} catch (InterruptedException e) {
! e.printStackTrace();
!
throw new BEEPException(ERR_TLS_HANDSHAKE_WAIT);
}
--- 634,645 ----
}
}
+ } catch (javax.net.ssl.SSLException e) {
+ Log.logEntry(Log.SEV_ERROR, e);
+ throw new BEEPException(e.getMessage());
} catch (java.io.IOException e) {
! Log.logEntry(Log.SEV_ERROR, e);
throw new BEEPException(ERR_TLS_SOCKET);
} catch (InterruptedException e) {
! Log.logEntry(Log.SEV_ERROR, e);
throw new BEEPException(ERR_TLS_HANDSHAKE_WAIT);
}
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:09:03
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp
In directory usw-pr-cvs1:/tmp/cvs-serv8875
Modified Files:
TCPSession.java
Log Message:
Cleanup erroneous message on session close
Index: TCPSession.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp/TCPSession.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** TCPSession.java 2001/07/29 03:52:57 1.11
--- TCPSession.java 2001/07/30 13:09:00 1.12
***************
*** 405,415 ****
while (true) {
! int b = is.read();
! if (b == -1) {
! throw new SessionAbortedException();
! }
! headerBuffer[length] = (byte) b;
if (headerBuffer[length] == '\n') {
--- 405,425 ----
while (true) {
! try {
! int b = is.read();
! if (b == -1) {
! throw new SessionAbortedException();
! }
!
! headerBuffer[length] = (byte) b;
! } catch (java.net.SocketException e) {
! if (getState() == SESSION_STATE_ACTIVE) {
! throw e;
! }
!
! // socket closed intentionally (session closing) so just return
! return;
! }
if (headerBuffer[length] == '\n') {
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:07:17
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp
In directory usw-pr-cvs1:/tmp/cvs-serv8402/otp
Modified Files:
OTPAuthenticator.java
Log Message:
Changed to use new sendXXX methods on Message instead of the methods on Channel
Index: OTPAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/otp/OTPAuthenticator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** OTPAuthenticator.java 2001/05/23 16:39:36 1.6
--- OTPAuthenticator.java 2001/07/30 13:07:11 1.7
***************
*** 519,523 ****
try {
channel.sendMSG(new StringDataStream(blob.toString()), (ReplyListener) this);
! } catch (Exception x) {
abort(x.getMessage());
}
--- 519,523 ----
try {
channel.sendMSG(new StringDataStream(blob.toString()), (ReplyListener) this);
! } catch (BEEPException x) {
abort(x.getMessage());
}
***************
*** 609,613 ****
{
blob = new Blob(Blob.STATUS_CONTINUE, phrase);
! profile.sendMessage(blob, channel);
}
catch(BEEPException x)
--- 609,613 ----
{
blob = new Blob(Blob.STATUS_CONTINUE, phrase);
! channel.sendMSG(new StringDataStream(blob.toString()), this);
}
catch(BEEPException x)
***************
*** 714,719 ****
if (state == STATE_STARTED) {
! profile.sendReply(receiveIDs(data),
! channel);
return;
}
--- 714,723 ----
if (state == STATE_STARTED) {
! Blob reply = receiveIDs(data);
! try {
! message.sendRPY(new StringDataStream(reply.toString()));
! } catch (BEEPException x) {
! throw new SASLException(x.getMessage());
! }
return;
}
***************
*** 733,737 ****
try
{
! channel.sendRPY(new StringDataStream(new Blob(Blob.STATUS_COMPLETE).toString()));
channel.setDataListener(null);
}
--- 737,741 ----
try
{
! message.sendRPY(new StringDataStream(new Blob(Blob.STATUS_COMPLETE).toString()));
channel.setDataListener(null);
}
***************
*** 754,759 ****
profile.failListenerAuthentication(channel.getSession(),
authenticated);
! channel.sendRPY(new StringDataStream(new Blob(Blob.STATUS_ABORT,
! s.getMessage()).toString()));
// channel.setDataListener(null);
}
--- 758,763 ----
profile.failListenerAuthentication(channel.getSession(),
authenticated);
! Blob reply = new Blob(Blob.STATUS_ABORT, s.getMessage());
! message.sendRPY(new StringDataStream(reply.toString()));
// channel.setDataListener(null);
}
***************
*** 857,865 ****
try
{
! profile.sendMessage(new Blob(Blob.STATUS_ABORT,
! x.getMessage()),
! channel);
}
! catch(SASLException y)
{
message.getChannel().getSession().terminate(y.getMessage());
--- 861,869 ----
try
{
! Blob a = new Blob(Blob.STATUS_ABORT, x.getMessage());
! channel.sendMSG(new StringDataStream(a.toString()),
! this);
}
! catch(BEEPException y)
{
message.getChannel().getSession().terminate(y.getMessage());
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:07:17
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl
In directory usw-pr-cvs1:/tmp/cvs-serv8402
Modified Files:
SASLProfile.java
Log Message:
Changed to use new sendXXX methods on Message instead of the methods on Channel
Index: SASLProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/SASLProfile.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SASLProfile.java 2001/07/03 20:51:28 1.4
--- SASLProfile.java 2001/07/30 13:07:11 1.5
***************
*** 72,126 ****
/**
- * Method sendReply This is usually used for sending challenges
- * in response to authentication requests...or in response
- * to authentication attempts. It was simpler to do it here once
- * and wrap the exceptions as SASLExceptions than it was to replicate
- * this code all over the SASL portion of the library.
- *
- * @param blob the data to send
- * @param Channel the channel to send the data on
- *
- * @throws SASLException if an issue is encountered during the send.
- */
- public void sendReply(Blob blob, Channel channel)
- throws SASLException
- {
- try {
- channel.sendRPY(new StringDataStream(blob.toString()));
- } catch (Exception x) {
- throw new SASLException(x.getMessage());
- }
- }
-
- /**
- * This routine is typically used for ...
- * either at the beginning of the authentication
- * "I would like to authenticate as <blank>"
- * "I got your challenge. Here is the info to authenticate me"
- */
- /**
- * Method sendMessage This is usually used for sending
- * messages in response to challenges from SASL mechanisms
- * It was simpler to do it here once
- * and wrap the exceptions as SASLExceptions than it was to replicate
- * this code all over the SASL portion of the library.
- *
- * @param blob the data to send
- * @param Channel the channel to send the data on
- *
- * @throws SASLException if an issue is encountered during the send.
- */
- public void sendMessage(Blob blob, Channel channel)
- throws SASLException
- {
- try {
- channel.sendMSG(new StringDataStream(blob.toString()),
- (ReplyListener) channel.getDataListener());
- } catch (Exception x) {
- throw new SASLException(x.getMessage());
- }
- }
-
- /**
* Method clearCredential simply clears the credentials associated
* with a given Session - this is typically done before a new
--- 72,75 ----
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:07:17
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous
In directory usw-pr-cvs1:/tmp/cvs-serv8402/anonymous
Modified Files:
AnonymousAuthenticator.java
Log Message:
Changed to use new sendXXX methods on Message instead of the methods on Channel
Index: AnonymousAuthenticator.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/anonymous/AnonymousAuthenticator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** AnonymousAuthenticator.java 2001/07/03 20:50:26 1.7
--- AnonymousAuthenticator.java 2001/07/30 13:07:11 1.8
***************
*** 211,215 ****
try {
credential.put(SessionCredential.AUTHENTICATOR, authenticateId);
! profile.sendMessage(blob, channel);
} catch (Exception x) {
abort(x.getMessage());
--- 211,215 ----
try {
credential.put(SessionCredential.AUTHENTICATOR, authenticateId);
! channel.sendMSG(new StringDataStream(blob.toString()), this);
} catch (Exception x) {
abort(x.getMessage());
***************
*** 314,324 ****
if (state == STATE_STARTED) {
try {
! profile.sendReply(receiveID(data), channel);
! } catch (Exception szf) {
! abort(szf.getMessage());
// @todo weird and iffy, cuz we may have sent...
// Unsolicited message is probably better than
// a waiting peer, so let's abort and blow it up...
- // return;
}
profile.finishListenerAuthentication(new SessionCredential(credential),
--- 314,324 ----
if (state == STATE_STARTED) {
try {
! Blob reply = receiveID(data);
! message.sendRPY(new StringDataStream(reply.toString()));
! } catch (BEEPException x) {
! abort(x.getMessage());
// @todo weird and iffy, cuz we may have sent...
// Unsolicited message is probably better than
// a waiting peer, so let's abort and blow it up...
}
profile.finishListenerAuthentication(new SessionCredential(credential),
***************
*** 330,337 ****
try
{
! profile.sendReply(new Blob(Blob.STATUS_ABORT, s.getMessage()),
! channel);
}
! catch(Exception t)
{
message.getChannel().getSession().terminate(t.getMessage());
--- 330,337 ----
try
{
! Blob reply = new Blob(Blob.STATUS_ABORT, s.getMessage());
! message.sendRPY(new StringDataStream(reply.toString()));
}
! catch(BEEPException t)
{
message.getChannel().getSession().terminate(t.getMessage());
***************
*** 413,422 ****
this.notify();
}
! try
! {
! if(sendAbort)
! profile.sendMessage(new Blob(Blob.STATUS_ABORT,
! x.getMessage()),
! channel);
}
catch(Exception q)
--- 413,422 ----
this.notify();
}
! try {
! if(sendAbort) {
! Blob reply = new Blob(Blob.STATUS_ABORT, x.getMessage());
! channel.sendMSG(new StringDataStream(blob.toString()),
! this);
! }
}
catch(Exception q)
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:04:37
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl
In directory usw-pr-cvs1:/tmp/cvs-serv7785
Modified Files:
Blob.java
Log Message:
Fixed null pointer exception for empty Blobs
Index: Blob.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/profile/sasl/Blob.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Blob.java 2001/05/23 16:38:37 1.2
--- Blob.java 2001/07/30 13:04:35 1.3
***************
*** 317,322 ****
}
}
! if(statusMappings == null)
! {
statusMappings = new String[STATUS_LIMIT];
statusMappings[STATUS_NONE] = NONE;
--- 317,321 ----
}
}
! if(statusMappings == null) {
statusMappings = new String[STATUS_LIMIT];
statusMappings[STATUS_NONE] = NONE;
***************
*** 329,336 ****
/**
! * Method getStatus
! *
! * @return String the status used in the blob - can be 'none'.
! *
*/
public String getStatus()
--- 328,332 ----
/**
! * Returns the status used in the blob - can be 'none'.
*/
public String getStatus()
***************
*** 340,358 ****
/**
! * Method getData
! *
! * @return String the data contained in the blob element
! *
*/
public String getData()
{
! return new String( decodedData );
}
/**
! * Method getData
! *
! * @return String the data contained in the blob element
! *
*/
public byte[] getDataBytes()
--- 336,351 ----
/**
! * Returns the blob data as a <code>String</code>.
*/
public String getData()
{
! if (decodedData == null) {
! return "";
! }
! return new String(decodedData);
}
/**
! * Returns the blob data as bytes.
*/
public byte[] getDataBytes()
***************
*** 362,368 ****
/**
! * Method toString
! *
! * @return String a representation of the Blob as it would be sent
* out on the wire (with the data encoded).
*
--- 355,359 ----
/**
! * Returns a representation of the Blob as it would be sent
* out on the wire (with the data encoded).
*
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:01:35
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv7180
Modified Files:
Session.java
Log Message:
fixed log message
Index: Session.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Session.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** Session.java 2001/07/03 20:51:28 1.14
--- Session.java 2001/07/30 13:01:33 1.15
***************
*** 1173,1177 ****
if (TuningProfile.isTuningProfile(channel.getProfile())) {
! Log.logEntry(Log.SEV_DEBUG, CORE, "\nDisabling this I/O thread");
disableIO();
}
--- 1173,1177 ----
if (TuningProfile.isTuningProfile(channel.getProfile())) {
! Log.logEntry(Log.SEV_DEBUG, CORE, "Disabling this I/O thread");
disableIO();
}
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:00:55
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv7004
Modified Files:
SessionTuningProperties.java
Log Message:
Fixed bug for empty tuning properties
Index: SessionTuningProperties.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/SessionTuningProperties.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** SessionTuningProperties.java 2001/07/27 06:17:40 1.2
--- SessionTuningProperties.java 2001/07/30 13:00:53 1.3
***************
*** 140,142 ****
--- 140,146 ----
return b.toString();
}
+
+ boolean isEmpty() {
+ return properties.isEmpty();
+ }
}
|
|
From: Huston F. <hu...@us...> - 2001-07-30 13:00:10
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv6839
Modified Files:
ProfileRegistry.java
Log Message:
Fixed bug for empty tuning properties
Index: ProfileRegistry.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/ProfileRegistry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ProfileRegistry.java 2001/07/27 06:17:40 1.5
--- ProfileRegistry.java 2001/07/30 13:00:07 1.6
***************
*** 20,23 ****
--- 20,24 ----
import java.util.Enumeration;
import java.util.Hashtable;
+ import org.beepcore.beep.util.Log;
***************
*** 127,131 ****
// if there are no qualifications, then just return the listener
! if (profile.tuning == null) {
return ((InternalProfile) profileListeners.get(uri)).listener;
}
--- 128,132 ----
// if there are no qualifications, then just return the listener
! if (profile.tuning == null || profile.tuning.isEmpty()) {
return ((InternalProfile) profileListeners.get(uri)).listener;
}
***************
*** 134,137 ****
--- 135,140 ----
// have anything, then return null
if (tuning == null) {
+ Log.logEntry(Log.SEV_DEBUG,
+ "Session does not have any tuning properties");
return null;
}
***************
*** 148,151 ****
--- 151,157 ----
== null))
{
+ Log.logEntry(Log.SEV_DEBUG,
+ "Session does not have tuning property " +
+ SessionTuningProperties.STANDARD_PROPERTIES[i]);
return null;
}
***************
*** 187,193 ****
tempProfile.listener = listener;
- if (tuning == null) {
- tuning = SessionTuningProperties.emptyTuningProperties;
- }
tempProfile.tuning = tuning;
--- 193,196 ----
|
|
From: Huston F. <hu...@us...> - 2001-07-30 12:59:06
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv6546
Modified Files:
Channel.java
Log Message:
Fixed null pointer exception in old sendXXX methods
Index: Channel.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Channel.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** Channel.java 2001/07/10 01:17:52 1.14
--- Channel.java 2001/07/30 12:59:03 1.15
***************
*** 135,138 ****
--- 135,141 ----
private Object applicationData = null;
+ /* this is to support deprecated sendXXX methods */
+ private MessageMSG currentMSG;
+
// in shutting down the session
// something for waiting synchronous messages (semaphores or something)
***************
*** 391,397 ****
public MessageStatus sendANS(DataStream stream) throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
!
! return m.sendANS(stream);
}
--- 394,398 ----
public MessageStatus sendANS(DataStream stream) throws BEEPException
{
! return this.currentMSG.sendANS(stream);
}
***************
*** 523,527 ****
public MessageStatus sendNUL() throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
return m.sendNUL();
--- 524,529 ----
public MessageStatus sendNUL() throws BEEPException
{
! Message m = this.currentMSG;
! this.currentMSG = null;
return m.sendNUL();
***************
*** 543,547 ****
public MessageStatus sendRPY(DataStream stream) throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
return m.sendRPY(stream);
--- 545,550 ----
public MessageStatus sendRPY(DataStream stream) throws BEEPException
{
! Message m = this.currentMSG;
! this.currentMSG = null;
return m.sendRPY(stream);
***************
*** 563,567 ****
public MessageStatus sendERR(BEEPError error) throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
return m.sendERR(error);
--- 566,571 ----
public MessageStatus sendERR(BEEPError error) throws BEEPException
{
! Message m = this.currentMSG;
! this.currentMSG = null;
return m.sendERR(error);
***************
*** 584,588 ****
throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
return m.sendERR(code, diagnostic);
--- 588,593 ----
throws BEEPException
{
! Message m = this.currentMSG;
! this.currentMSG = null;
return m.sendERR(code, diagnostic);
***************
*** 607,611 ****
throws BEEPException
{
! Message m = (Message)this.recvMSGQueue.get(0);
return m.sendERR(code, diagnostic, xmlLang);
--- 612,617 ----
throws BEEPException
{
! Message m = this.currentMSG;
! this.currentMSG = null;
return m.sendERR(code, diagnostic, xmlLang);
***************
*** 691,694 ****
--- 697,701 ----
}
+ this.currentMSG = m;
((MessageListener) this.listener).receiveMSG(m);
***************
*** 750,753 ****
--- 757,764 ----
mstatus.setMessageStatus(MessageStatus.MESSAGE_STATUS_RECEIVED_REPLY);
+ Log.logEntry(Log.SEV_DEBUG_VERBOSE,
+ "Notifying reply listener =>" + replyListener +
+ "for NUL message");
+
replyListener.receiveNUL(m);
|
|
From: Huston F. <hu...@us...> - 2001-07-29 03:57:41
|
Update of /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example
In directory usw-pr-cvs1:/tmp/cvs-serv32415/example/org/beepcore/beep/example
Modified Files:
Bing.java
Log Message:
Added session close on errors
Index: Bing.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/example/org/beepcore/beep/example/Bing.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Bing.java 2001/07/11 02:46:19 1.2
--- Bing.java 2001/07/29 03:57:39 1.3
***************
*** 69,160 ****
}
! // Start TLS if requested
! if (privacy != PRIVACY_NONE) {
! try {
! session =
! TLSProfile.getDefaultInstance().startTLS((TCPSession) session);
! } catch (BEEPException e) {
! System.err.println("bing: Error unable to start TLS.\n\t" +
! e.getMessage());
! if (privacy == PRIVACY_REQUIRED)
! return;
}
- }
! // Start a channel for the echo profile
! Channel channel;
! try {
! channel = session.startChannel(EchoProfile.ECHO_URI);
! } catch (BEEPError e) {
! if (e.getCode() == 550) {
! System.err.println("bing: Error host does not support echo " +
! "profile");
! } else {
System.err.println("bing: Error starting channel (" +
! e.getCode() + ": " + e.getMessage() + ")");
}
- return;
- } catch (BEEPException e) {
- System.err.println("bing: Error starting channel (" +
- e.getMessage() + ")");
- return;
- }
! String request = createRequest(size);
! try {
! for (int i=0; i<count; ++i) {
! long time;
! int replyLength = 0;
! Reply reply = new Reply();
!
! time = System.currentTimeMillis();
!
! // Send the request
! channel.sendMSG(new StringDataStream(request), reply);
!
! // Get the reply to the request
! DataStream ds = reply.getNextReply().getDataStream();
! InputStream is = ds.getInputStream();
!
! // Read the data in the reply
! while (ds.isComplete() == false || is.available() > 0) {
! is.read();
! ++replyLength;
}
!
! System.out.println("Reply from " + host + ": bytes=" +
! replyLength + " time=" +
! (System.currentTimeMillis() - time) +
! "ms");
}
- } catch (BEEPError e) {
- System.err.println("bing: Error sending request (" + e.getCode() +
- ": " + e.getMessage() + ")");
- return;
- } catch (Exception e) {
- System.err.println("bing: Error sending request (" +
- e.getMessage() + ")");
- return;
- }
! // Cleanup
! // Close the Channel
! try {
! channel.close();
! } catch (BEEPException e) {
! System.err.println("bing: Error closing channel (" +
! e.getMessage() + ")");
! return;
! }
! // Close the Session
! try {
! session.close();
! } catch (BEEPException e) {
! System.err.print("bing: Error closing session (" +
! e.getMessage() + ")");
! return;
}
}
--- 69,163 ----
}
! try {
! // Start TLS if requested
! if (privacy != PRIVACY_NONE) {
! try {
! session =
! TLSProfile.getDefaultInstance().startTLS((TCPSession) session);
! } catch (BEEPException e) {
! System.err.println("bing: Error unable to start TLS.\n\t" +
! e.getMessage());
! if (privacy == PRIVACY_REQUIRED)
! return;
! }
}
! // Start a channel for the echo profile
! Channel channel;
! try {
! channel = session.startChannel(EchoProfile.ECHO_URI);
! } catch (BEEPError e) {
! if (e.getCode() == 550) {
! System.err.println("bing: Error host does not support echo " +
! "profile");
! } else {
! System.err.println("bing: Error starting channel (" +
! e.getCode() + ": " + e.getMessage() + ")");
! }
! return;
! } catch (BEEPException e) {
System.err.println("bing: Error starting channel (" +
! e.getMessage() + ")");
! return;
}
! String request = createRequest(size);
! try {
! for (int i=0; i<count; ++i) {
! long time;
! int replyLength = 0;
! Reply reply = new Reply();
!
! time = System.currentTimeMillis();
!
! // Send the request
! channel.sendMSG(new StringDataStream(request), reply);
!
! // Get the reply to the request
! DataStream ds = reply.getNextReply().getDataStream();
! InputStream is = ds.getInputStream();
!
! // Read the data in the reply
! while (ds.isComplete() == false || is.available() > 0) {
! is.read();
! ++replyLength;
! }
!
! System.out.println("Reply from " + host + ": bytes=" +
! replyLength + " time=" +
! (System.currentTimeMillis() - time) +
! "ms");
}
! } catch (BEEPError e) {
! System.err.println("bing: Error sending request (" + e.getCode() +
! ": " + e.getMessage() + ")");
! return;
! } catch (Exception e) {
! System.err.println("bing: Error sending request (" +
! e.getMessage() + ")");
! return;
}
! // Cleanup
! // Close the Channel
! try {
! channel.close();
! } catch (BEEPException e) {
! System.err.println("bing: Error closing channel (" +
! e.getMessage() + ")");
! return;
! }
! } finally {
! // Close the Session
! try {
! session.close();
! } catch (BEEPException e) {
! System.err.print("bing: Error closing session (" +
! e.getMessage() + ")");
! return;
! }
}
}
|
|
From: Huston F. <hu...@us...> - 2001-07-29 03:53:00
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp
In directory usw-pr-cvs1:/tmp/cvs-serv31128/src/org/beepcore/beep/transport/tcp
Modified Files:
TCPSession.java
Log Message:
Fixed erroneous message for aborted session
Index: TCPSession.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/transport/tcp/TCPSession.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** TCPSession.java 2001/06/28 15:42:49 1.10
--- TCPSession.java 2001/07/29 03:52:57 1.11
***************
*** 391,395 ****
* @throws BEEPException
*/
! private void processNextFrame() throws BEEPException, IOException
{
if (Log.isLogged(Log.SEV_DEBUG_VERBOSE)) {
--- 391,396 ----
* @throws BEEPException
*/
! private void processNextFrame()
! throws BEEPException, IOException, SessionAbortedException
{
if (Log.isLogged(Log.SEV_DEBUG_VERBOSE)) {
***************
*** 407,411 ****
if (b == -1) {
! throw new BEEPException("Malformed BEEP header, EOS");
}
--- 408,412 ----
if (b == -1) {
! throw new SessionAbortedException();
}
***************
*** 440,444 ****
for (int count = 0; count < payload.length; ) {
! count += is.read(payload, count, payload.length - count);
}
--- 441,449 ----
for (int count = 0; count < payload.length; ) {
! int n = is.read(payload, count, payload.length - count);
! if (n == -1) {
! throw new SessionAbortedException();
! }
! count += n;
}
***************
*** 452,457 ****
if (b == -1) {
! throw new BEEPException("Malformed BEEP frame, "
! + "trailer not found");
}
--- 457,461 ----
if (b == -1) {
! throw new SessionAbortedException();
}
***************
*** 520,523 ****
--- 524,529 ----
terminate(e.getMessage());
+ } catch (SessionAbortedException e) {
+ terminate("Session aborted by remote peer.");
} catch (Throwable e) {
Log.logEntry(Log.SEV_ERROR, TCP_MAPPING, e);
***************
*** 529,532 ****
--- 535,541 ----
+ TCPSession.this.getState());
}
+ }
+
+ private static class SessionAbortedException extends Exception {
}
}
|