You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2011/05/07 14:55:39 UTC
svn commit: r1100524 - in /mina/sshd/trunk/sshd-core/src:
main/java/org/apache/sshd/common/util/Buffer.java
test/java/org/apache/sshd/common/util/BufferTest.java
Author: elecharny
Date: Sat May 7 12:55:39 2011
New Revision: 1100524
URL: http://svn.apache.org/viewvc?rev=1100524&view=rev
Log:
Applied patch for SSHD-130
Added:
mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java?rev=1100524&r1=1100523&r2=1100524&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/util/Buffer.java Sat May 7 12:55:39 2011
@@ -19,9 +19,21 @@
package org.apache.sshd.common.util;
import java.math.BigInteger;
-import java.security.*;
-import java.security.interfaces.*;
-import java.security.spec.*;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.DSAPrivateKeySpec;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.sshd.common.KeyPairProvider;
@@ -155,14 +167,14 @@ public final class Buffer {
public long getLong()
{
ensureAvailable(8);
- long l = ((data[rpos++] << 56) & 0xff00000000000000L)|
- ((data[rpos++] << 48) & 0x00ff000000000000L)|
- ((data[rpos++] << 40) & 0x0000ff0000000000L)|
- ((data[rpos++] << 32) & 0x000000ff00000000L)|
- ((data[rpos++] << 24) & 0x00000000ff000000L)|
- ((data[rpos++] << 16) & 0x0000000000ff0000L)|
- ((data[rpos++] << 8) & 0x000000000000ff00L)|
- ((data[rpos++] ) & 0x00000000000000ffL);
+ long l = (((long) data[rpos++] << 56) & 0xff00000000000000L)|
+ (((long) data[rpos++] << 48) & 0x00ff000000000000L)|
+ (((long) data[rpos++] << 40) & 0x0000ff0000000000L)|
+ (((long) data[rpos++] << 32) & 0x000000ff00000000L)|
+ (((long) data[rpos++] << 24) & 0x00000000ff000000L)|
+ (((long) data[rpos++] << 16) & 0x0000000000ff0000L)|
+ (((long) data[rpos++] << 8) & 0x000000000000ff00L)|
+ (((long) data[rpos++] ) & 0x00000000000000ffL);
return l;
}
Added: mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java?rev=1100524&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java (added)
+++ mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java Sat May 7 12:55:39 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+
+import org.junit.Test;
+
+public class BufferTest {
+
+ @Test
+ public void testGetLong() throws Exception {
+ long v = 1234567890123456789L;
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ new DataOutputStream(stream).writeLong(v);
+ Buffer buffer = new Buffer(stream.toByteArray());
+ assertEquals(v, buffer.getLong());
+ }
+}