#include "jni.h"
@@ -51,3 +52,17 @@ void buildJniFunctionName(const char *sym, const char *cname,
}
}
+size_t
+getLastErrorString(char *buf, size_t len)
+{
+ if (errno == 0 || len < 1) return 0;
+
+ const char *err = strerror(errno);
+ size_t n = strlen(err);
+ if (n >= len)
+ n = len - 1;
+
+ strncpy(buf, err, n);
+ buf[n] = '\0';
+ return n;
+}
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c
index dedeedb669f..ad9655452e4 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c
@@ -790,6 +790,11 @@ void parseExclusiveBindProperty(JNIEnv *env) {
#endif
}
+JNIEXPORT jint JNICALL
+NET_EnableFastTcpLoopback(int fd) {
+ return 0;
+}
+
/* In the case of an IPv4 Inetaddress this method will return an
* IPv4 mapped address where IPv6 is available and v4MappedAddress is TRUE.
* Otherwise it will return a sockaddr_in structure for an IPv4 InetAddress.
diff --git a/jdk/src/java.base/unix/native/libnio/ch/Net.c b/jdk/src/java.base/unix/native/libnio/ch/Net.c
index 197b23a7285..d8653d624f6 100644
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c
+++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c
@@ -188,7 +188,7 @@ Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
JNIEXPORT int JNICALL
Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
- jboolean stream, jboolean reuse)
+ jboolean stream, jboolean reuse, jboolean ignored)
{
int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
diff --git a/jdk/src/java.base/windows/native/include/jvm_md.h b/jdk/src/java.base/windows/native/include/jvm_md.h
index 23b2a74f546..e9feba32415 100644
--- a/jdk/src/java.base/windows/native/include/jvm_md.h
+++ b/jdk/src/java.base/windows/native/include/jvm_md.h
@@ -97,7 +97,6 @@ JVM_GetHostByName(char* name);
#define JVM_O_O_APPEND O_APPEND
#define JVM_O_EXCL O_EXCL
#define JVM_O_CREAT O_CREAT
-#define JVM_O_DELETE O_TEMPORARY
/* Signals */
diff --git a/jdk/src/java.base/windows/native/libjava/io_util_md.c b/jdk/src/java.base/windows/native/libjava/io_util_md.c
index 123995433eb..ba2db4de401 100644
--- a/jdk/src/java.base/windows/native/libjava/io_util_md.c
+++ b/jdk/src/java.base/windows/native/libjava/io_util_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -576,77 +576,3 @@ handleLseek(FD fd, jlong offset, jint whence)
}
return long_to_jlong(pos.QuadPart);
}
-
-size_t
-getLastErrorString(char *utf8_jvmErrorMsg, size_t cbErrorMsg)
-{
- size_t n = 0;
- if (cbErrorMsg > 0) {
- BOOLEAN noError = FALSE;
- WCHAR *utf16_osErrorMsg = (WCHAR *)malloc(cbErrorMsg*sizeof(WCHAR));
- if (utf16_osErrorMsg == NULL) {
- // OOM accident
- strncpy(utf8_jvmErrorMsg, "Out of memory", cbErrorMsg);
- // truncate if too long
- utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0';
- n = strlen(utf8_jvmErrorMsg);
- } else {
- DWORD errval = GetLastError();
- if (errval != 0) {
- // WIN32 error
- n = (size_t)FormatMessageW(
- FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- errval,
- 0,
- utf16_osErrorMsg,
- (DWORD)cbErrorMsg,
- NULL);
- if (n > 3) {
- // Drop final '.', CR, LF
- if (utf16_osErrorMsg[n - 1] == L'\n') --n;
- if (utf16_osErrorMsg[n - 1] == L'\r') --n;
- if (utf16_osErrorMsg[n - 1] == L'.') --n;
- utf16_osErrorMsg[n] = L'\0';
- }
- } else if (errno != 0) {
- // C runtime error that has no corresponding WIN32 error code
- const WCHAR *rtError = _wcserror(errno);
- if (rtError != NULL) {
- wcsncpy(utf16_osErrorMsg, rtError, cbErrorMsg);
- // truncate if too long
- utf16_osErrorMsg[cbErrorMsg - 1] = L'\0';
- n = wcslen(utf16_osErrorMsg);
- }
- } else
- noError = TRUE; //OS has no error to report
-
- if (!noError) {
- if (n > 0) {
- n = WideCharToMultiByte(
- CP_UTF8,
- 0,
- utf16_osErrorMsg,
- n,
- utf8_jvmErrorMsg,
- cbErrorMsg,
- NULL,
- NULL);
-
- // no way to die
- if (n > 0)
- utf8_jvmErrorMsg[min(cbErrorMsg - 1, n)] = '\0';
- }
-
- if (n <= 0) {
- strncpy(utf8_jvmErrorMsg, "Secondary error while OS message extraction", cbErrorMsg);
- // truncate if too long
- utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0';
- n = strlen(utf8_jvmErrorMsg);
- }
- }
- free(utf16_osErrorMsg);
- }
- }
- return n;
-}
diff --git a/jdk/src/java.base/windows/native/libjava/jni_util_md.c b/jdk/src/java.base/windows/native/libjava/jni_util_md.c
index 80f1b355fe5..b2bb70aa758 100644
--- a/jdk/src/java.base/windows/native/libjava/jni_util_md.c
+++ b/jdk/src/java.base/windows/native/libjava/jni_util_md.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -73,3 +73,77 @@ void buildJniFunctionName(const char *sym, const char *cname,
}
return;
}
+
+size_t
+getLastErrorString(char *utf8_jvmErrorMsg, size_t cbErrorMsg)
+{
+ size_t n = 0;
+ if (cbErrorMsg > 0) {
+ BOOLEAN noError = FALSE;
+ WCHAR *utf16_osErrorMsg = (WCHAR *)malloc(cbErrorMsg*sizeof(WCHAR));
+ if (utf16_osErrorMsg == NULL) {
+ // OOM accident
+ strncpy(utf8_jvmErrorMsg, "Out of memory", cbErrorMsg);
+ // truncate if too long
+ utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0';
+ n = strlen(utf8_jvmErrorMsg);
+ } else {
+ DWORD errval = GetLastError();
+ if (errval != 0) {
+ // WIN32 error
+ n = (size_t)FormatMessageW(
+ FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errval,
+ 0,
+ utf16_osErrorMsg,
+ (DWORD)cbErrorMsg,
+ NULL);
+ if (n > 3) {
+ // Drop final '.', CR, LF
+ if (utf16_osErrorMsg[n - 1] == L'\n') --n;
+ if (utf16_osErrorMsg[n - 1] == L'\r') --n;
+ if (utf16_osErrorMsg[n - 1] == L'.') --n;
+ utf16_osErrorMsg[n] = L'\0';
+ }
+ } else if (errno != 0) {
+ // C runtime error that has no corresponding WIN32 error code
+ const WCHAR *rtError = _wcserror(errno);
+ if (rtError != NULL) {
+ wcsncpy(utf16_osErrorMsg, rtError, cbErrorMsg);
+ // truncate if too long
+ utf16_osErrorMsg[cbErrorMsg - 1] = L'\0';
+ n = wcslen(utf16_osErrorMsg);
+ }
+ } else
+ noError = TRUE; //OS has no error to report
+
+ if (!noError) {
+ if (n > 0) {
+ n = WideCharToMultiByte(
+ CP_UTF8,
+ 0,
+ utf16_osErrorMsg,
+ n,
+ utf8_jvmErrorMsg,
+ cbErrorMsg,
+ NULL,
+ NULL);
+
+ // no way to die
+ if (n > 0)
+ utf8_jvmErrorMsg[min(cbErrorMsg - 1, n)] = '\0';
+ }
+
+ if (n <= 0) {
+ strncpy(utf8_jvmErrorMsg, "Secondary error while OS message extraction", cbErrorMsg);
+ // truncate if too long
+ utf8_jvmErrorMsg[cbErrorMsg - 1] = '\0';
+ n = strlen(utf8_jvmErrorMsg);
+ }
+ }
+ free(utf16_osErrorMsg);
+ }
+ }
+ return n;
+}
diff --git a/jdk/src/java.base/windows/native/libnet/net_util_md.c b/jdk/src/java.base/windows/native/libnet/net_util_md.c
index 523973ba50f..8a0f5c15275 100644
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.c
@@ -29,6 +29,9 @@
#include "net_util.h"
#include "jni.h"
+// Taken from mstcpip.h in Windows SDK 8.0 or newer.
+#define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16)
+
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
#endif
@@ -844,6 +847,25 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
}
}
+/**
+ * Enables SIO_LOOPBACK_FAST_PATH
+ */
+JNIEXPORT jint JNICALL
+NET_EnableFastTcpLoopback(int fd) {
+ int enabled = 1;
+ DWORD result_byte_count = -1;
+ int result = WSAIoctl(fd,
+ SIO_LOOPBACK_FAST_PATH,
+ &enabled,
+ sizeof(enabled),
+ NULL,
+ 0,
+ &result_byte_count,
+ NULL,
+ NULL);
+ return result == SOCKET_ERROR ? WSAGetLastError() : 0;
+}
+
/* If address types is IPv6, then IPv6 must be available. Otherwise
* no address can be generated. In the case of an IPv4 Inetaddress this
* method will return an IPv4 mapped address where IPv6 is available and
diff --git a/jdk/src/java.base/windows/native/libnio/ch/Net.c b/jdk/src/java.base/windows/native/libnio/ch/Net.c
index b92e63ac11b..be3d0f99677 100644
--- a/jdk/src/java.base/windows/native/libnio/ch/Net.c
+++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c
@@ -127,7 +127,7 @@ Java_sun_nio_ch_Net_canJoin6WithIPv4Group0(JNIEnv* env, jclass cl)
JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
- jboolean stream, jboolean reuse)
+ jboolean stream, jboolean reuse, jboolean fastLoopback)
{
SOCKET s;
int domain = (preferIPv6) ? AF_INET6 : AF_INET;
@@ -152,6 +152,20 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
NET_ThrowNew(env, WSAGetLastError(), "socket");
}
+ if (stream && fastLoopback) {
+ static int loopback_available = 1;
+ if (loopback_available) {
+ int rv = NET_EnableFastTcpLoopback((jint)s);
+ if (rv) {
+ if (rv == WSAEOPNOTSUPP) {
+ loopback_available = 0;
+ } else {
+ NET_ThrowNew(env, rv, "fastLoopback");
+ }
+ }
+ }
+ }
+
return (jint)s;
}
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
index ecd55cbe7cf..6f9c444bb03 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/FileHandler.java
@@ -150,7 +150,7 @@ import java.util.Set;
public class FileHandler extends StreamHandler {
private MeteredStream meter;
private boolean append;
- private int limit; // zero => no limit.
+ private long limit; // zero => no limit.
private int count;
private String pattern;
private String lockFileName;
@@ -164,11 +164,11 @@ public class FileHandler extends StreamHandler {
* (a) forwards all its output to a target stream
* (b) keeps track of how many bytes have been written
*/
- private class MeteredStream extends OutputStream {
+ private static final class MeteredStream extends OutputStream {
final OutputStream out;
- int written;
+ long written;
- MeteredStream(OutputStream out, int written) {
+ MeteredStream(OutputStream out, long written) {
this.out = out;
this.written = written;
}
@@ -203,9 +203,9 @@ public class FileHandler extends StreamHandler {
}
private void open(File fname, boolean append) throws IOException {
- int len = 0;
+ long len = 0;
if (append) {
- len = (int)fname.length();
+ len = fname.length();
}
FileOutputStream fout = new FileOutputStream(fname.toString(), append);
BufferedOutputStream bout = new BufferedOutputStream(fout);
@@ -223,7 +223,7 @@ public class FileHandler extends StreamHandler {
String cname = getClass().getName();
pattern = manager.getStringProperty(cname + ".pattern", "%h/java%u.log");
- limit = manager.getIntProperty(cname + ".limit", 0);
+ limit = manager.getLongProperty(cname + ".limit", 0);
if (limit < 0) {
limit = 0;
}
@@ -395,6 +395,39 @@ public class FileHandler extends StreamHandler {
*/
public FileHandler(String pattern, int limit, int count, boolean append)
throws IOException, SecurityException {
+ this(pattern, (long)limit, count, append);
+ }
+
+ /**
+ * Initialize a {@code FileHandler} to write to a set of files
+ * with optional append. When (approximately) the given limit has
+ * been written to one file, another file will be opened. The
+ * output will cycle through a set of count files.
+ *
+ * The {@code FileHandler} is configured based on {@code LogManager}
+ * properties (or their default values) except that the given pattern
+ * argument is used as the filename pattern, the file limit is
+ * set to the limit argument, and the file count is set to the
+ * given count argument, and the append mode is set to the given
+ * {@code append} argument.
+ *
+ * The count must be at least 1.
+ *
+ * @param pattern the pattern for naming the output file
+ * @param limit the maximum number of bytes to write to any one file
+ * @param count the number of files to use
+ * @param append specifies append mode
+ * @exception IOException if there are IO problems opening the files.
+ * @exception SecurityException if a security manager exists and if
+ * the caller does not have {@code LoggingPermission("control")}.
+ * @exception IllegalArgumentException if {@code limit < 0}, or {@code count < 1}.
+ * @exception IllegalArgumentException if pattern is an empty string
+ *
+ * @since 1.9
+ *
+ */
+ public FileHandler(String pattern, long limit, int count, boolean append)
+ throws IOException {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
@@ -690,7 +723,7 @@ public class FileHandler extends StreamHandler {
}
super.publish(record);
flush();
- if (limit > 0 && meter.written >= limit) {
+ if (limit > 0 && (meter.written >= limit || meter.written < 0)) {
// We performed access checks in the "init" method to make sure
// we are only initialized from trusted code. So we assume
// it is OK to write the target files, even if we are
diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
index b7b00086034..45f2c054bd6 100644
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java
@@ -1387,6 +1387,21 @@ public class LogManager {
}
}
+ // Package private method to get a long property.
+ // If the property is not defined or cannot be parsed
+ // we return the given default value.
+ long getLongProperty(String name, long defaultValue) {
+ String val = getProperty(name);
+ if (val == null) {
+ return defaultValue;
+ }
+ try {
+ return Long.parseLong(val.trim());
+ } catch (Exception ex) {
+ return defaultValue;
+ }
+ }
+
// Package private method to get a boolean property.
// If the property is not defined or cannot be parsed
// we return the given default value.
diff --git a/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c b/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c
index 59f3f7db971..4c1eeea2f0b 100644
--- a/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c
+++ b/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c
@@ -65,6 +65,11 @@ jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
dcmd_arg_info_array);
dcmdArgInfoCls = (*env)->FindClass(env,
"sun/management/DiagnosticCommandArgumentInfo");
+ if ((*env)->ExceptionCheck(env)) {
+ free(dcmd_arg_info_array);
+ return NULL;
+ }
+
result = (*env)->NewObjectArray(env, num_arg, dcmdArgInfoCls, NULL);
if (result == NULL) {
free(dcmd_arg_info_array);
@@ -91,9 +96,16 @@ jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
}
free(dcmd_arg_info_array);
arraysCls = (*env)->FindClass(env, "java/util/Arrays");
+ if ((*env)->ExceptionCheck(env)) {
+ return NULL;
+ }
mid = (*env)->GetStaticMethodID(env, arraysCls,
"asList", "([Ljava/lang/Object;)Ljava/util/List;");
resultList = (*env)->CallStaticObjectMethod(env, arraysCls, mid, result);
+ if ((*env)->ExceptionCheck(env)) {
+ // Make sure we return NULL in case of OOM inside Java
+ return NULL;
+ }
return resultList;
}
@@ -121,6 +133,10 @@ Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommandInfo
num_commands = (*env)->GetArrayLength(env, commands);
dcmdInfoCls = (*env)->FindClass(env,
"sun/management/DiagnosticCommandInfo");
+ if ((*env)->ExceptionCheck(env)) {
+ return NULL;
+ }
+
result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL);
if (result == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
diff --git a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetWarning.java b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetWarning.java
index b8f1c4b0a14..311c74ad8fd 100644
--- a/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetWarning.java
+++ b/jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/RowSetWarning.java
@@ -55,11 +55,6 @@ import java.sql.SQLException;
*/
public class RowSetWarning extends SQLException {
- /**
- * RowSetWarning object handle.
- */
- private RowSetWarning rwarning;
-
/**
* Constructs a RowSetWarning
object
* with the given value for the reason; SQLState defaults to null,
@@ -128,7 +123,15 @@ public class RowSetWarning extends SQLException {
* @see #setNextWarning
*/
public RowSetWarning getNextWarning() {
- return rwarning;
+ SQLException warning = getNextException();
+ if ( warning == null || warning instanceof RowSetWarning) {
+ return (RowSetWarning)warning;
+ } else {
+ // The chained value isn't a RowSetWarning.
+ // This is a programming error by whoever added it to
+ // the RowSetWarning chain. We throw a Java "Error".
+ throw new Error("RowSetWarning chain holds value that is not a RowSetWarning: ");
+ }
}
/**
@@ -141,7 +144,7 @@ public class RowSetWarning extends SQLException {
* @see #getNextWarning
*/
public void setNextWarning(RowSetWarning warning) {
- rwarning = warning;
+ setNextException(warning);
}
static final long serialVersionUID = 6678332766434564774L;
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java
new file mode 100644
index 00000000000..1ecdda7812e
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/CipherContextRef.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+
+import java.security.*;
+import java.security.spec.*;
+import javax.crypto.*;
+
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * Internal class for context resource clean up.
+ *
+ * @since 1.9
+ */
+final class CipherContextRef extends PhantomReference
+ implements Comparable {
+
+ private static ReferenceQueue refQueue =
+ new ReferenceQueue();
+
+ // Needed to keep these references from being GC'ed until when their
+ // referents are GC'ed so we can do post-mortem processing
+ private static Set refList =
+ new ConcurrentSkipListSet();
+
+ final long id;
+ final boolean encrypt;
+
+ private static void drainRefQueueBounded() {
+ while (true) {
+ CipherContextRef next = (CipherContextRef) refQueue.poll();
+ if (next == null) break;
+ next.dispose(true);
+ }
+ }
+
+ CipherContextRef(NativeCipher nc, long id, boolean encrypt) {
+ super(nc, refQueue);
+ this.id = id;
+ this.encrypt = encrypt;
+ refList.add(this);
+ UcryptoProvider.debug("Resource: trace CipherCtxt " + this.id);
+ drainRefQueueBounded();
+ }
+
+ public int compareTo(CipherContextRef other) {
+ if (this.id == other.id) {
+ return 0;
+ } else {
+ return (this.id < other.id) ? -1 : 1;
+ }
+ }
+
+ void dispose(boolean doCancel) {
+ refList.remove(this);
+ try {
+ if (doCancel) {
+ UcryptoProvider.debug("Resource: cancel CipherCtxt " + id);
+ int k = NativeCipher.nativeFinal(id, encrypt, null, 0);
+ if (k < 0) {
+ UcryptoProvider.debug
+ ("Resource: error cancelling CipherCtxt " + id +
+ " " + new UcryptoException(-k).getMessage());
+ }
+ } else {
+ UcryptoProvider.debug("Resource: untrace CipherCtxt " + id);
+ }
+ } finally {
+ this.clear();
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java
new file mode 100644
index 00000000000..67dc8a33e4f
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/Config.java
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.io.*;
+import static java.io.StreamTokenizer.*;
+import java.math.BigInteger;
+import java.util.*;
+
+import java.security.*;
+
+import sun.security.action.GetPropertyAction;
+import sun.security.util.PropertyExpander;
+
+import sun.security.pkcs11.wrapper.*;
+
+/**
+ * Configuration container and file parsing.
+ *
+ * Currently, there is only one supported entry "disabledServices"
+ * for disabling crypto services. Its syntax is as follows:
+ *
+ * disabledServices = {
+ * .
+ * ...
+ * }
+ *
+ * where can be "MessageDigest", "Cipher", etc. and
+ * reprepresents the value that's passed into the various getInstance() calls.
+ *
+ * @since 1.9
+ */
+final class Config {
+
+ // Reader and StringTokenizer used during parsing
+ private Reader reader;
+
+ private StreamTokenizer st;
+
+ private Set parsedKeywords;
+
+ // set of disabled crypto services, e.g. MessageDigest.SHA1, or
+ // Cipher.AES/ECB/PKCS5Padding
+ private Set disabledServices;
+
+ Config(String filename) throws IOException {
+ FileInputStream in = new FileInputStream(expand(filename));
+ reader = new BufferedReader(new InputStreamReader(in));
+ parsedKeywords = new HashSet();
+ st = new StreamTokenizer(reader);
+ setupTokenizer();
+ parse();
+ }
+
+ String[] getDisabledServices() {
+ if (disabledServices != null) {
+ return disabledServices.toArray(new String[disabledServices.size()]);
+ } else {
+ return new String[0];
+ }
+ }
+
+ private static String expand(final String s) throws IOException {
+ try {
+ return PropertyExpander.expand(s);
+ } catch (Exception e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ private void setupTokenizer() {
+ st.resetSyntax();
+ st.wordChars('a', 'z');
+ st.wordChars('A', 'Z');
+ st.wordChars('0', '9');
+ st.wordChars(':', ':');
+ st.wordChars('.', '.');
+ st.wordChars('_', '_');
+ st.wordChars('-', '-');
+ st.wordChars('/', '/');
+ st.wordChars('\\', '\\');
+ st.wordChars('$', '$');
+ st.wordChars('{', '{'); // need {} for property subst
+ st.wordChars('}', '}');
+ st.wordChars('*', '*');
+ st.wordChars('+', '+');
+ st.wordChars('~', '~');
+ // XXX check ASCII table and add all other characters except special
+
+ // special: #="(),
+ st.whitespaceChars(0, ' ');
+ st.commentChar('#');
+ st.eolIsSignificant(true);
+ st.quoteChar('\"');
+ }
+
+ private ConfigException excToken(String msg) {
+ return new ConfigException(msg + " " + st);
+ }
+
+ private ConfigException excLine(String msg) {
+ return new ConfigException(msg + ", line " + st.lineno());
+ }
+
+ private void parse() throws IOException {
+ while (true) {
+ int token = nextToken();
+ if (token == TT_EOF) {
+ break;
+ }
+ if (token == TT_EOL) {
+ continue;
+ }
+ if (token != TT_WORD) {
+ throw excToken("Unexpected token:");
+ }
+ String word = st.sval;
+ if (word.equals("disabledServices")) {
+ parseDisabledServices(word);
+ } else {
+ throw new ConfigException
+ ("Unknown keyword '" + word + "', line " + st.lineno());
+ }
+ parsedKeywords.add(word);
+ }
+ reader.close();
+ reader = null;
+ st = null;
+ parsedKeywords = null;
+ }
+
+ //
+ // Parsing helper methods
+ //
+ private int nextToken() throws IOException {
+ int token = st.nextToken();
+ return token;
+ }
+
+ private void parseEquals() throws IOException {
+ int token = nextToken();
+ if (token != '=') {
+ throw excToken("Expected '=', read");
+ }
+ }
+
+ private void parseOpenBraces() throws IOException {
+ while (true) {
+ int token = nextToken();
+ if (token == TT_EOL) {
+ continue;
+ }
+ if ((token == TT_WORD) && st.sval.equals("{")) {
+ return;
+ }
+ throw excToken("Expected '{', read");
+ }
+ }
+
+ private boolean isCloseBraces(int token) {
+ return (token == TT_WORD) && st.sval.equals("}");
+ }
+
+ private void checkDup(String keyword) throws IOException {
+ if (parsedKeywords.contains(keyword)) {
+ throw excLine(keyword + " must only be specified once");
+ }
+ }
+
+ private void parseDisabledServices(String keyword) throws IOException {
+ checkDup(keyword);
+ disabledServices = new HashSet();
+ parseEquals();
+ parseOpenBraces();
+ while (true) {
+ int token = nextToken();
+ if (isCloseBraces(token)) {
+ break;
+ }
+ if (token == TT_EOL) {
+ continue;
+ }
+ if (token != TT_WORD) {
+ throw excToken("Expected mechanism, read");
+ }
+ disabledServices.add(st.sval);
+ }
+ }
+}
+
+class ConfigException extends IOException {
+ private static final long serialVersionUID = 254492758127673194L;
+ ConfigException(String msg) {
+ super(msg);
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java
new file mode 100644
index 00000000000..ed598d6d6b5
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/GCMParameters.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.security.AlgorithmParametersSpi;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import javax.crypto.spec.GCMParameterSpec;
+import sun.security.util.*;
+
+/**
+ * This class implements the parameter set used with GCM mode
+ * which is defined in RFC5084 as follows:
+ *
+ *
+ * GCMParameters ::= SEQUENCE {
+ * aes-nonce OCTET STRING, -- recommended size is 12 octets
+ * aes-ICVlen AES-GCM-ICVlen DEFAULT 12 }
+ *
+ * where
+ * AES-GCM-ICVlen ::= INTEGER (12 | 13 | 14 | 15 | 16)
+ * NOTE: however, NIST 800-38D also lists 4 (32bit) and 8 (64bit)
+ * as possible AES-GCM-ICVlen values, so we allow all 6 values.
+ *
+ *
+ * @since 1.9
+ */
+public final class GCMParameters extends AlgorithmParametersSpi {
+
+ private byte[] iv; // i.e. aes-nonce
+ private int tLen; // i.e. aes-ICVlen, in bytes
+
+ public GCMParameters() {}
+
+ private void setValues(byte[] iv, int tLen) throws IOException {
+ if (iv == null) {
+ throw new IOException("IV cannot be null");
+ }
+ if (tLen != 4 && tLen != 8 && (tLen < 12 || tLen > 16)) {
+ throw new IOException("Unsupported tag length: " + tLen);
+ }
+ this.iv = iv;
+ this.tLen = tLen;
+ }
+
+ protected byte[] engineGetEncoded() throws IOException {
+ DerOutputStream out = new DerOutputStream();
+ DerOutputStream bytes = new DerOutputStream();
+
+ bytes.putOctetString(iv);
+ bytes.putInteger(tLen);
+ out.write(DerValue.tag_Sequence, bytes);
+ return out.toByteArray();
+ }
+
+ protected byte[] engineGetEncoded(String format) throws IOException {
+ // ignore format for now
+ return engineGetEncoded();
+ }
+
+ protected
+ T engineGetParameterSpec(Class paramSpec)
+ throws InvalidParameterSpecException {
+ if (GCMParameterSpec.class.isAssignableFrom(paramSpec)) {
+ return paramSpec.cast(new GCMParameterSpec(tLen*8, iv.clone()));
+ } else {
+ throw new InvalidParameterSpecException
+ ("Inappropriate parameter specification");
+ }
+ }
+
+ protected void engineInit(AlgorithmParameterSpec paramSpec)
+ throws InvalidParameterSpecException {
+ if (!(paramSpec instanceof GCMParameterSpec)) {
+ throw new InvalidParameterSpecException
+ ("Inappropriate parameter specification");
+ }
+ GCMParameterSpec gcmSpec = (GCMParameterSpec) paramSpec;
+ try {
+ setValues(gcmSpec.getIV(), gcmSpec.getTLen()/8);
+ } catch (IOException ioe) {
+ throw new InvalidParameterSpecException(ioe.getMessage());
+ }
+ }
+
+ protected void engineInit(byte[] encoded) throws IOException {
+ DerValue val = new DerValue(encoded);
+ if (val.tag == DerValue.tag_Sequence) {
+ val.data.reset();
+ setValues(val.data.getOctetString(), val.data.getInteger());
+ } else {
+ throw new IOException("GCM parameter parsing error: SEQ tag expected");
+ }
+ }
+
+ protected void engineInit(byte[] encoded, String format)
+ throws IOException {
+ // ignore format for now
+ engineInit(encoded);
+ }
+
+ protected String engineToString() {
+ return ("IV=" + Arrays.toString(iv) + ", tLen=" + tLen * 8);
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java
new file mode 100644
index 00000000000..afed4c1009a
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipher.java
@@ -0,0 +1,588 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+
+import java.security.*;
+import java.security.spec.*;
+import javax.crypto.*;
+
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * Cipher wrapper class utilizing ucrypto APIs. This class currently supports
+ * - AES/ECB/NOPADDING
+ * - AES/CBC/NOPADDING
+ * - AES/CTR/NOPADDING
+ * - AES/CFB128/NOPADDING
+ * (Support for GCM mode is inside the child class NativeGCMCipher)
+ *
+ * @since 1.9
+ */
+class NativeCipher extends CipherSpi {
+
+ // public implementation classes
+ public static final class AesEcbNoPadding extends NativeCipher {
+ public AesEcbNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_ECB);
+ }
+ }
+ public static final class AesCbcNoPadding extends NativeCipher {
+ public AesCbcNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CBC);
+ }
+ }
+ public static final class AesCtrNoPadding extends NativeCipher {
+ public AesCtrNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CTR);
+ }
+ }
+ public static final class AesCfb128NoPadding extends NativeCipher {
+ public AesCfb128NoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CFB128);
+ }
+ }
+
+ // public implementation classes with fixed key sizes
+ public static final class Aes128EcbNoPadding extends NativeCipher {
+ public Aes128EcbNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_ECB, 16);
+ }
+ }
+ public static final class Aes128CbcNoPadding extends NativeCipher {
+ public Aes128CbcNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CBC, 16);
+ }
+ }
+ public static final class Aes192EcbNoPadding extends NativeCipher {
+ public Aes192EcbNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_ECB, 24);
+ }
+ }
+ public static final class Aes192CbcNoPadding extends NativeCipher {
+ public Aes192CbcNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CBC, 24);
+ }
+ }
+ public static final class Aes256EcbNoPadding extends NativeCipher {
+ public Aes256EcbNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_ECB, 32);
+ }
+ }
+ public static final class Aes256CbcNoPadding extends NativeCipher {
+ public Aes256CbcNoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_CBC, 32);
+ }
+ }
+
+ // ok as constants since AES is all we support
+ public static final int AES_BLOCK_SIZE = 16;
+ public static final String AES_KEY_ALGO = "AES";
+
+ // fields set in constructor
+ protected final UcryptoMech mech;
+ protected String keyAlgo;
+ protected int blockSize;
+ protected int fixedKeySize;
+
+ //
+ // fields (re)set in every init()
+ //
+ protected CipherContextRef pCtxt = null;
+ protected byte[] keyValue = null;
+ protected byte[] iv = null;
+ protected boolean initialized = false;
+ protected boolean encrypt = true;
+ protected int bytesBuffered = 0;
+
+ // private utility methods for key re-construction
+ private static final PublicKey constructPublicKey(byte[] encodedKey,
+ String encodedKeyAlgorithm)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ PublicKey key = null;
+ try {
+ KeyFactory keyFactory =
+ KeyFactory.getInstance(encodedKeyAlgorithm);
+ X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey);
+ key = keyFactory.generatePublic(keySpec);
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new NoSuchAlgorithmException("No provider found for " +
+ encodedKeyAlgorithm +
+ " KeyFactory");
+ } catch (InvalidKeySpecException ikse) {
+ // Should never happen
+ throw new InvalidKeyException("Cannot construct public key", ikse);
+ }
+ return key;
+ }
+
+ private static final PrivateKey constructPrivateKey(byte[] encodedKey,
+ String encodedKeyAlgorithm)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ PrivateKey key = null;
+ try {
+ KeyFactory keyFactory =
+ KeyFactory.getInstance(encodedKeyAlgorithm);
+ PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
+ key = keyFactory.generatePrivate(keySpec);
+ } catch (NoSuchAlgorithmException nsae) {
+ throw new NoSuchAlgorithmException("No provider found for " +
+ encodedKeyAlgorithm +
+ " KeyFactory");
+ } catch (InvalidKeySpecException ikse) {
+ // Should never happen
+ throw new InvalidKeyException("Cannot construct private key", ikse);
+ }
+ return key;
+ }
+
+ private static final SecretKey constructSecretKey(byte[] encodedKey,
+ String encodedKeyAlgorithm) {
+ return new SecretKeySpec(encodedKey, encodedKeyAlgorithm);
+ }
+
+ // package-private utility method for general key re-construction
+ static final Key constructKey(int keyType, byte[] encodedKey,
+ String encodedKeyAlgorithm)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+ Key result = null;
+ switch (keyType) {
+ case Cipher.SECRET_KEY:
+ result = constructSecretKey(encodedKey,
+ encodedKeyAlgorithm);
+ break;
+ case Cipher.PRIVATE_KEY:
+ result = constructPrivateKey(encodedKey,
+ encodedKeyAlgorithm);
+ break;
+ case Cipher.PUBLIC_KEY:
+ result = constructPublicKey(encodedKey,
+ encodedKeyAlgorithm);
+ break;
+ }
+ return result;
+ }
+
+ NativeCipher(UcryptoMech mech, int fixedKeySize) throws NoSuchAlgorithmException {
+ this.mech = mech;
+ // defaults to AES - the only supported symmetric cipher algo
+ this.blockSize = AES_BLOCK_SIZE;
+ this.keyAlgo = AES_KEY_ALGO;
+ this.fixedKeySize = fixedKeySize;
+ }
+
+ NativeCipher(UcryptoMech mech) throws NoSuchAlgorithmException {
+ this(mech, -1);
+ }
+
+ @Override
+ protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
+ // Disallow change of mode for now since currently it's explicitly
+ // defined in transformation strings
+ throw new NoSuchAlgorithmException("Unsupported mode " + mode);
+ }
+
+ // see JCE spec
+ @Override
+ protected void engineSetPadding(String padding)
+ throws NoSuchPaddingException {
+ // Disallow change of padding for now since currently it's explicitly
+ // defined in transformation strings
+ throw new NoSuchPaddingException("Unsupported padding " + padding);
+ }
+
+ // see JCE spec
+ @Override
+ protected int engineGetBlockSize() {
+ return blockSize;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineGetOutputSize(int inputLen) {
+ return getOutputSizeByOperation(inputLen, true);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineGetIV() {
+ return (iv != null? iv.clone() : null);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized AlgorithmParameters engineGetParameters() {
+ AlgorithmParameters params = null;
+ try {
+ if (iv != null) {
+ IvParameterSpec ivSpec = new IvParameterSpec(iv.clone());
+ params = AlgorithmParameters.getInstance(keyAlgo);
+ params.init(ivSpec);
+ }
+ } catch (GeneralSecurityException e) {
+ // NoSuchAlgorithmException, NoSuchProviderException
+ // InvalidParameterSpecException
+ throw new UcryptoException("Could not encode parameters", e);
+ }
+ return params;
+ }
+
+ @Override
+ protected int engineGetKeySize(Key key) throws InvalidKeyException {
+ return checkKey(key) * 8;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key,
+ SecureRandom random) throws InvalidKeyException {
+ try {
+ engineInit(opmode, key, (AlgorithmParameterSpec)null, random);
+ } catch (InvalidAlgorithmParameterException e) {
+ throw new InvalidKeyException("init() failed", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key,
+ AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ checkKey(key);
+ if (opmode != Cipher.ENCRYPT_MODE &&
+ opmode != Cipher.DECRYPT_MODE &&
+ opmode != Cipher.WRAP_MODE &&
+ opmode != Cipher.UNWRAP_MODE) {
+ throw new InvalidAlgorithmParameterException
+ ("Unsupported mode: " + opmode);
+ }
+ boolean doEncrypt =
+ (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE);
+
+ byte[] ivBytes = null;
+ if (mech == UcryptoMech.CRYPTO_AES_ECB) {
+ if (params != null) {
+ throw new InvalidAlgorithmParameterException
+ ("No Parameters for ECB mode");
+ }
+ } else {
+ if (params != null) {
+ if (!(params instanceof IvParameterSpec)) {
+ throw new InvalidAlgorithmParameterException
+ ("IvParameterSpec required");
+ } else {
+ ivBytes = ((IvParameterSpec) params).getIV();
+ if (ivBytes.length != blockSize) {
+ throw new InvalidAlgorithmParameterException
+ ("Wrong IV length: must be " + blockSize +
+ " bytes long");
+ }
+ }
+ } else {
+ if (encrypt) {
+ // generate IV if none supplied for encryption
+ ivBytes = new byte[blockSize];
+ new SecureRandom().nextBytes(ivBytes);
+ } else {
+ throw new InvalidAlgorithmParameterException
+ ("Parameters required for decryption");
+ }
+ }
+ }
+ init(doEncrypt, key.getEncoded().clone(), ivBytes);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key,
+ AlgorithmParameters params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ AlgorithmParameterSpec spec = null;
+ if (params != null) {
+ try {
+ spec = params.getParameterSpec(IvParameterSpec.class);
+ } catch (InvalidParameterSpecException iaps) {
+ throw new InvalidAlgorithmParameterException(iaps);
+ }
+ }
+ engineInit(opmode, key, spec, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineUpdate(byte[] in, int ofs, int len) {
+ byte[] out = new byte[getOutputSizeByOperation(len, false)];
+ int n = update(in, ofs, len, out, 0);
+ if (n == 0) {
+ return null;
+ } else if (out.length != n) {
+ out = Arrays.copyOf(out, n);
+ }
+ return out;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineUpdate(byte[] in, int inOfs, int inLen,
+ byte[] out, int outOfs) throws ShortBufferException {
+ int min = getOutputSizeByOperation(inLen, false);
+ if (out.length - outOfs < min) {
+ throw new ShortBufferException("min " + min + "-byte buffer needed");
+ }
+ return update(in, inOfs, inLen, out, outOfs);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineUpdateAAD(byte[] src, int ofs, int len)
+ throws IllegalStateException {
+ throw new IllegalStateException("No AAD can be supplied");
+ }
+
+ // see JCE spec
+ @Override
+ protected void engineUpdateAAD(ByteBuffer src)
+ throws IllegalStateException {
+ throw new IllegalStateException("No AAD can be supplied");
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineDoFinal(byte[] in, int ofs, int len)
+ throws IllegalBlockSizeException, BadPaddingException {
+ byte[] out = new byte[getOutputSizeByOperation(len, true)];
+ try {
+ // delegate to the other engineDoFinal(...) method
+ int k = engineDoFinal(in, ofs, len, out, 0);
+ if (out.length != k) {
+ out = Arrays.copyOf(out, k);
+ }
+ return out;
+ } catch (ShortBufferException e) {
+ throw new UcryptoException("Internal Error", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineDoFinal(byte[] in, int inOfs, int inLen,
+ byte[] out, int outOfs)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException {
+ int k = 0;
+ int min = getOutputSizeByOperation(inLen, true);
+ if (out.length - outOfs < min) {
+ throw new ShortBufferException("min " + min + "-byte buffer needed");
+ }
+ if (inLen > 0) {
+ k = update(in, inOfs, inLen, out, outOfs);
+ outOfs += k;
+ }
+ k += doFinal(out, outOfs);
+ return k;
+ }
+
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineWrap(Key key)
+ throws IllegalBlockSizeException, InvalidKeyException {
+ byte[] result = null;
+ try {
+ byte[] encodedKey = key.getEncoded();
+ if ((encodedKey == null) || (encodedKey.length == 0)) {
+ throw new InvalidKeyException("Cannot get an encoding of " +
+ "the key to be wrapped");
+ }
+ result = engineDoFinal(encodedKey, 0, encodedKey.length);
+ } catch (BadPaddingException e) {
+ // Should never happen for key wrapping
+ throw new UcryptoException("Internal Error" , e);
+ }
+ return result;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized Key engineUnwrap(byte[] wrappedKey,
+ String wrappedKeyAlgorithm, int wrappedKeyType)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ byte[] encodedKey;
+ Key result = null;
+ try {
+ encodedKey = engineDoFinal(wrappedKey, 0,
+ wrappedKey.length);
+ } catch (Exception e) {
+ throw (InvalidKeyException)
+ (new InvalidKeyException()).initCause(e);
+ }
+
+ return constructKey(wrappedKeyType, encodedKey, wrappedKeyAlgorithm);
+ }
+
+ final int checkKey(Key key) throws InvalidKeyException {
+ if (key == null || key.getEncoded() == null) {
+ throw new InvalidKeyException("Key cannot be null");
+ } else {
+ // check key algorithm and format
+ if (!keyAlgo.equalsIgnoreCase(key.getAlgorithm())) {
+ throw new InvalidKeyException("Key algorithm must be " +
+ keyAlgo);
+ }
+ if (!"RAW".equalsIgnoreCase(key.getFormat())) {
+ throw new InvalidKeyException("Key format must be RAW");
+ }
+ int keyLen = key.getEncoded().length;
+ if (fixedKeySize == -1) {
+ // all 3 AES key lengths are allowed
+ if (keyLen != 16 && keyLen != 24 && keyLen != 32) {
+ throw new InvalidKeyException("Key size is not valid");
+ }
+ } else {
+ if (keyLen != fixedKeySize) {
+ throw new InvalidKeyException("Only " + fixedKeySize +
+ "-byte keys are accepted");
+ }
+ }
+ // return the validated key length in bytes
+ return keyLen;
+ }
+ }
+
+ protected void reset(boolean doCancel) {
+ initialized = false;
+ bytesBuffered = 0;
+ if (pCtxt != null) {
+ pCtxt.dispose(doCancel);
+ pCtxt = null;
+ }
+ }
+
+ /**
+ * calls ucrypto_encrypt_init(...) or ucrypto_decrypt_init(...)
+ * @return pointer to the context
+ */
+ protected native static long nativeInit(int mech, boolean encrypt,
+ byte[] key, byte[] iv,
+ int tagLen, byte[] aad);
+
+ /**
+ * calls ucrypto_encrypt_update(...) or ucrypto_decrypt_update(...)
+ * @returns the length of output or if negative, an error status code
+ */
+ private native static int nativeUpdate(long pContext, boolean encrypt,
+ byte[] in, int inOfs, int inLen,
+ byte[] out, int outOfs);
+
+ /**
+ * calls ucrypto_encrypt_final(...) or ucrypto_decrypt_final(...)
+ * @returns the length of output or if negative, an error status code
+ */
+ native static int nativeFinal(long pContext, boolean encrypt,
+ byte[] out, int outOfs);
+
+ protected void ensureInitialized() {
+ if (!initialized) {
+ init(encrypt, keyValue, iv);
+ if (!initialized) {
+ throw new UcryptoException("Cannot initialize Cipher");
+ }
+ }
+ }
+
+ protected int getOutputSizeByOperation(int inLen, boolean isDoFinal) {
+ if (inLen <= 0) {
+ inLen = 0;
+ }
+ if (!isDoFinal && (inLen == 0)) {
+ return 0;
+ }
+ return inLen + bytesBuffered;
+ }
+
+ // actual init() implementation - caller should clone key and iv if needed
+ protected void init(boolean encrypt, byte[] keyVal, byte[] ivVal) {
+ reset(true);
+ this.encrypt = encrypt;
+ this.keyValue = keyVal;
+ this.iv = ivVal;
+ long pCtxtVal = nativeInit(mech.value(), encrypt, keyValue, iv, 0, null);
+ initialized = (pCtxtVal != 0L);
+ if (initialized) {
+ pCtxt = new CipherContextRef(this, pCtxtVal, encrypt);
+ } else {
+ throw new UcryptoException("Cannot initialize Cipher");
+ }
+ }
+
+ // Caller MUST check and ensure output buffer has enough capacity
+ private int update(byte[] in, int inOfs, int inLen, byte[] out, int outOfs) {
+ ensureInitialized();
+ if (inLen <= 0) { return 0; }
+
+ int k = nativeUpdate(pCtxt.id, encrypt, in, inOfs, inLen, out, outOfs);
+ if (k < 0) {
+ reset(false);
+ // cannot throw ShortBufferException here since it's too late
+ // native context is invalid upon any failure
+ throw new UcryptoException(-k);
+ }
+ bytesBuffered += (inLen - k);
+ return k;
+ }
+
+ // Caller MUST check and ensure output buffer has enough capacity
+ private int doFinal(byte[] out, int outOfs) throws IllegalBlockSizeException,
+ BadPaddingException {
+ try {
+ ensureInitialized();
+
+ int k = nativeFinal(pCtxt.id, encrypt, out, outOfs);
+ if (k < 0) {
+ String cause = UcryptoException.getErrorMessage(-k);
+ if (cause.endsWith("_LEN_RANGE")) {
+ throw new IllegalBlockSizeException(cause);
+ } else if (cause.endsWith("_DATA_INVALID")) {
+ throw new BadPaddingException(cause);
+ } else {
+ throw new UcryptoException(-k);
+ }
+ }
+ return k;
+ } finally {
+ reset(false);
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java
new file mode 100644
index 00000000000..fdd1c3ebb7e
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeCipherWithJavaPadding.java
@@ -0,0 +1,464 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+
+import java.security.AlgorithmParameters;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherSpi;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.ShortBufferException;
+
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * Wrapper class which uses NativeCipher class and Java impls of padding scheme.
+ * This class currently supports
+ * - AES/ECB/PKCS5PADDING
+ * - AES/CBC/PKCS5PADDING
+ * - AES/CFB128/PKCS5PADDING
+ *
+ * @since 1.9
+ */
+public class NativeCipherWithJavaPadding extends CipherSpi {
+
+ private static interface Padding {
+ // ENC: generate and return the necessary padding bytes
+ int getPadLen(int dataLen);
+
+ // ENC: generate and return the necessary padding bytes
+ byte[] getPaddingBytes(int dataLen);
+
+ // DEC: process the decrypted data and buffer up the potential padding
+ // bytes
+ byte[] bufferBytes(byte[] intermediateData);
+
+ // DEC: return the length of internally buffered pad bytes
+ int getBufferedLength();
+
+ // DEC: unpad and place the output in 'out', starting from outOfs
+ // and return the number of bytes unpadded into 'out'.
+ int unpad(byte[] paddedData, byte[] out, int outOfs)
+ throws BadPaddingException, IllegalBlockSizeException,
+ ShortBufferException;
+
+ // DEC: Clears the padding object to the initial state
+ void clear();
+ }
+
+ private static class PKCS5Padding implements Padding {
+ private final int blockSize;
+ // buffer for storing the the potential padding bytes
+ private ByteBuffer trailingBytes = null;
+
+ PKCS5Padding(int blockSize)
+ throws NoSuchPaddingException {
+ if (blockSize == 0) {
+ throw new NoSuchPaddingException
+ ("PKCS#5 padding not supported with stream ciphers");
+ }
+ this.blockSize = blockSize;
+ }
+
+ public int getPadLen(int dataLen) {
+ return (blockSize - (dataLen & (blockSize - 1)));
+ }
+
+ public byte[] getPaddingBytes(int dataLen) {
+ byte padValue = (byte) getPadLen(dataLen);
+ byte[] paddingBytes = new byte[padValue];
+ Arrays.fill(paddingBytes, padValue);
+ return paddingBytes;
+ }
+
+ public byte[] bufferBytes(byte[] dataFromUpdate) {
+ if (dataFromUpdate == null || dataFromUpdate.length == 0) {
+ return null;
+ }
+ byte[] result = null;
+ if (trailingBytes == null) {
+ trailingBytes = ByteBuffer.wrap(new byte[blockSize]);
+ }
+ int tbSize = trailingBytes.position();
+ if (dataFromUpdate.length > trailingBytes.remaining()) {
+ int totalLen = dataFromUpdate.length + tbSize;
+ int newTBSize = totalLen % blockSize;
+ if (newTBSize == 0) {
+ newTBSize = blockSize;
+ }
+ if (tbSize == 0) {
+ result = Arrays.copyOf(dataFromUpdate, totalLen - newTBSize);
+ } else {
+ // combine 'trailingBytes' and 'dataFromUpdate'
+ result = Arrays.copyOf(trailingBytes.array(),
+ totalLen - newTBSize);
+ if (result.length != tbSize) {
+ System.arraycopy(dataFromUpdate, 0, result, tbSize,
+ result.length - tbSize);
+ }
+ }
+ // update 'trailingBytes' w/ remaining bytes in 'dataFromUpdate'
+ trailingBytes.clear();
+ trailingBytes.put(dataFromUpdate,
+ dataFromUpdate.length - newTBSize, newTBSize);
+ } else {
+ trailingBytes.put(dataFromUpdate);
+ }
+ return result;
+ }
+
+ public int getBufferedLength() {
+ if (trailingBytes != null) {
+ return trailingBytes.position();
+ }
+ return 0;
+ }
+
+ public int unpad(byte[] lastData, byte[] out, int outOfs)
+ throws BadPaddingException, IllegalBlockSizeException,
+ ShortBufferException {
+ int tbSize = (trailingBytes == null? 0:trailingBytes.position());
+ int dataLen = tbSize + lastData.length;
+ // check total length
+ if ((dataLen < 1) || (dataLen % blockSize != 0)) {
+ UcryptoProvider.debug("PKCS5Padding: unpad, buffered " + tbSize +
+ " bytes, last block " + lastData.length + " bytes");
+
+ throw new IllegalBlockSizeException
+ ("Input length must be multiples of " + blockSize);
+ }
+
+ // check padding bytes
+ if (lastData.length == 0) {
+ if (tbSize != 0) {
+ // work on 'trailingBytes' directly
+ lastData = Arrays.copyOf(trailingBytes.array(), tbSize);
+ trailingBytes.clear();
+ tbSize = 0;
+ } else {
+ throw new BadPaddingException("No pad bytes found!");
+ }
+ }
+ byte padValue = lastData[lastData.length - 1];
+ if (padValue < 1 || padValue > blockSize) {
+ UcryptoProvider.debug("PKCS5Padding: unpad, lastData: " + Arrays.toString(lastData));
+ UcryptoProvider.debug("PKCS5Padding: unpad, padValue=" + padValue);
+ throw new BadPaddingException("Invalid pad value!");
+ }
+
+ // sanity check padding bytes
+ int padStartIndex = lastData.length - padValue;
+ for (int i = padStartIndex; i < lastData.length; i++) {
+ if (lastData[i] != padValue) {
+ UcryptoProvider.debug("PKCS5Padding: unpad, lastData: " + Arrays.toString(lastData));
+ UcryptoProvider.debug("PKCS5Padding: unpad, padValue=" + padValue);
+ throw new BadPaddingException("Invalid padding bytes!");
+ }
+ }
+
+ int actualOutLen = dataLen - padValue;
+ // check output buffer capacity
+ if (out.length - outOfs < actualOutLen) {
+ throw new ShortBufferException("Output buffer too small, need " + actualOutLen +
+ ", got " + (out.length - outOfs));
+ }
+ try {
+ if (tbSize != 0) {
+ trailingBytes.rewind();
+ if (tbSize < actualOutLen) {
+ trailingBytes.get(out, outOfs, tbSize);
+ outOfs += tbSize;
+ } else {
+ // copy from trailingBytes and we are done
+ trailingBytes.get(out, outOfs, actualOutLen);
+ return actualOutLen;
+ }
+ }
+ if (lastData.length > padValue) {
+ System.arraycopy(lastData, 0, out, outOfs,
+ lastData.length - padValue);
+ }
+ return actualOutLen;
+ } finally {
+ clear();
+ }
+ }
+
+ public void clear() {
+ if (trailingBytes != null) trailingBytes.clear();
+ }
+ }
+
+ public static final class AesEcbPKCS5 extends NativeCipherWithJavaPadding {
+ public AesEcbPKCS5() throws NoSuchAlgorithmException, NoSuchPaddingException {
+ super(new NativeCipher.AesEcbNoPadding(), "PKCS5Padding");
+ }
+ }
+
+ public static final class AesCbcPKCS5 extends NativeCipherWithJavaPadding {
+ public AesCbcPKCS5() throws NoSuchAlgorithmException, NoSuchPaddingException {
+ super(new NativeCipher.AesCbcNoPadding(), "PKCS5Padding");
+ }
+ }
+
+ public static final class AesCfb128PKCS5 extends NativeCipherWithJavaPadding {
+ public AesCfb128PKCS5() throws NoSuchAlgorithmException, NoSuchPaddingException {
+ super(new NativeCipher.AesCfb128NoPadding(), "PKCS5Padding");
+ }
+ }
+
+ // fields (re)set in every init()
+ private final NativeCipher nc;
+ private final Padding padding;
+ private final int blockSize;
+ private int lastBlockLen = 0;
+
+ // Only ECB, CBC, CTR, and CFB128 modes w/ NOPADDING for now
+ NativeCipherWithJavaPadding(NativeCipher nc, String paddingScheme)
+ throws NoSuchAlgorithmException, NoSuchPaddingException {
+ this.nc = nc;
+ this.blockSize = nc.engineGetBlockSize();
+ if (paddingScheme.toUpperCase().equals("PKCS5PADDING")) {
+ padding = new PKCS5Padding(blockSize);
+ } else {
+ throw new NoSuchAlgorithmException("Unsupported padding scheme: " + paddingScheme);
+ }
+ }
+
+ void reset() {
+ padding.clear();
+ lastBlockLen = 0;
+ }
+
+ @Override
+ protected synchronized void engineSetMode(String mode) throws NoSuchAlgorithmException {
+ nc.engineSetMode(mode);
+ }
+
+ // see JCE spec
+ @Override
+ protected void engineSetPadding(String padding)
+ throws NoSuchPaddingException {
+ // Disallow change of padding for now since currently it's explicitly
+ // defined in transformation strings
+ throw new NoSuchPaddingException("Unsupported padding " + padding);
+ }
+
+ // see JCE spec
+ @Override
+ protected int engineGetBlockSize() {
+ return blockSize;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineGetOutputSize(int inputLen) {
+ int result = nc.engineGetOutputSize(inputLen);
+ if (nc.encrypt) {
+ result += padding.getPadLen(result);
+ } else {
+ result += padding.getBufferedLength();
+ }
+ return result;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineGetIV() {
+ return nc.engineGetIV();
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized AlgorithmParameters engineGetParameters() {
+ return nc.engineGetParameters();
+ }
+
+ @Override
+ protected int engineGetKeySize(Key key) throws InvalidKeyException {
+ return nc.engineGetKeySize(key);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException {
+ reset();
+ nc.engineInit(opmode, key, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key,
+ AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ reset();
+ nc.engineInit(opmode, key, params, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key, AlgorithmParameters params,
+ SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ reset();
+ nc.engineInit(opmode, key, params, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
+ if (nc.encrypt) {
+ lastBlockLen += inLen;
+ lastBlockLen &= (blockSize - 1);
+ return nc.engineUpdate(in, inOfs, inLen);
+ } else {
+ return padding.bufferBytes(nc.engineUpdate(in, inOfs, inLen));
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs) throws ShortBufferException {
+ if (nc.encrypt) {
+ lastBlockLen += inLen;
+ lastBlockLen &= (blockSize - 1);
+ return nc.engineUpdate(in, inOfs, inLen, out, outOfs);
+ } else {
+ byte[] result = padding.bufferBytes(nc.engineUpdate(in, inOfs, inLen));
+ if (result != null) {
+ System.arraycopy(result, 0, out, outOfs, result.length);
+ return result.length;
+ } else return 0;
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
+ throws IllegalBlockSizeException, BadPaddingException {
+ int estimatedOutLen = engineGetOutputSize(inLen);
+ byte[] out = new byte[estimatedOutLen];
+ try {
+ int actualOut = this.engineDoFinal(in, inOfs, inLen, out, 0);
+ // truncate off extra bytes
+ if (actualOut != out.length) {
+ out = Arrays.copyOf(out, actualOut);
+ }
+ } catch (ShortBufferException sbe) {
+ throw new UcryptoException("Internal Error");
+ } finally {
+ reset();
+ }
+ return out;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException {
+ int estimatedOutLen = engineGetOutputSize(inLen);
+
+ if (out.length - outOfs < estimatedOutLen) {
+ throw new ShortBufferException();
+ }
+ try {
+ if (nc.encrypt) {
+ int k = nc.engineUpdate(in, inOfs, inLen, out, outOfs);
+ lastBlockLen += inLen;
+ lastBlockLen &= (blockSize - 1);
+ byte[] padBytes = padding.getPaddingBytes(lastBlockLen);
+ k += nc.engineDoFinal(padBytes, 0, padBytes.length, out, (outOfs + k));
+ return k;
+ } else {
+ byte[] tempOut = nc.engineDoFinal(in, inOfs, inLen);
+ int len = padding.unpad(tempOut, out, outOfs);
+ return len;
+ }
+ } finally {
+ reset();
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineWrap(Key key) throws IllegalBlockSizeException,
+ InvalidKeyException {
+ byte[] result = null;
+ try {
+ byte[] encodedKey = key.getEncoded();
+ if ((encodedKey == null) || (encodedKey.length == 0)) {
+ throw new InvalidKeyException("Cannot get an encoding of " +
+ "the key to be wrapped");
+ }
+ result = engineDoFinal(encodedKey, 0, encodedKey.length);
+ } catch (BadPaddingException e) {
+ // Should never happen for key wrapping
+ throw new UcryptoException("Internal Error", e);
+ }
+ return result;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
+ int wrappedKeyType)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ byte[] encodedKey;
+ try {
+ encodedKey = engineDoFinal(wrappedKey, 0,
+ wrappedKey.length);
+ } catch (Exception e) {
+ throw (InvalidKeyException)
+ (new InvalidKeyException()).initCause(e);
+ }
+
+ return NativeCipher.constructKey(wrappedKeyType, encodedKey,
+ wrappedKeyAlgorithm);
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java
new file mode 100644
index 00000000000..9121be3d8cb
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeDigest.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.lang.ref.*;
+
+import java.io.ByteArrayOutputStream;
+import java.util.*;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.security.*;
+
+/**
+ * MessageDigest implementation class. This class currently supports
+ * MD5, SHA1, SHA256, SHA384, and SHA512
+ *
+ * @since 1.9
+ */
+public abstract class NativeDigest extends MessageDigestSpi
+ implements Cloneable {
+
+ private static final int MECH_MD5 = 1;
+ private static final int MECH_SHA1 = 2;
+ private static final int MECH_SHA256 = 3;
+ private static final int MECH_SHA224 = 4;
+ private static final int MECH_SHA384 = 5;
+ private static final int MECH_SHA512 = 6;
+
+ private final int digestLen;
+ private final int mech;
+
+ // field for ensuring native memory is freed
+ private DigestContextRef pCtxt = null;
+
+ private static class DigestContextRef extends PhantomReference
+ implements Comparable {
+
+ private static ReferenceQueue refQueue =
+ new ReferenceQueue();
+
+ // Needed to keep these references from being GC'ed until when their
+ // referents are GC'ed so we can do post-mortem processing
+ private static Set refList =
+ new ConcurrentSkipListSet();
+ // Collections.synchronizedSortedSet(new TreeSet());
+
+ private final long id;
+ private final int mech;
+
+ private static void drainRefQueueBounded() {
+ while (true) {
+ DigestContextRef next = (DigestContextRef) refQueue.poll();
+ if (next == null) break;
+ next.dispose(true);
+ }
+ }
+
+ DigestContextRef(NativeDigest nc, long id, int mech) {
+ super(nc, refQueue);
+ this.id = id;
+ this.mech = mech;
+ refList.add(this);
+ UcryptoProvider.debug("Resource: track Digest Ctxt " + this.id);
+ drainRefQueueBounded();
+ }
+
+ public int compareTo(DigestContextRef other) {
+ if (this.id == other.id) {
+ return 0;
+ } else {
+ return (this.id < other.id) ? -1 : 1;
+ }
+ }
+
+ void dispose(boolean needFree) {
+ refList.remove(this);
+ try {
+ if (needFree) {
+ UcryptoProvider.debug("Resource: free Digest Ctxt " + this.id);
+ NativeDigest.nativeFree(mech, id);
+ } else UcryptoProvider.debug("Resource: stop tracking Digest Ctxt " + this.id);
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
+ NativeDigest(int mech, int digestLen) {
+ this.digestLen = digestLen;
+ this.mech = mech;
+ }
+
+ // see JCA spec
+ protected int engineGetDigestLength() {
+ return digestLen;
+ }
+
+ // see JCA spec
+ protected synchronized void engineReset() {
+ if (pCtxt != null) {
+ pCtxt.dispose(true);
+ pCtxt = null;
+ }
+ }
+
+ // see JCA spec
+ protected synchronized byte[] engineDigest() {
+ byte[] digest = new byte[digestLen];
+ try {
+ int len = engineDigest(digest, 0, digestLen);
+ if (len != digestLen) {
+ throw new UcryptoException("Digest length mismatch");
+ }
+ return digest;
+ } catch (DigestException de) {
+ throw new UcryptoException("Internal error", de);
+ }
+ }
+
+ // see JCA spec
+ protected synchronized int engineDigest(byte[] out, int ofs, int len)
+ throws DigestException {
+ if (len < digestLen) {
+ throw new DigestException("Output buffer must be at least " +
+ digestLen + " bytes long");
+ }
+ if ((ofs < 0) || (len < 0) || (ofs > out.length - len)) {
+ throw new DigestException("Buffer too short to store digest");
+ }
+
+ if (pCtxt == null) {
+ pCtxt = new DigestContextRef(this, nativeInit(mech), mech);
+ }
+ try {
+ int status = nativeDigest(mech, pCtxt.id, out, ofs, digestLen);
+ if (status != 0) {
+ throw new DigestException("Internal error: " + status);
+ }
+ } finally {
+ pCtxt.dispose(false);
+ pCtxt = null;
+ }
+ return digestLen;
+ }
+
+ // see JCA spec
+ protected synchronized void engineUpdate(byte in) {
+ byte[] temp = { in };
+ engineUpdate(temp, 0, 1);
+ }
+
+ // see JCA spec
+ protected synchronized void engineUpdate(byte[] in, int ofs, int len) {
+ if (len == 0) {
+ return;
+ }
+ if ((ofs < 0) || (len < 0) || (ofs > in.length - len)) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ if (pCtxt == null) {
+ pCtxt = new DigestContextRef(this, nativeInit(mech), mech);
+ }
+ nativeUpdate(mech, pCtxt.id, in, ofs, len);
+ }
+
+ /**
+ * Clone this digest.
+ */
+ public synchronized Object clone() throws CloneNotSupportedException {
+ NativeDigest copy = (NativeDigest) super.clone();
+ // re-work the fields that cannot be copied over
+ if (pCtxt != null) {
+ copy.pCtxt = new DigestContextRef(this, nativeClone(mech, pCtxt.id), mech);
+ }
+ return copy;
+ }
+
+ // return pointer to the context
+ protected static native long nativeInit(int mech);
+ // return status code; always 0
+ protected static native int nativeUpdate(int mech, long pCtxt, byte[] in, int ofs, int inLen);
+ // return status code; always 0
+ protected static native int nativeDigest(int mech, long pCtxt, byte[] out, int ofs, int digestLen);
+ // return pointer to the duplicated context
+ protected static native long nativeClone(int mech, long pCtxt);
+ // free the specified context
+ private native static void nativeFree(int mech, long id);
+
+
+ public static final class MD5 extends NativeDigest {
+ public MD5() {
+ super(MECH_MD5, 16);
+ }
+ }
+
+ public static final class SHA1 extends NativeDigest {
+ public SHA1() {
+ super(MECH_SHA1, 20);
+ }
+ }
+
+ public static final class SHA256 extends NativeDigest {
+ public SHA256() {
+ super(MECH_SHA256, 32);
+ }
+ }
+
+
+ public static final class SHA384 extends NativeDigest {
+ public SHA384() {
+ super(MECH_SHA384, 48);
+ }
+ }
+
+
+ public static final class SHA512 extends NativeDigest {
+ public SHA512() {
+ super(MECH_SHA512, 64);
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java
new file mode 100644
index 00000000000..80c7bb08243
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeGCMCipher.java
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+
+import java.util.Set;
+import java.util.Arrays;
+import java.security.*;
+import java.security.spec.*;
+import javax.crypto.*;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.spec.GCMParameterSpec;
+
+/**
+ * Cipher wrapper class utilizing ucrypto APIs. This class currently supports
+ * - AES/GCM/NoPADDING
+ *
+ * @since 1.9
+ */
+class NativeGCMCipher extends NativeCipher {
+
+ public static final class AesGcmNoPadding extends NativeGCMCipher {
+ public AesGcmNoPadding() throws NoSuchAlgorithmException {
+ super(-1);
+ }
+ }
+ public static final class Aes128GcmNoPadding extends NativeGCMCipher {
+ public Aes128GcmNoPadding() throws NoSuchAlgorithmException {
+ super(16);
+ }
+ }
+ public static final class Aes192GcmNoPadding extends NativeGCMCipher {
+ public Aes192GcmNoPadding() throws NoSuchAlgorithmException {
+ super(24);
+ }
+ }
+ public static final class Aes256GcmNoPadding extends NativeGCMCipher {
+ public Aes256GcmNoPadding() throws NoSuchAlgorithmException {
+ super(32);
+ }
+ }
+
+ private static final int DEFAULT_TAG_LEN = 128; // same as SunJCE provider
+
+ // buffer for storing AAD data; if null, meaning buffer content has been
+ // supplied to native context
+ private ByteArrayOutputStream aadBuffer = new ByteArrayOutputStream();
+
+ // buffer for storing input in decryption, not used for encryption
+ private ByteArrayOutputStream ibuffer = null;
+
+ private int tagLen = DEFAULT_TAG_LEN;
+
+ /*
+ * variables used for performing the GCM (key+iv) uniqueness check.
+ * To use GCM mode safely, the cipher object must be re-initialized
+ * with a different combination of key + iv values for each
+ * ENCRYPTION operation. However, checking all past key + iv values
+ * isn't feasible. Thus, we only do a per-instance check of the
+ * key + iv values used in previous encryption.
+ * For decryption operations, no checking is necessary.
+ */
+ private boolean requireReinit = false;
+ private byte[] lastEncKey = null;
+ private byte[] lastEncIv = null;
+
+ NativeGCMCipher(int fixedKeySize) throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_AES_GCM, fixedKeySize);
+ }
+
+ @Override
+ protected void ensureInitialized() {
+ if (!initialized) {
+ if (aadBuffer != null && aadBuffer.size() > 0) {
+ init(encrypt, keyValue, iv, tagLen, aadBuffer.toByteArray());
+ aadBuffer = null;
+ } else {
+ init(encrypt, keyValue, iv, tagLen, null);
+ }
+ if (!initialized) {
+ throw new UcryptoException("Cannot initialize Cipher");
+ }
+ }
+ }
+
+ @Override
+ protected int getOutputSizeByOperation(int inLen, boolean isDoFinal) {
+ if (inLen < 0) return 0;
+
+ if (!isDoFinal && (inLen == 0)) {
+ return 0;
+ }
+
+ int result = inLen + bytesBuffered;
+ if (encrypt) {
+ if (isDoFinal) {
+ result += tagLen/8;
+ }
+ } else {
+ if (ibuffer != null) {
+ result += ibuffer.size();
+ }
+ if (isDoFinal) {
+ result -= tagLen/8;
+ }
+ }
+ if (result < 0) {
+ result = 0;
+ }
+ return result;
+ }
+
+ @Override
+ protected void reset(boolean doCancel) {
+ super.reset(doCancel);
+ if (aadBuffer == null) {
+ aadBuffer = new ByteArrayOutputStream();
+ } else {
+ aadBuffer.reset();
+ }
+
+ if (ibuffer != null) {
+ ibuffer.reset();
+ }
+ if (!encrypt) requireReinit = false;
+ }
+
+ // actual init() implementation - caller should clone key and iv if needed
+ protected void init(boolean encrypt, byte[] keyVal, byte[] ivVal, int tLen, byte[] aad) {
+ reset(true);
+ this.encrypt = encrypt;
+ this.keyValue = keyVal;
+ this.iv = ivVal;
+ long pCtxtVal = NativeCipher.nativeInit(mech.value(), encrypt, keyValue, iv,
+ tLen, aad);
+ initialized = (pCtxtVal != 0L);
+ if (initialized) {
+ pCtxt = new CipherContextRef(this, pCtxtVal, encrypt);
+ } else {
+ throw new UcryptoException("Cannot initialize Cipher");
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized AlgorithmParameters engineGetParameters() {
+ AlgorithmParameters params = null;
+ try {
+ if (iv != null) {
+ GCMParameterSpec gcmSpec = new GCMParameterSpec(tagLen, iv.clone());
+ params = AlgorithmParameters.getInstance("GCM");
+ params.init(gcmSpec);
+ }
+ } catch (GeneralSecurityException e) {
+ // NoSuchAlgorithmException, NoSuchProviderException
+ // InvalidParameterSpecException
+ throw new UcryptoException("Could not encode parameters", e);
+ }
+ return params;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key,
+ AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ checkKey(key);
+ if (opmode != Cipher.ENCRYPT_MODE &&
+ opmode != Cipher.DECRYPT_MODE &&
+ opmode != Cipher.WRAP_MODE &&
+ opmode != Cipher.UNWRAP_MODE) {
+ throw new InvalidAlgorithmParameterException
+ ("Unsupported mode: " + opmode);
+ }
+ boolean doEncrypt = (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE);
+ byte[] keyBytes = key.getEncoded().clone();
+ byte[] ivBytes = null;
+ if (params != null) {
+ if (!(params instanceof GCMParameterSpec)) {
+ throw new InvalidAlgorithmParameterException("GCMParameterSpec required");
+ } else {
+ tagLen = ((GCMParameterSpec) params).getTLen();
+ ivBytes = ((GCMParameterSpec) params).getIV();
+ }
+ } else {
+ if (doEncrypt) {
+ tagLen = DEFAULT_TAG_LEN;
+
+ // generate IV if none supplied for encryption
+ ivBytes = new byte[blockSize];
+ new SecureRandom().nextBytes(ivBytes);
+ } else {
+ throw new InvalidAlgorithmParameterException("Parameters required for decryption");
+ }
+ }
+ if (doEncrypt) {
+ requireReinit = Arrays.equals(ivBytes, lastEncIv) &&
+ Arrays.equals(keyBytes, lastEncKey);
+ if (requireReinit) {
+ throw new InvalidAlgorithmParameterException
+ ("Cannot reuse iv for GCM encryption");
+ }
+ lastEncIv = ivBytes;
+ lastEncKey = keyBytes;
+ } else {
+ requireReinit = false;
+ ibuffer = new ByteArrayOutputStream();
+ }
+ init(doEncrypt, keyBytes, ivBytes, tagLen, null);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key, AlgorithmParameters params,
+ SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ AlgorithmParameterSpec spec = null;
+ if (params != null) {
+ try {
+ // mech must be UcryptoMech.CRYPTO_AES_GCM
+ spec = params.getParameterSpec(GCMParameterSpec.class);
+ } catch (InvalidParameterSpecException iaps) {
+ throw new InvalidAlgorithmParameterException(iaps);
+ }
+ }
+ engineInit(opmode, key, spec, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
+ if (aadBuffer != null && aadBuffer.size() > 0) {
+ // init again with AAD data
+ init(encrypt, keyValue, iv, tagLen, aadBuffer.toByteArray());
+ aadBuffer = null;
+ }
+ if (requireReinit) {
+ throw new IllegalStateException
+ ("Must use either different key or iv for GCM encryption");
+ }
+ if (inLen > 0) {
+ if (!encrypt) {
+ ibuffer.write(in, inOfs, inLen);
+ return null;
+ }
+ return super.engineUpdate(in, inOfs, inLen);
+ } else return null;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs) throws ShortBufferException {
+ int len = getOutputSizeByOperation(inLen, false);
+ if (out.length - outOfs < len) {
+ throw new ShortBufferException("Output buffer must be "
+ + "(at least) " + len
+ + " bytes long");
+ }
+ if (aadBuffer != null && aadBuffer.size() > 0) {
+ // init again with AAD data
+ init(encrypt, keyValue, iv, tagLen, aadBuffer.toByteArray());
+ aadBuffer = null;
+ }
+ if (requireReinit) {
+ throw new IllegalStateException
+ ("Must use either different key or iv for GCM encryption");
+ }
+ if (inLen > 0) {
+ if (!encrypt) {
+ ibuffer.write(in, inOfs, inLen);
+ return 0;
+ } else {
+ return super.engineUpdate(in, inOfs, inLen, out, outOfs);
+ }
+ }
+ return 0;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineUpdateAAD(byte[] src, int srcOfs, int srcLen)
+ throws IllegalStateException {
+
+ if ((src == null) || (srcOfs < 0) || (srcOfs + srcLen > src.length)) {
+ throw new IllegalArgumentException("Invalid AAD");
+ }
+ if (keyValue == null) {
+ throw new IllegalStateException("Need to initialize Cipher first");
+ }
+ if (requireReinit) {
+ throw new IllegalStateException
+ ("Must use either different key or iv for GCM encryption");
+ }
+ if (aadBuffer != null) {
+ aadBuffer.write(src, srcOfs, srcLen);
+ } else {
+ // update has already been called
+ throw new IllegalStateException
+ ("Update has been called; no more AAD data");
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected void engineUpdateAAD(ByteBuffer src)
+ throws IllegalStateException {
+ if (src == null) {
+ throw new IllegalArgumentException("Invalid AAD");
+ }
+ if (keyValue == null) {
+ throw new IllegalStateException("Need to initialize Cipher first");
+ }
+ if (requireReinit) {
+ throw new IllegalStateException
+ ("Must use either different key or iv for GCM encryption");
+ }
+ if (aadBuffer != null) {
+ if (src.hasRemaining()) {
+ byte[] srcBytes = new byte[src.remaining()];
+ src.get(srcBytes);
+ aadBuffer.write(srcBytes, 0, srcBytes.length);
+ }
+ } else {
+ // update has already been called
+ throw new IllegalStateException
+ ("Update has been called; no more AAD data");
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
+ throws IllegalBlockSizeException, BadPaddingException {
+ byte[] out = new byte[getOutputSizeByOperation(inLen, true)];
+ try {
+ // delegate to the other engineDoFinal(...) method
+ int k = engineDoFinal(in, inOfs, inLen, out, 0);
+ if (out.length != k) {
+ out = Arrays.copyOf(out, k);
+ }
+ return out;
+ } catch (ShortBufferException e) {
+ throw new UcryptoException("Internal Error", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineDoFinal(byte[] in, int inOfs, int inLen,
+ byte[] out, int outOfs)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException {
+ int len = getOutputSizeByOperation(inLen, true);
+ if (out.length - outOfs < len) {
+ throw new ShortBufferException("Output buffer must be "
+ + "(at least) " + len
+ + " bytes long");
+ }
+ if (aadBuffer != null && aadBuffer.size() > 0) {
+ // init again with AAD data
+ init(encrypt, keyValue, iv, tagLen, aadBuffer.toByteArray());
+ aadBuffer = null;
+ }
+ if (requireReinit) {
+ throw new IllegalStateException
+ ("Must use either different key or iv for GCM encryption");
+ }
+ if (!encrypt) {
+ if (inLen > 0) {
+ ibuffer.write(in, inOfs, inLen);
+ }
+ inLen = ibuffer.size();
+ if (inLen < tagLen/8) {
+ // Otherwise, Solaris lib will error out w/ CRYPTO_BUFFER_TOO_SMALL
+ // when ucrypto_decrypt_final() is called
+ throw new AEADBadTagException("Input too short - need tag");
+ }
+ // refresh 'in' to all buffered-up bytes
+ in = ibuffer.toByteArray();
+ inOfs = 0;
+ ibuffer.reset();
+ }
+ try {
+ return super.engineDoFinal(in, inOfs, inLen, out, outOfs);
+ } catch (UcryptoException ue) {
+ if (ue.getMessage().equals("CRYPTO_INVALID_MAC")) {
+ throw new AEADBadTagException("Tag does not match");
+ } else {
+ // pass it up
+ throw ue;
+ }
+ } finally {
+ requireReinit = encrypt;
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java
new file mode 100644
index 00000000000..7f88f92ab4c
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeKey.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Key;
+import java.security.PublicKey;
+import java.security.PrivateKey;
+import java.security.KeyFactorySpi;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPublicKey;
+
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+/**
+ * Wrapper class for native keys needed for using ucrypto APIs.
+ * This class currently supports native RSA private/public keys.
+ *
+ * @since 1.9
+ */
+abstract class NativeKey implements Key {
+
+ private static final long serialVersionUID = 6812507588904302830L;
+
+ private final int numComponents;
+
+ NativeKey(int numComponents) {
+ this.numComponents = numComponents;
+ }
+
+ abstract long value();
+
+ int length() {
+ return numComponents;
+ }
+
+ public String getAlgorithm() { return "RSA"; }
+ public String getFormat() { return "RAW"; }
+ public byte[] getEncoded() {
+ // not used; so not generated
+ return null;
+ }
+
+ private native static void nativeFree(long id, int numComponents);
+
+ static byte[] getMagnitude(BigInteger bi) {
+ byte[] b = bi.toByteArray();
+ if ((b.length > 1) && (b[0] == 0)) {
+ int n = b.length - 1;
+ byte[] newarray = new byte[n];
+ System.arraycopy(b, 1, newarray, 0, n);
+ b = newarray;
+ }
+ return b;
+ }
+
+ static final class RSAPrivateCrt extends NativeKey implements RSAPrivateCrtKey {
+
+ private static final long serialVersionUID = 6812507588904302831L;
+
+ private final RSAPrivateCrtKeySpec keySpec;
+ private final long keyId;
+
+ RSAPrivateCrt(KeySpec keySpec) throws InvalidKeySpecException {
+ super(8);
+ long pKey = 0L;
+ if (keySpec instanceof RSAPrivateCrtKeySpec) {
+ RSAPrivateCrtKeySpec ks = (RSAPrivateCrtKeySpec) keySpec;
+ BigInteger mod = ks.getModulus();
+ BigInteger publicExp = ks.getPublicExponent();
+ BigInteger privateExp = ks.getPrivateExponent();
+ BigInteger primeP = ks.getPrimeP();
+ BigInteger primeQ = ks.getPrimeQ();
+ BigInteger primeExpP = ks.getPrimeExponentP();
+ BigInteger primeExpQ = ks.getPrimeExponentQ();
+ BigInteger crtCoeff = ks.getCrtCoefficient();
+ pKey = nativeInit(NativeKey.getMagnitude(mod),
+ NativeKey.getMagnitude(publicExp),
+ NativeKey.getMagnitude(privateExp),
+ NativeKey.getMagnitude(primeP),
+ NativeKey.getMagnitude(primeQ),
+ NativeKey.getMagnitude(primeExpP),
+ NativeKey.getMagnitude(primeExpQ),
+ NativeKey.getMagnitude(crtCoeff));
+ } else {
+ throw new InvalidKeySpecException("Only supports RSAPrivateCrtKeySpec");
+ }
+ if (pKey == 0L) {
+ throw new UcryptoException("Error constructing RSA PrivateKey");
+ }
+ // track native resource clean up
+ new KeyRef(this, pKey);
+ this.keySpec = (RSAPrivateCrtKeySpec) keySpec;
+ this.keyId = pKey;
+ }
+
+ long value() { return keyId; }
+ public BigInteger getModulus() { return keySpec.getModulus(); };
+ public BigInteger getPublicExponent() { return keySpec.getPublicExponent(); };
+ public BigInteger getPrivateExponent() { return keySpec.getPrivateExponent(); };
+ public BigInteger getPrimeP() { return keySpec.getPrimeP(); };
+ public BigInteger getPrimeQ() { return keySpec.getPrimeQ(); };
+ public BigInteger getPrimeExponentP() { return keySpec.getPrimeExponentP(); };
+ public BigInteger getPrimeExponentQ() { return keySpec.getPrimeExponentQ(); };
+ public BigInteger getCrtCoefficient() { return keySpec.getCrtCoefficient(); };
+
+ private native static long nativeInit(byte[] mod, byte[] pubExp, byte[] privExp,
+ byte[] p, byte[] q,
+ byte[] expP, byte[] expQ, byte[] crtCoeff);
+ }
+
+ static final class RSAPublic extends NativeKey implements RSAPublicKey {
+
+ private static final long serialVersionUID = 6812507588904302832L;
+
+ private final RSAPublicKeySpec keySpec;
+ private final long keyId;
+
+ RSAPublic(KeySpec keySpec) throws InvalidKeySpecException {
+ super(2);
+ long pKey = 0L;
+ if (keySpec instanceof RSAPublicKeySpec) {
+ RSAPublicKeySpec ks = (RSAPublicKeySpec) keySpec;
+ BigInteger mod = ks.getModulus();
+ BigInteger publicExp = ks.getPublicExponent();
+ pKey = nativeInit(NativeKey.getMagnitude(mod),
+ NativeKey.getMagnitude(publicExp));
+ } else {
+ throw new InvalidKeySpecException("Only supports RSAPublicKeySpec");
+ }
+ if (pKey == 0L) {
+ throw new UcryptoException("Error constructing RSA PublicKey");
+ }
+ // track native resource clean up
+ new KeyRef(this, pKey);
+ this.keySpec = (RSAPublicKeySpec) keySpec;
+ this.keyId = pKey;
+ }
+
+ long value() { return keyId; }
+ public BigInteger getModulus() { return keySpec.getModulus(); };
+ public BigInteger getPublicExponent() { return keySpec.getPublicExponent(); };
+
+ private native static long nativeInit(byte[] mod, byte[] pubExp);
+ }
+
+ // internal class for native resource cleanup
+ private static class KeyRef extends PhantomReference
+ implements Comparable {
+
+ private static ReferenceQueue refQueue =
+ new ReferenceQueue();
+
+ // Needed to keep these references from being GC'ed until when their
+ // referents are GC'ed so we can do post-mortem processing
+ private static Set refList =
+ new ConcurrentSkipListSet();
+
+ private final long id;
+ private final int length;
+
+ private static void drainRefQueueBounded() {
+ while (true) {
+ KeyRef next = (KeyRef) refQueue.poll();
+ if (next == null) break;
+ next.dispose();
+ }
+ }
+
+ KeyRef(NativeKey nk, long id) {
+ super(nk, refQueue);
+ this.id = id;
+ this.length = nk.length();
+ refList.add(this);
+ UcryptoProvider.debug("Resource: track NativeKey " + this.id);
+ drainRefQueueBounded();
+ }
+
+ public int compareTo(KeyRef other) {
+ if (this.id == other.id) {
+ return 0;
+ } else {
+ return (this.id < other.id) ? -1 : 1;
+ }
+ }
+
+ void dispose() {
+ refList.remove(this);
+ UcryptoProvider.debug("Resource: free NativeKey " + this.id);
+ try {
+ NativeKey.nativeFree(id, length);
+ } finally {
+ this.clear();
+ }
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java
new file mode 100644
index 00000000000..813da731c06
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSACipher.java
@@ -0,0 +1,448 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.Arrays;
+import java.util.WeakHashMap;
+import java.util.Collections;
+import java.util.Map;
+
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.PublicKey;
+import java.security.PrivateKey;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.security.interfaces.RSAKey;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.interfaces.RSAPublicKey;
+
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.spec.InvalidKeySpecException;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherSpi;
+import javax.crypto.SecretKey;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.ShortBufferException;
+
+import javax.crypto.spec.SecretKeySpec;
+
+import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
+import sun.security.util.KeyUtil;
+
+/**
+ * Asymmetric Cipher wrapper class utilizing ucrypto APIs. This class
+ * currently supports
+ * - RSA/ECB/NOPADDING
+ * - RSA/ECB/PKCS1PADDING
+ *
+ * @since 1.9
+ */
+public class NativeRSACipher extends CipherSpi {
+ // fields set in constructor
+ private final UcryptoMech mech;
+ private final int padLen;
+ private final NativeRSAKeyFactory keyFactory;
+ private AlgorithmParameterSpec spec;
+ private SecureRandom random;
+
+ // Keep a cache of RSA keys and their RSA NativeKey for reuse.
+ // When the RSA key is gc'ed, we let NativeKey phatom references cleanup
+ // the native allocation
+ private static final Map keyList =
+ Collections.synchronizedMap(new WeakHashMap());
+
+ //
+ // fields (re)set in every init()
+ //
+ private NativeKey key = null;
+ private int outputSize = 0; // e.g. modulus size in bytes
+ private boolean encrypt = true;
+ private byte[] buffer;
+ private int bufOfs = 0;
+
+ // public implementation classes
+ public static final class NoPadding extends NativeRSACipher {
+ public NoPadding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_RSA_X_509, 0);
+ }
+ }
+
+ public static final class PKCS1Padding extends NativeRSACipher {
+ public PKCS1Padding() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_RSA_PKCS, 11);
+ }
+ }
+
+ NativeRSACipher(UcryptoMech mech, int padLen)
+ throws NoSuchAlgorithmException {
+ this.mech = mech;
+ this.padLen = padLen;
+ this.keyFactory = new NativeRSAKeyFactory();
+ }
+
+ @Override
+ protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
+ // Disallow change of mode for now since currently it's explicitly
+ // defined in transformation strings
+ throw new NoSuchAlgorithmException("Unsupported mode " + mode);
+ }
+
+ // see JCE spec
+ @Override
+ protected void engineSetPadding(String padding)
+ throws NoSuchPaddingException {
+ // Disallow change of padding for now since currently it's explicitly
+ // defined in transformation strings
+ throw new NoSuchPaddingException("Unsupported padding " + padding);
+ }
+
+ // see JCE spec
+ @Override
+ protected int engineGetBlockSize() {
+ return 0;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineGetOutputSize(int inputLen) {
+ return outputSize;
+ }
+
+ // see JCE spec
+ @Override
+ protected byte[] engineGetIV() {
+ return null;
+ }
+
+ // see JCE spec
+ @Override
+ protected AlgorithmParameters engineGetParameters() {
+ return null;
+ }
+
+ @Override
+ protected int engineGetKeySize(Key key) throws InvalidKeyException {
+ if (!(key instanceof RSAKey)) {
+ throw new InvalidKeyException("RSAKey required");
+ }
+ int n = ((RSAKey)key).getModulus().bitLength();
+ // strip off the leading extra 0x00 byte prefix
+ int realByteSize = (n + 7) >> 3;
+ return realByteSize * 8;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key, SecureRandom random)
+ throws InvalidKeyException {
+ try {
+ engineInit(opmode, key, (AlgorithmParameterSpec)null, random);
+ } catch (InvalidAlgorithmParameterException e) {
+ throw new InvalidKeyException("init() failed", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key newKey,
+ AlgorithmParameterSpec params, SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ if (newKey == null) {
+ throw new InvalidKeyException("Key cannot be null");
+ }
+ if (opmode != Cipher.ENCRYPT_MODE &&
+ opmode != Cipher.DECRYPT_MODE &&
+ opmode != Cipher.WRAP_MODE &&
+ opmode != Cipher.UNWRAP_MODE) {
+ throw new InvalidAlgorithmParameterException
+ ("Unsupported mode: " + opmode);
+ }
+ if (params != null) {
+ if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
+ throw new InvalidAlgorithmParameterException(
+ "No Parameters can be specified");
+ }
+ spec = params;
+ this.random = random; // for TLS RSA premaster secret
+ }
+ boolean doEncrypt = (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE);
+
+ // Make sure the proper opmode uses the proper key
+ if (doEncrypt && (!(newKey instanceof RSAPublicKey))) {
+ throw new InvalidKeyException("RSAPublicKey required for encryption");
+ } else if (!doEncrypt && (!(newKey instanceof RSAPrivateCrtKey))) {
+ throw new InvalidKeyException("RSAPrivateCrtKey required for decryption");
+ }
+
+ NativeKey nativeKey = null;
+ // Check keyList cache for a nativeKey
+ nativeKey = keyList.get(newKey);
+ if (nativeKey == null) {
+ // With no existing nativeKey for this newKey, create one
+ if (doEncrypt) {
+ RSAPublicKey publicKey = (RSAPublicKey) newKey;
+ try {
+ nativeKey = (NativeKey) keyFactory.engineGeneratePublic
+ (new RSAPublicKeySpec(publicKey.getModulus(), publicKey.getPublicExponent()));
+ } catch (InvalidKeySpecException ikse) {
+ throw new InvalidKeyException(ikse);
+ }
+ } else {
+ RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) newKey;
+ try {
+ nativeKey = (NativeKey) keyFactory.engineGeneratePrivate
+ (new RSAPrivateCrtKeySpec(privateKey.getModulus(),
+ privateKey.getPublicExponent(),
+ privateKey.getPrivateExponent(),
+ privateKey.getPrimeP(),
+ privateKey.getPrimeQ(),
+ privateKey.getPrimeExponentP(),
+ privateKey.getPrimeExponentQ(),
+ privateKey.getCrtCoefficient()));
+ } catch (InvalidKeySpecException ikse) {
+ throw new InvalidKeyException(ikse);
+ }
+ }
+
+ // Add nativeKey to keyList cache and associate it with newKey
+ keyList.put(newKey, nativeKey);
+ }
+
+ init(doEncrypt, nativeKey);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized void engineInit(int opmode, Key key, AlgorithmParameters params,
+ SecureRandom random)
+ throws InvalidKeyException, InvalidAlgorithmParameterException {
+ if (params != null) {
+ throw new InvalidAlgorithmParameterException("No Parameters can be specified");
+ }
+ engineInit(opmode, key, (AlgorithmParameterSpec) null, random);
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
+ if (inLen > 0) {
+ update(in, inOfs, inLen);
+ }
+ return null;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineUpdate(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs) throws ShortBufferException {
+ if (out.length - outOfs < outputSize) {
+ throw new ShortBufferException("Output buffer too small");
+ }
+ if (inLen > 0) {
+ update(in, inOfs, inLen);
+ }
+ return 0;
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineDoFinal(byte[] in, int inOfs, int inLen)
+ throws IllegalBlockSizeException, BadPaddingException {
+ byte[] out = new byte[outputSize];
+ try {
+ // delegate to the other engineDoFinal(...) method
+ int actualLen = engineDoFinal(in, inOfs, inLen, out, 0);
+ if (actualLen != outputSize) {
+ return Arrays.copyOf(out, actualLen);
+ } else {
+ return out;
+ }
+ } catch (ShortBufferException e) {
+ throw new UcryptoException("Internal Error", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized int engineDoFinal(byte[] in, int inOfs, int inLen, byte[] out,
+ int outOfs)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException {
+ if (inLen != 0) {
+ update(in, inOfs, inLen);
+ }
+ return doFinal(out, outOfs, out.length - outOfs);
+ }
+
+
+ // see JCE spec
+ @Override
+ protected synchronized byte[] engineWrap(Key key) throws IllegalBlockSizeException,
+ InvalidKeyException {
+ try {
+ byte[] encodedKey = key.getEncoded();
+ if ((encodedKey == null) || (encodedKey.length == 0)) {
+ throw new InvalidKeyException("Cannot get an encoding of " +
+ "the key to be wrapped");
+ }
+ if (encodedKey.length > buffer.length) {
+ throw new InvalidKeyException("Key is too long for wrapping");
+ }
+ return engineDoFinal(encodedKey, 0, encodedKey.length);
+ } catch (BadPaddingException e) {
+ // Should never happen for key wrapping
+ throw new UcryptoException("Internal Error", e);
+ }
+ }
+
+ // see JCE spec
+ @Override
+ protected synchronized Key engineUnwrap(byte[] wrappedKey,
+ String wrappedKeyAlgorithm, int wrappedKeyType)
+ throws InvalidKeyException, NoSuchAlgorithmException {
+
+ if (wrappedKey.length > buffer.length) {
+ throw new InvalidKeyException("Key is too long for unwrapping");
+ }
+
+ boolean isTlsRsaPremasterSecret =
+ wrappedKeyAlgorithm.equals("TlsRsaPremasterSecret");
+ Exception failover = null;
+
+ byte[] encodedKey = null;
+ try {
+ encodedKey = engineDoFinal(wrappedKey, 0, wrappedKey.length);
+ } catch (BadPaddingException bpe) {
+ if (isTlsRsaPremasterSecret) {
+ failover = bpe;
+ } else {
+ throw new InvalidKeyException("Unwrapping failed", bpe);
+ }
+ } catch (Exception e) {
+ throw new InvalidKeyException("Unwrapping failed", e);
+ }
+
+ if (isTlsRsaPremasterSecret) {
+ if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) {
+ throw new IllegalStateException(
+ "No TlsRsaPremasterSecretParameterSpec specified");
+ }
+
+ // polish the TLS premaster secret
+ encodedKey = KeyUtil.checkTlsPreMasterSecretKey(
+ ((TlsRsaPremasterSecretParameterSpec)spec).getClientVersion(),
+ ((TlsRsaPremasterSecretParameterSpec)spec).getServerVersion(),
+ random, encodedKey, (failover != null));
+ }
+
+ return NativeCipher.constructKey(wrappedKeyType,
+ encodedKey, wrappedKeyAlgorithm);
+ }
+
+ /**
+ * calls ucrypto_encrypt(...) or ucrypto_decrypt(...)
+ * @returns the length of output or an negative error status code
+ */
+ private native static int nativeAtomic(int mech, boolean encrypt,
+ long keyValue, int keyLength,
+ byte[] in, int inLen,
+ byte[] out, int ouOfs, int outLen);
+
+ // do actual initialization
+ private void init(boolean encrypt, NativeKey key) {
+ this.encrypt = encrypt;
+ this.key = key;
+ try {
+ this.outputSize = engineGetKeySize(key)/8;
+ } catch (InvalidKeyException ike) {
+ throw new UcryptoException("Internal Error", ike);
+ }
+ this.buffer = new byte[outputSize];
+ this.bufOfs = 0;
+ }
+
+ // store the specified input into the internal buffer
+ private void update(byte[] in, int inOfs, int inLen) {
+ if ((inLen <= 0) || (in == null)) {
+ return;
+ }
+ // buffer bytes internally until doFinal is called
+ if ((bufOfs + inLen + (encrypt? padLen:0)) > buffer.length) {
+ // lead to IllegalBlockSizeException when doFinal() is called
+ bufOfs = buffer.length + 1;
+ return;
+ }
+ System.arraycopy(in, inOfs, buffer, bufOfs, inLen);
+ bufOfs += inLen;
+ }
+
+ // return the actual non-negative output length
+ private int doFinal(byte[] out, int outOfs, int outLen)
+ throws ShortBufferException, IllegalBlockSizeException,
+ BadPaddingException {
+ if (bufOfs > buffer.length) {
+ throw new IllegalBlockSizeException(
+ "Data must not be longer than " +
+ (buffer.length - (encrypt ? padLen : 0)) + " bytes");
+ }
+ if (outLen < outputSize) {
+ throw new ShortBufferException();
+ }
+ try {
+ long keyValue = key.value();
+ int k = nativeAtomic(mech.value(), encrypt, keyValue,
+ key.length(), buffer, bufOfs,
+ out, outOfs, outLen);
+ if (k < 0) {
+ if ( k == -16 || k == -64) {
+ // -16: CRYPTO_ENCRYPTED_DATA_INVALID
+ // -64: CKR_ENCRYPTED_DATA_INVALID, see bug 17459266
+ UcryptoException ue = new UcryptoException(16);
+ BadPaddingException bpe =
+ new BadPaddingException("Invalid encryption data");
+ bpe.initCause(ue);
+ throw bpe;
+ }
+ throw new UcryptoException(-k);
+ }
+
+ return k;
+ } finally {
+ bufOfs = 0;
+ }
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java
new file mode 100644
index 00000000000..80cc1d9b224
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSAKeyFactory.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Key;
+import java.security.PublicKey;
+import java.security.PrivateKey;
+import java.security.KeyFactorySpi;
+
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.KeySpec;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+/**
+ * Ucrypto-private KeyFactory class for generating native keys
+ * needed for using ucrypto APIs. Given that it's not used
+ * externally, it only needs to support RSAPrivateCrtKeySpec
+ * and RSAPublicKeySpec objects.
+ *
+ * @since 1.9
+ */
+public final class NativeRSAKeyFactory extends KeyFactorySpi {
+
+ @Override
+ protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
+ throws InvalidKeySpecException {
+ return new NativeKey.RSAPrivateCrt(keySpec);
+ }
+
+ @Override
+ protected PublicKey engineGeneratePublic(KeySpec keySpec)
+ throws InvalidKeySpecException {
+ return new NativeKey.RSAPublic(keySpec);
+ }
+
+ @Override
+ protected T
+ engineGetKeySpec(Key key, Class keySpec)
+ throws InvalidKeySpecException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected Key engineTranslateKey(Key key) throws InvalidKeyException {
+ // no need to support this
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java
new file mode 100644
index 00000000000..18f986293b2
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/NativeRSASignature.java
@@ -0,0 +1,445 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.Set;
+import java.util.Arrays;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.lang.ref.*;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+
+import java.security.SignatureSpi;
+import java.security.NoSuchAlgorithmException;
+import java.security.InvalidParameterException;
+import java.security.InvalidKeyException;
+import java.security.SignatureException;
+import java.security.Key;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+
+import java.security.*;
+import java.security.interfaces.*;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.security.spec.InvalidKeySpecException;
+import sun.nio.ch.DirectBuffer;
+import java.nio.ByteBuffer;
+import sun.security.rsa.RSAPadding;
+
+/**
+ * Signature implementation class. This class currently supports the
+ * following algorithms:
+ *
+ * . RSA:
+ * . MD5withRSA
+ * . SHA1withRSA
+ * . SHA256withRSA
+ * . SHA384withRSA
+ * . SHA512withRSA
+ *
+ * @since 1.9
+ */
+class NativeRSASignature extends SignatureSpi {
+
+ private static final int PKCS1PADDING_LEN = 11;
+
+ // fields set in constructor
+ private final UcryptoMech mech;
+ private final int encodedLen;
+
+ // field for ensuring native memory is freed
+ private SignatureContextRef pCtxt = null;
+
+ //
+ // fields (re)set in every init()
+ //
+ private boolean initialized = false;
+ private boolean sign = true;
+ private int sigLength;
+ private NativeKey key;
+ private NativeRSAKeyFactory keyFactory; // may need a more generic type later
+
+ // public implementation classes
+ public static final class MD5 extends NativeRSASignature {
+ public MD5() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_MD5_RSA_PKCS, 34);
+ }
+ }
+
+ public static final class SHA1 extends NativeRSASignature {
+ public SHA1() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_SHA1_RSA_PKCS, 35);
+ }
+ }
+
+ public static final class SHA256 extends NativeRSASignature {
+ public SHA256() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_SHA256_RSA_PKCS, 51);
+ }
+ }
+
+ public static final class SHA384 extends NativeRSASignature {
+ public SHA384() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_SHA384_RSA_PKCS, 67);
+ }
+ }
+
+ public static final class SHA512 extends NativeRSASignature {
+ public SHA512() throws NoSuchAlgorithmException {
+ super(UcryptoMech.CRYPTO_SHA512_RSA_PKCS, 83);
+ }
+ }
+
+ // internal class for native resource cleanup
+ private static class SignatureContextRef extends PhantomReference
+ implements Comparable {
+
+ private static ReferenceQueue refQueue =
+ new ReferenceQueue();
+
+ // Needed to keep these references from being GC'ed until when their
+ // referents are GC'ed so we can do post-mortem processing
+ private static Set refList =
+ new ConcurrentSkipListSet();
+ // Collections.synchronizedSortedSet(new TreeSet());
+
+ private final long id;
+ private final boolean sign;
+
+ private static void drainRefQueueBounded() {
+ while (true) {
+ SignatureContextRef next = (SignatureContextRef) refQueue.poll();
+ if (next == null) break;
+ next.dispose(true);
+ }
+ }
+
+ SignatureContextRef(NativeRSASignature ns, long id, boolean sign) {
+ super(ns, refQueue);
+ this.id = id;
+ this.sign = sign;
+ refList.add(this);
+ UcryptoProvider.debug("Resource: track Signature Ctxt " + this.id);
+ drainRefQueueBounded();
+ }
+
+ public int compareTo(SignatureContextRef other) {
+ if (this.id == other.id) {
+ return 0;
+ } else {
+ return (this.id < other.id) ? -1 : 1;
+ }
+ }
+
+ void dispose(boolean doCancel) {
+ refList.remove(this);
+ try {
+ if (doCancel) {
+ UcryptoProvider.debug("Resource: free Signature Ctxt " + this.id);
+ NativeRSASignature.nativeFinal(id, sign, null, 0, 0);
+ } else {
+ UcryptoProvider.debug("Resource: stop tracking Signature Ctxt " + this.id);
+ }
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
+ NativeRSASignature(UcryptoMech mech, int encodedLen)
+ throws NoSuchAlgorithmException {
+ this.mech = mech;
+ this.encodedLen = encodedLen;
+ this.keyFactory = new NativeRSAKeyFactory();
+ }
+
+ // deprecated but abstract
+ @SuppressWarnings("deprecation")
+ protected Object engineGetParameter(String param) throws InvalidParameterException {
+ throw new UnsupportedOperationException("getParameter() not supported");
+ }
+
+ @Override
+ protected synchronized void engineInitSign(PrivateKey privateKey)
+ throws InvalidKeyException {
+ if (privateKey == null) {
+ throw new InvalidKeyException("Key must not be null");
+ }
+ NativeKey newKey = key;
+ int newSigLength = sigLength;
+ // Need to check RSA key length whenever a new private key is set
+ if (privateKey != key) {
+ if (privateKey instanceof RSAPrivateCrtKey) {
+ RSAPrivateCrtKey rsaPrivKey = (RSAPrivateCrtKey) privateKey;
+ BigInteger mod = rsaPrivKey.getModulus();
+ newSigLength = checkRSAKeyLength(mod);
+ try {
+ newKey = (NativeKey) keyFactory.engineGeneratePrivate
+ (new RSAPrivateCrtKeySpec(mod,
+ rsaPrivKey.getPublicExponent(),
+ rsaPrivKey.getPrivateExponent(),
+ rsaPrivKey.getPrimeP(),
+ rsaPrivKey.getPrimeQ(),
+ rsaPrivKey.getPrimeExponentP(),
+ rsaPrivKey.getPrimeExponentQ(),
+ rsaPrivKey.getCrtCoefficient()));
+ } catch (InvalidKeySpecException ikse) {
+ throw new InvalidKeyException(ikse);
+ }
+ } else {
+ throw new InvalidKeyException("RSAPrivateCrtKey required");
+ }
+ }
+ init(true, newKey, newSigLength);
+ }
+
+
+ @Override
+ protected synchronized void engineInitVerify(PublicKey publicKey)
+ throws InvalidKeyException {
+ if (publicKey == null) {
+ throw new InvalidKeyException("Key must not be null");
+ }
+ NativeKey newKey = key;
+ int newSigLength = sigLength;
+ // Need to check RSA key length whenever a new public key is set
+ if (publicKey != key) {
+ if (publicKey instanceof RSAPublicKey) {
+ BigInteger mod = ((RSAPublicKey) publicKey).getModulus();
+ newSigLength = checkRSAKeyLength(mod);
+ try {
+ newKey = (NativeKey) keyFactory.engineGeneratePublic
+ (new RSAPublicKeySpec(mod, ((RSAPublicKey) publicKey).getPublicExponent()));
+ } catch (InvalidKeySpecException ikse) {
+ throw new InvalidKeyException(ikse);
+ }
+ } else {
+ throw new InvalidKeyException("RSAPublicKey required");
+ }
+ }
+ init(false, newKey, newSigLength);
+ }
+
+ // deprecated but abstract
+ @SuppressWarnings("deprecation")
+ protected void engineSetParameter(String param, Object value) throws InvalidParameterException {
+ throw new UnsupportedOperationException("setParameter() not supported");
+ }
+
+ @Override
+ protected synchronized byte[] engineSign() throws SignatureException {
+ byte[] sig = new byte[sigLength];
+ int rv = doFinal(sig, 0, sigLength);
+ if (rv < 0) {
+ throw new SignatureException(new UcryptoException(-rv));
+ }
+ return sig;
+ }
+
+ @Override
+ protected synchronized int engineSign(byte[] outbuf, int offset, int len)
+ throws SignatureException {
+ if (outbuf == null || (offset < 0) || (outbuf.length < (offset + sigLength))
+ || (len < sigLength)) {
+ throw new SignatureException("Invalid output buffer");
+ }
+ int rv = doFinal(outbuf, offset, sigLength);
+ if (rv < 0) {
+ throw new SignatureException(new UcryptoException(-rv));
+ }
+ return sigLength;
+ }
+
+ @Override
+ protected synchronized void engineUpdate(byte b) throws SignatureException {
+ byte[] in = { b };
+ int rv = update(in, 0, 1);
+ if (rv < 0) {
+ throw new SignatureException(new UcryptoException(-rv));
+ }
+ }
+
+ @Override
+ protected synchronized void engineUpdate(byte[] in, int inOfs, int inLen)
+ throws SignatureException {
+ if (in == null || inOfs < 0 || inLen == 0) return;
+
+ int rv = update(in, inOfs, inLen);
+ if (rv < 0) {
+ throw new SignatureException(new UcryptoException(-rv));
+ }
+ }
+
+ @Override
+ protected synchronized void engineUpdate(ByteBuffer in) {
+ if (in == null || in.remaining() == 0) return;
+
+ if (in instanceof DirectBuffer == false) {
+ // cannot do better than default impl
+ super.engineUpdate(in);
+ return;
+ }
+ long inAddr = ((DirectBuffer)in).address();
+ int inOfs = in.position();
+ int inLen = in.remaining();
+
+ int rv = update((inAddr + inOfs), inLen);
+ if (rv < 0) {
+ throw new UcryptoException(-rv);
+ }
+ in.position(inOfs + inLen);
+ }
+
+ @Override
+ protected synchronized boolean engineVerify(byte[] sigBytes) throws SignatureException {
+ return engineVerify(sigBytes, 0, sigBytes.length);
+ }
+
+ @Override
+ protected synchronized boolean engineVerify(byte[] sigBytes, int sigOfs, int sigLen)
+ throws SignatureException {
+ if (sigBytes == null || (sigOfs < 0) || (sigBytes.length < (sigOfs + this.sigLength))
+ || (sigLen < this.sigLength)) {
+ throw new SignatureException("Invalid signature buffer");
+ }
+
+ int rv = doFinal(sigBytes, sigOfs, sigLen);
+ if (rv == 0) {
+ return true;
+ } else {
+ UcryptoProvider.debug("Signature: " + mech + " verification error " +
+ new UcryptoException(-rv).getMessage());
+ return false;
+ }
+ }
+
+ void reset(boolean doCancel) {
+ initialized = false;
+ if (pCtxt != null) {
+ pCtxt.dispose(doCancel);
+ pCtxt = null;
+ }
+ }
+
+ /**
+ * calls ucrypto_sign_init(...) or ucrypto_verify_init(...)
+ * @return pointer to the context
+ */
+ private native static long nativeInit(int mech, boolean sign,
+ long keyValue, int keyLength);
+
+ /**
+ * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
+ * @returns an error status code (0 means SUCCESS)
+ */
+ private native static int nativeUpdate(long pContext, boolean sign,
+ byte[] in, int inOfs, int inLen);
+ /**
+ * calls ucrypto_sign_update(...) or ucrypto_verify_update(...)
+ * @returns an error status code (0 means SUCCESS)
+ */
+ private native static int nativeUpdate(long pContext, boolean sign,
+ long pIn, int inLen);
+
+ /**
+ * calls ucrypto_sign_final(...) or ucrypto_verify_final(...)
+ * @returns the length of signature bytes or verification status.
+ * If negative, it indicates an error status code
+ */
+ private native static int nativeFinal(long pContext, boolean sign,
+ byte[] sig, int sigOfs, int sigLen);
+
+ // actual init() implementation - caller should clone key if needed
+ private void init(boolean sign, NativeKey key, int sigLength) {
+ reset(true);
+ this.sign = sign;
+ this.sigLength = sigLength;
+ this.key = key;
+ long pCtxtVal = nativeInit(mech.value(), sign, key.value(),
+ key.length());
+ initialized = (pCtxtVal != 0L);
+ if (initialized) {
+ pCtxt = new SignatureContextRef(this, pCtxtVal, sign);
+ } else {
+ throw new UcryptoException("Cannot initialize Signature");
+ }
+ }
+
+ private void ensureInitialized() {
+ if (!initialized) {
+ init(sign, key, sigLength);
+ if (!initialized) {
+ throw new UcryptoException("Cannot initialize Signature");
+ }
+ }
+ }
+
+ // returns 0 (success) or negative (ucrypto error occurred)
+ private int update(byte[] in, int inOfs, int inLen) {
+ if (inOfs < 0 || inOfs + inLen > in.length) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ ensureInitialized();
+ int k = nativeUpdate(pCtxt.id, sign, in, inOfs, inLen);
+ if (k < 0) {
+ reset(false);
+ }
+ return k;
+ }
+
+ // returns 0 (success) or negative (ucrypto error occurred)
+ private int update(long pIn, int inLen) {
+ ensureInitialized();
+ int k = nativeUpdate(pCtxt.id, sign, pIn, inLen);
+ if (k < 0) {
+ reset(false);
+ }
+ return k;
+ }
+
+ // returns 0 (success) or negative (ucrypto error occurred)
+ private int doFinal(byte[] sigBytes, int sigOfs, int sigLen) {
+ try {
+ ensureInitialized();
+ int k = nativeFinal(pCtxt.id, sign, sigBytes, sigOfs, sigLen);
+ return k;
+ } finally {
+ reset(false);
+ }
+ }
+
+ // check and return RSA key size in number of bytes
+ private int checkRSAKeyLength(BigInteger mod) throws InvalidKeyException {
+ int keySize = (mod.bitLength() + 7) >> 3;
+ int maxDataSize = keySize - PKCS1PADDING_LEN;
+ if (maxDataSize < encodedLen) {
+ throw new InvalidKeyException
+ ("Key is too short for this signature algorithm");
+ }
+ return keySize;
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java
new file mode 100644
index 00000000000..1e09a48d5ee
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.*;
+import java.security.ProviderException;
+
+/**
+ * The exception class used by SunUcrypto provider. An exception
+ * object of this class indicates that a function call to the underlying
+ * native calls returned a value not equal to CRYPTO_SUCCESS.
+ *
+ * @since 1.9
+ */
+public final class UcryptoException extends ProviderException {
+
+ private static final long serialVersionUID = -933864511110035746L;
+
+ // NOTE: check /usr/include/sys/crypto/common.h for updates
+ private static final String ERROR_MSG[] = {
+ "CRYPTO_SUCCESS",
+ "CRYPTO_CANCEL",
+ "CRYPTO_HOST_MEMORY",
+ "CRYPTO_GENERAL_ERROR",
+ "CRYPTO_FAILED",
+ "CRYPTO_ARGUMENTS_BAD",
+ "CRYPTO_ATTRIBUTE_READ_ONLY",
+ "CRYPTO_ATTRIBUTE_SENSITIVE",
+ "CRYPTO_ATTRIBUTE_TYPE_INVALID",
+ "CRYPTO_ATTRIBUTE_VALUE_INVALID",
+ "CRYPTO_CANCELED",
+ "CRYPTO_DATA_INVALID",
+ "CRYPTO_DATA_LEN_RANGE",
+ "CRYPTO_DEVICE_ERROR",
+ "CRYPTO_DEVICE_MEMORY",
+ "CRYPTO_DEVICE_REMOVED",
+ "CRYPTO_ENCRYPTED_DATA_INVALID",
+ "CRYPTO_ENCRYPTED_DATA_LEN_RANGE",
+ "CRYPTO_KEY_HANDLE_INVALID",
+ "CRYPTO_KEY_SIZE_RANGE",
+ "CRYPTO_KEY_TYPE_INCONSISTENT",
+ "CRYPTO_KEY_NOT_NEEDED",
+ "CRYPTO_KEY_CHANGED",
+ "CRYPTO_KEY_NEEDED",
+ "CRYPTO_KEY_INDIGESTIBLE",
+ "CRYPTO_KEY_FUNCTION_NOT_PERMITTED",
+ "CRYPTO_KEY_NOT_WRAPPABLE",
+ "CRYPTO_KEY_UNEXTRACTABLE",
+ "CRYPTO_MECHANISM_INVALID",
+ "CRYPTO_MECHANISM_PARAM_INVALID",
+ "CRYPTO_OBJECT_HANDLE_INVALID",
+ "CRYPTO_OPERATION_IS_ACTIVE",
+ "CRYPTO_OPERATION_NOT_INITIALIZED",
+ "CRYPTO_PIN_INCORRECT",
+ "CRYPTO_PIN_INVALID",
+ "CRYPTO_PIN_LEN_RANGE",
+ "CRYPTO_PIN_EXPIRED",
+ "CRYPTO_PIN_LOCKED",
+ "CRYPTO_SESSION_CLOSED",
+ "CRYPTO_SESSION_COUNT",
+ "CRYPTO_SESSION_HANDLE_INVALID",
+ "CRYPTO_SESSION_READ_ONLY",
+ "CRYPTO_SESSION_EXISTS",
+ "CRYPTO_SESSION_READ_ONLY_EXISTS",
+ "CRYPTO_SESSION_READ_WRITE_SO_EXISTS",
+ "CRYPTO_SIGNATURE_INVALID",
+ "CRYPTO_SIGNATURE_LEN_RANGE",
+ "CRYPTO_TEMPLATE_INCOMPLETE",
+ "CRYPTO_TEMPLATE_INCONSISTENT",
+ "CRYPTO_UNWRAPPING_KEY_HANDLE_INVALID",
+ "CRYPTO_UNWRAPPING_KEY_SIZE_RANGE",
+ "CRYPTO_UNWRAPPING_KEY_TYPE_INCONSISTENT",
+ "CRYPTO_USER_ALREADY_LOGGED_IN",
+ "CRYPTO_USER_NOT_LOGGED_IN",
+ "CRYPTO_USER_PIN_NOT_INITIALIZED",
+ "CRYPTO_USER_TYPE_INVALID",
+ "CRYPTO_USER_ANOTHER_ALREADY_LOGGED_IN",
+ "CRYPTO_USER_TOO_MANY_TYPES",
+ "CRYPTO_WRAPPED_KEY_INVALID",
+ "CRYPTO_WRAPPED_KEY_LEN_RANGE",
+ "CRYPTO_WRAPPING_KEY_HANDLE_INVALID",
+ "CRYPTO_WRAPPING_KEY_SIZE_RANGE",
+ "CRYPTO_WRAPPING_KEY_TYPE_INCONSISTENT",
+ "CRYPTO_RANDOM_SEED_NOT_SUPPORTED",
+ "CRYPTO_RANDOM_NO_RNG",
+ "CRYPTO_DOMAIN_PARAMS_INVALID",
+ "CRYPTO_BUFFER_TOO_SMALL",
+ "CRYPTO_INFORMATION_SENSITIVE",
+ "CRYPTO_NOT_SUPPORTED",
+ "CRYPTO_QUEUED",
+ "CRYPTO_BUFFER_TOO_BIG",
+ "CRYPTO_INVALID_CONTEXT",
+ "CRYPTO_INVALID_MAC",
+ "CRYPTO_MECH_NOT_SUPPORTED",
+ "CRYPTO_INCONSISTENT_ATTRIBUTE",
+ "CRYPTO_NO_PERMISSION",
+ "CRYPTO_INVALID_PROVIDER_ID",
+ "CRYPTO_VERSION_MISMATCH",
+ "CRYPTO_BUSY",
+ "CRYPTO_UNKNOWN_PROVIDER",
+ "CRYPTO_MODVERIFICATION_FAILED",
+ "CRYPTO_OLD_CTX_TEMPLATE",
+ "CRYPTO_WEAK_KEY",
+ "CRYPTO_FIPS140_ERROR"
+ };
+
+ /**
+ * The error code if this exception is triggered by a Ucrypto error.
+ */
+ private final int errorCode;
+
+ /**
+ * This method gets the corresponding text error message from a
+ * predefined mapping. If mapping is not found, then it returns the error
+ * code as a hex-string.
+ *
+ * @return The message or the error code; e.g. "CRYPTO_DATA_INVALID" or
+ * "0x88".
+ */
+ static String getErrorMessage(int errorCode) {
+ String message;
+ if (errorCode < ERROR_MSG.length) {
+ message = ERROR_MSG[errorCode];
+ } else {
+ message = "0x" + Integer.toHexString(errorCode);
+ }
+ return message;
+ }
+
+ /**
+ * Constructor taking the error code as defined for the CRYPTO_* constants
+ */
+ public UcryptoException(int rv) {
+ super(getErrorMessage(rv));
+ this.errorCode = rv;
+ }
+
+ public UcryptoException(String message) {
+ super(message);
+ errorCode = -1;
+ }
+
+ public UcryptoException(String message, Throwable cause) {
+ super(message, cause);
+ errorCode = -1;
+ }
+
+ /**
+ * Returns the Ucrypto error code.
+ *
+ * @return The error code.
+ */
+ public int getErrorCode() {
+ return errorCode;
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java
new file mode 100644
index 00000000000..91f95c0827f
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoMech.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.util.HashMap;
+
+/**
+ * Enum for representing the ucrypto mechanisms.
+ *
+ * @since 1.9
+ */
+// Check /usr/include/libsoftcrypto.h for updates
+public enum UcryptoMech {
+ CRYPTO_AES_ECB(1, new String[]
+ { "Cipher.AES/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesEcbNoPadding",
+ "Cipher.AES/ECB/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesEcbPKCS5",
+ "Cipher.AES_128/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes128EcbNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1;AES_128/ECB/NoPadding",
+ "Cipher.AES_192/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes192EcbNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21;AES_192/ECB/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21;AES_192/ECB/NoPadding",
+ "Cipher.AES_256/ECB/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes256EcbNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41;AES_256/ECB/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41;AES_256/ECB/NoPadding"
+ }),
+ CRYPTO_AES_CBC(2, new String[]
+ { "Cipher.AES/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCbcNoPadding",
+ "Cipher.AES/CBC/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCbcPKCS5",
+ "Cipher.AES_128/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes128CbcNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2;AES_128/CBC/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2;AES_128/CBC/NoPadding",
+ "Cipher.AES_192/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes192CbcNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22;AES_192/CBC/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22;AES_192/CBC/NoPadding",
+ "Cipher.AES_256/CBC/NoPadding;com.oracle.security.ucrypto.NativeCipher$Aes256CbcNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42;AES_256/CBC/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42;AES_256/CBC/NoPadding"
+ }),
+ CRYPTO_AES_CBC_PAD(3, null), // No support from Solaris yet
+ CRYPTO_AES_CTR(4, new String[]
+ { "Cipher.AES/CTR/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCtrNoPadding" }),
+ CRYPTO_AES_CCM(5, null), // Cannot support due to lack of Java API which corresponds to CK_AES_CCM_PARAMS
+ CRYPTO_AES_GCM(6, new String[]
+ { "Cipher.AES/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$AesGcmNoPadding",
+ "Cipher.AES_128/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes128GcmNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.6;AES_128/GCM/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.6;AES_128/GCM/NoPadding",
+ "Cipher.AES_192/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes192GcmNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.26;AES_192/GCM/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.26;AES_192/GCM/NoPadding",
+ "Cipher.AES_256/GCM/NoPadding;com.oracle.security.ucrypto.NativeGCMCipher$Aes256GcmNoPadding",
+ "Alg.Alias.Cipher.2.16.840.1.101.3.4.1.46;AES_256/GCM/NoPadding",
+ "Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.46;AES_256/GCM/NoPadding",
+ }),
+ CRYPTO_AES_GMAC(7, null), // No support from Solaris yet
+ CRYPTO_AES_CFB128(8, new String[]
+ { "Cipher.AES/CFB128/NoPadding;com.oracle.security.ucrypto.NativeCipher$AesCfb128NoPadding",
+ "Cipher.AES/CFB128/PKCS5Padding;com.oracle.security.ucrypto.NativeCipherWithJavaPadding$AesCfb128PKCS5" }),
+ CRYPTO_RSA_PKCS(31, new String[]
+ { "Cipher.RSA/ECB/PKCS1Padding;com.oracle.security.ucrypto.NativeRSACipher$PKCS1Padding" }),
+ CRYPTO_RSA_X_509(32, new String[]
+ { "Cipher.RSA/ECB/NoPadding;com.oracle.security.ucrypto.NativeRSACipher$NoPadding" }),
+ CRYPTO_MD5_RSA_PKCS(33, new String[]
+ { "Signature.MD5withRSA;com.oracle.security.ucrypto.NativeRSASignature$MD5",
+ "Alg.Alias.Signature.1.2.840.113549.1.1.4;MD5withRSA",
+ "Alg.Alias.Signature.OID.1.2.840.113549.1.1.4;MD5withRSA" }),
+ CRYPTO_SHA1_RSA_PKCS(34, new String[]
+ { "Signature.SHA1withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA1",
+ "Alg.Alias.Signature.1.2.840.113549.1.1.5;SHA1withRSA",
+ "Alg.Alias.Signature.OID.1.2.840.113549.1.1.5;SHA1withRSA",
+ "Alg.Alias.Signature.1.3.14.3.2.29;SHA1withRSA" }),
+ CRYPTO_SHA256_RSA_PKCS(35, new String[]
+ { "Signature.SHA256withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA256",
+ "Alg.Alias.Signature.1.2.840.113549.1.1.11;SHA256withRSA",
+ "Alg.Alias.Signature.OID.1.2.840.113549.1.1.11;SHA256withRSA" }),
+ CRYPTO_SHA384_RSA_PKCS(36, new String[]
+ { "Signature.SHA384withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA384",
+ "Alg.Alias.Signature.1.2.840.113549.1.1.12;SHA384withRSA",
+ "Alg.Alias.Signature.OID.1.2.840.113549.1.1.12;SHA384withRSA" }),
+ CRYPTO_SHA512_RSA_PKCS(37, new String[]
+ { "Signature.SHA512withRSA;com.oracle.security.ucrypto.NativeRSASignature$SHA512",
+ "Alg.Alias.Signature.1.2.840.113549.1.1.13;SHA512withRSA",
+ "Alg.Alias.Signature.OID.1.2.840.113549.1.1.13;SHA512withRSA" });
+
+ private int mech;
+ private String[] jceProps;
+
+ UcryptoMech(int mech, String[] jceProps) {
+ this.mech = mech;
+ this.jceProps = jceProps;
+ }
+
+ public int value() { return mech; }
+ public String[] jceProperties() { return jceProps; }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java
new file mode 100644
index 00000000000..d6aeb139556
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoProvider.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.security.ucrypto;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+import java.security.*;
+import sun.security.action.PutAllAction;
+import sun.security.action.GetPropertyAction;
+
+/**
+ * OracleUcrypto provider main class.
+ *
+ * @since 1.9
+ */
+public final class UcryptoProvider extends Provider {
+
+ private static final long serialVersionUID = 351251234302833L;
+
+ private static boolean DEBUG;
+ private static HashMap provProp;
+
+ static {
+ try {
+ DEBUG = Boolean.parseBoolean(AccessController.doPrivileged
+ (new GetPropertyAction("com.oracle.security.ucrypto.debug")));
+
+ // cannot use LoadLibraryAction because that would make the native
+ // library available to the bootclassloader, but we run in the
+ // extension classloader.
+ provProp = AccessController.doPrivileged
+ (new PrivilegedAction>() {
+ public HashMap run() {
+ try {
+ System.loadLibrary("j2ucrypto");
+ String osname = System.getProperty("os.name");
+ if (osname.startsWith("SunOS")) {
+ return new HashMap();
+ } else return null;
+ } catch (Error err) {
+ return null;
+ } catch (SecurityException se) {
+ return null;
+ }
+ }
+ });
+ if (provProp != null) {
+ boolean[] result = loadLibraries();
+ if (result.length == 2) {
+ if (result[0]) { // successfully loaded libmd
+ provProp.put("MessageDigest.MD5",
+ "com.oracle.security.ucrypto.NativeDigest$MD5");
+ provProp.put("MessageDigest.SHA",
+ "com.oracle.security.ucrypto.NativeDigest$SHA1");
+ provProp.put("Alg.Alias.MessageDigest.SHA-1", "SHA");
+ provProp.put("Alg.Alias.MessageDigest.SHA1", "SHA");
+ provProp.put("MessageDigest.SHA-256",
+ "com.oracle.security.ucrypto.NativeDigest$SHA256");
+ provProp.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.1", "SHA-256");
+ provProp.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.1", "SHA-256");
+
+ provProp.put("MessageDigest.SHA-384",
+ "com.oracle.security.ucrypto.NativeDigest$SHA384");
+ provProp.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.2", "SHA-384");
+ provProp.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.2", "SHA-384");
+
+ provProp.put("MessageDigest.SHA-512",
+ "com.oracle.security.ucrypto.NativeDigest$SHA512");
+ provProp.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512");
+ provProp.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.3", "SHA-512");
+
+ }
+ if (result[1]) { // successfully loaded libsoftcrypto
+ String supportedMechs = getMechList();
+ debug("Prov: supported mechs = " + supportedMechs);
+ for (UcryptoMech m : UcryptoMech.values()) {
+ if (supportedMechs.indexOf(m.name() + ",") != -1) {
+ String[] jceProps = m.jceProperties();
+ // skip unsupported UcryptoMech
+ if (jceProps == null) continue;
+ for (int p = 0; p < jceProps.length; p++) {
+ StringTokenizer st =
+ new StringTokenizer(jceProps[p], ";");
+ if (st.countTokens() != 2) {
+ throw new RuntimeException("Wrong format: " + jceProps[p]);
+ }
+ provProp.put(st.nextToken(), st.nextToken());
+ }
+ }
+ }
+ // NOTE: GCM support is only available since jdk 7
+ provProp.put("AlgorithmParameters.GCM",
+ "com.oracle.security.ucrypto.GCMParameters");
+ }
+ } else {
+ debug("Prov: unexpected ucrypto library loading error, got " + result.length);
+ }
+ }
+ } catch (AccessControlException ace) {
+ // disable Ucrypto provider
+ DEBUG = false;
+ provProp = null;
+ }
+ }
+
+ static Provider provider = null;
+ private static native boolean[] loadLibraries();
+ private static native String getMechList();
+
+ static void debug(String msg) {
+ if (DEBUG) {
+ System.out.println("UCrypto/" + msg);
+ }
+ }
+
+ public UcryptoProvider() {
+ super("OracleUcrypto", 1.9d, "Provider using Oracle Ucrypto API");
+ if (provProp != null) {
+ AccessController.doPrivileged(new PutAllAction(this, provProp));
+ }
+ if (provider == null) provider = this;
+ }
+
+ public UcryptoProvider(String configName) {
+ super("OracleUcrypto", 1.9d, "Provider using Oracle Ucrypto API");
+ try {
+ if (provProp != null) {
+ HashMap customProvProp =
+ new HashMap(provProp);
+ Config c = new Config(configName);
+ String[] disabledServices = c.getDisabledServices();
+ for (int i = 0; i < disabledServices.length; i++) {
+ if (customProvProp.remove(disabledServices[i]) != null) {
+ debug("Prov: remove config-disabled service " + disabledServices[i]);
+ } else {
+ debug("Prov: ignore unsupported config-disabled service " +
+ disabledServices[i]);
+ }
+ }
+ AccessController.doPrivileged(new PutAllAction(this, customProvProp));
+ }
+ } catch (IOException ioe) { // thrown by Config
+ throw new UcryptoException("Error parsing Config", ioe);
+ }
+ if (provider == null) provider = this;
+ }
+
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/conf/security/ucrypto-solaris.cfg b/jdk/src/jdk.crypto.ucrypto/solaris/conf/security/ucrypto-solaris.cfg
new file mode 100644
index 00000000000..5ccefad1369
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/conf/security/ucrypto-solaris.cfg
@@ -0,0 +1,9 @@
+#
+# Configuration file for the OracleUcrypto provider
+#
+disabledServices = {
+ # disabled due to Solaris bug 7121679
+ Cipher.AES/CFB128/PKCS5Padding
+ Cipher.AES/CFB128/NoPadding
+}
+
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c
new file mode 100644
index 00000000000..ddb8f0b4404
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.c
@@ -0,0 +1,1250 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "nativeCrypto.h"
+#include "nativeFunc.h"
+
+/*
+ * Dumps out byte array in hex with and name and length info
+ */
+void printBytes(char* header, unsigned char* bytes, int len) {
+ int i;
+
+ printf("%s", header);
+ printf("len=%d {", len);
+ for (i = 0; i < len; i++) {
+ if (i > 0) printf(":");
+ printf("%02X", bytes[i]);
+ }
+ printf("}\n");
+}
+
+/*
+ * Throws java.lang.OutOfMemoryError
+ */
+void throwOutOfMemoryError(JNIEnv *env, const char *msg)
+{
+ jclass jExClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
+ if (jExClass != 0) /* Otherwise an exception has already been thrown */ {
+ (*env)->ThrowNew(env, jExClass, msg);
+ }
+ /* free the local ref */
+ (*env)->DeleteLocalRef(env, jExClass);
+}
+
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
+ return JNI_VERSION_1_4;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_UcryptoProvider
+ * Method: loadLibraries
+ * Signature: ()[Z
+ */
+JNIEXPORT jbooleanArray JNICALL Java_com_oracle_security_ucrypto_UcryptoProvider_loadLibraries
+(JNIEnv *env, jclass jcls) {
+ jbooleanArray jResult;
+ jboolean *result;
+ jResult = (*env)->NewBooleanArray(env, 2);
+
+ if (jResult != NULL) {
+ result = loadNative();
+ (*env)->SetBooleanArrayRegion(env, jResult, 0, 2, result);
+ free(result);
+ }
+ return jResult;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_UcryptoProvider
+ * Method: getMechList
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_oracle_security_ucrypto_UcryptoProvider_getMechList
+(JNIEnv *env, jclass jcls) {
+ jstring jResult;
+ char* result;
+ int length;
+
+ jResult = NULL;
+ if (ftab->ucryptoVersion != NULL && ftab->ucryptoGetMechList != NULL) {
+ length = (*ftab->ucryptoGetMechList)(NULL);
+ if (DEBUG) printf("mech list length: %d\n", length);
+ result = malloc(length);
+ if (result == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return NULL;
+ }
+ length = (*ftab->ucryptoGetMechList)(result);
+ if (DEBUG) printf("mech list: %s\n", result);
+ jResult = (*env)->NewStringUTF(env, result);
+ free(result);
+ } else {
+ // version 0 on Solaris 10
+ result = "CRYPTO_AES_ECB,CRYPTO_AES_CBC,CRYPTO_AES_CFB128,";
+ jResult = (*env)->NewStringUTF(env, result);
+ }
+ return jResult;
+}
+
+/*
+ * Utility function for throwing a UcryptoException when rv is not CRYPTO_OK(0)
+ */
+void throwUCExceptionUsingRV(JNIEnv *env, int rv) {
+ jclass jExClass;
+ jmethodID jConstructor;
+ jthrowable jException;
+
+ if ((*env)->ExceptionCheck(env)) return;
+
+ jExClass = (*env)->FindClass(env, "com/oracle/security/ucrypto/UcryptoException");
+ /* if jExClass is NULL, an exception has already been thrown */
+ if (jExClass != NULL) {
+ jConstructor = (*env)->GetMethodID(env, jExClass, "", "(I)V");
+ if (jConstructor != NULL) {
+ jException = (jthrowable) (*env)->NewObject(env, jExClass, jConstructor, rv);
+ if (jException != NULL) {
+ (*env)->Throw(env, jException);
+ }
+ }
+ }
+ /* free the local ref */
+ (*env)->DeleteLocalRef(env, jExClass);
+}
+
+/*
+ * Utility function for duplicating a byte array from jbyteArray
+ * If anything went wrong, no memory will be allocated.
+ * NOTE: caller is responsible for freeing the allocated memory
+ * once this method returned successfully.
+ */
+jbyte* getBytes(JNIEnv *env, jbyteArray bytes, int offset, int len) {
+ jbyte* result = NULL;
+
+ if (!(*env)->ExceptionCheck(env)) {
+ result = (jbyte*) calloc(len, sizeof(char));
+ if (result == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return NULL;
+ }
+ (*env)->GetByteArrayRegion(env, bytes, offset, len, result);
+ if ((*env)->ExceptionCheck(env)) {
+ // free allocated memory if error occurred
+ free(result);
+ return NULL;
+ }
+ }
+ return result;
+}
+
+
+int
+CipherInit(crypto_ctx_t *context, int encrypt, ucrypto_mech_t mech,
+ unsigned char *jKey, int jKeyLen, unsigned char *jIv, int jIvLen,
+ int tagLen, unsigned char *jAad, int jAadLen)
+
+{
+ int rv = 0;
+ void *iv;
+ size_t ivLen;
+
+ if (DEBUG) printf("CipherInit: mech %i, key %i(%i), iv %i(%i) tagLen %i, aad %i(%i)\n",
+ mech, jKey, jKeyLen, jIv, jIvLen, tagLen, jAad, jAadLen);
+ if (mech == CRYPTO_AES_CTR) {
+ ivLen = sizeof(CK_AES_CTR_PARAMS);
+ iv = (CK_AES_CTR_PARAMS*) malloc(ivLen);
+ if (iv == NULL) return -1;
+
+ ((CK_AES_CTR_PARAMS*)iv)->ulCounterBits = 32;
+ memcpy(((CK_AES_CTR_PARAMS*)iv)->cb, jIv, 16);
+ } else if (mech == CRYPTO_AES_GCM) {
+ ivLen = sizeof(CK_AES_GCM_PARAMS);
+ iv = (CK_AES_GCM_PARAMS*) malloc(ivLen);
+ if (iv == NULL) return -1;
+
+ ((CK_AES_GCM_PARAMS*)iv)->pIv = (uchar_t *)jIv;
+ ((CK_AES_GCM_PARAMS*)iv)->ulIvLen = (ulong_t)jIvLen;
+ ((CK_AES_GCM_PARAMS*)iv)->ulIvBits = 96;
+ ((CK_AES_GCM_PARAMS*)iv)->pAAD = (uchar_t *)jAad;
+ ((CK_AES_GCM_PARAMS*)iv)->ulAADLen = (ulong_t)jAadLen;
+ ((CK_AES_GCM_PARAMS*)iv)->ulTagBits = (ulong_t)tagLen;
+ } else {
+ // normal bytes
+ iv = jIv;
+ ivLen = jIvLen;
+ }
+ if (encrypt) {
+ rv = (*ftab->ucryptoEncryptInit)(context, mech, jKey, (size_t)jKeyLen, iv, ivLen);
+ if (rv != 0 && DEBUG) printf("ucryptoEncryptInit: ret = 0x%x\n", rv);
+ } else {
+ rv =(*ftab->ucryptoDecryptInit)(context, mech, jKey, (size_t)jKeyLen, iv, ivLen);
+ if (rv != 0 && DEBUG) printf("ucryptoDecryptInit: ret = 0x%x\n", rv);
+ }
+
+ if (iv != jIv) {
+ if (mech == CRYPTO_AES_CTR) {
+ free((CK_AES_CTR_PARAMS*)iv);
+ } else {
+ free((CK_AES_GCM_PARAMS*)iv);
+ }
+ }
+
+ return rv;
+}
+
+int
+CipherUpdate(crypto_ctx_t *context, int encrypt, unsigned char *bufIn, int inOfs,
+ int inLen, unsigned char *bufOut, int outOfs, int *outLen)
+{
+ int rv = 0;
+ size_t outLength;
+
+ outLength = (size_t) *outLen;
+ if (DEBUG) {
+ printf("CipherUpdate: Inofs %i, InLen %i, OutOfs %i, OutLen %i\n", inOfs, inLen, outOfs, *outLen);
+ printBytes("BufIn=", (unsigned char*)(bufIn+inOfs), inLen);
+ }
+ if (encrypt) {
+ rv = (*ftab->ucryptoEncryptUpdate)(context, (unsigned char*)(bufIn+inOfs), (size_t)inLen, (unsigned char*)(bufOut+outOfs), &outLength);
+ if (rv != 0) {
+ if (DEBUG) printf("ucryptoEncryptUpdate: ret = 0x%x\n", rv);
+ } else {
+ *outLen = (int)outLength;
+ }
+ } else {
+ rv = (*ftab->ucryptoDecryptUpdate)(context, (unsigned char*)(bufIn+inOfs), (size_t)inLen, (unsigned char*)(bufOut+outOfs), &outLength);
+ if (rv != 0) {
+ if (DEBUG) printf("ucryptoDecryptUpdate: ret = 0x%x\n", rv);
+ } else {
+ if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+ *outLen = (int)outLength;
+ }
+ }
+
+ return rv;
+}
+
+int
+CipherFinal(crypto_ctx_t *context, int encrypt, unsigned char *bufOut, int outOfs, int *outLen)
+{
+ int rv = 0;
+ size_t outLength;
+
+ outLength = (size_t)*outLen;
+
+ if (DEBUG) printf("CipherFinal: OutOfs %i, outLen %i\n", outOfs, *outLen);
+ if (encrypt) {
+ rv = (*ftab->ucryptoEncryptFinal)(context, (unsigned char*)(bufOut+outOfs), &outLength);
+ if (rv != 0) {
+ if (DEBUG) printf("ucryptoDecryptFinal: ret = 0x%x\n", rv);
+ } else {
+ if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+ *outLen = (int)outLength;
+ }
+ } else {
+ rv = (*ftab->ucryptoDecryptFinal)(context, (unsigned char*)(bufOut+outOfs), &outLength);
+ if (rv != 0) {
+ if (DEBUG) printf("ucryptoDecryptFinal: ret = 0x%x\n", rv);
+ } else {
+ if (DEBUG) printBytes("BufOut=", (unsigned char*)(bufOut+outOfs), outLength);
+ *outLen = (int)outLength;
+ }
+ }
+ return rv;
+}
+
+////////////////////////////////////////////////////////
+// SPECIAL ENTRIES FOR JVM JNI-BYPASSING OPTIMIZATION
+////////////////////////////////////////////////////////
+jlong JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeInit(jint mech) {
+ void *pContext = NULL;
+
+ switch (mech) {
+ case com_oracle_security_ucrypto_NativeDigest_MECH_SHA1:
+ pContext = (SHA1_CTX *) malloc(sizeof(SHA1_CTX));
+ if (pContext != NULL) {
+ (*ftab->sha1Init)((SHA1_CTX *)pContext);
+ }
+ break;
+ case com_oracle_security_ucrypto_NativeDigest_MECH_MD5:
+ pContext = (MD5_CTX *) malloc(sizeof(MD5_CTX));
+ if (pContext != NULL) {
+ (*ftab->md5Init)((MD5_CTX *)pContext);
+ }
+ break;
+ case com_oracle_security_ucrypto_NativeDigest_MECH_SHA256:
+ pContext = (SHA2_CTX *) malloc(sizeof(SHA2_CTX));
+ if (pContext != NULL) {
+ (*ftab->sha2Init)(SHA256, (SHA2_CTX *)pContext);
+ }
+ break;
+ case com_oracle_security_ucrypto_NativeDigest_MECH_SHA384:
+ pContext = (SHA2_CTX *) malloc(sizeof(SHA2_CTX));
+ if (pContext != NULL) {
+ (*ftab->sha2Init)(SHA384, (SHA2_CTX *)pContext);
+ }
+ break;
+ case com_oracle_security_ucrypto_NativeDigest_MECH_SHA512:
+ pContext = (SHA2_CTX *) malloc(sizeof(SHA2_CTX));
+ if (pContext != NULL) {
+ (*ftab->sha2Init)(SHA512, (SHA2_CTX *)pContext);
+ }
+ break;
+ default:
+ if (DEBUG) printf("ERROR: Unsupported mech %i\n", mech);
+ }
+ return (jlong) pContext;
+}
+
+jint JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeUpdate
+ (jint mech, jlong pContext, int notUsed, unsigned char* in, jint ofs, jint len) {
+ if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_SHA1) {
+ (*ftab->sha1Update)((SHA1_CTX*)pContext, (unsigned char*)(in+ofs), len);
+ } else if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_MD5) {
+ (*ftab->md5Update)((MD5_CTX*)pContext, (unsigned char*)(in+ofs), len);
+ } else { // SHA-2 family
+ (*ftab->sha2Update)((SHA2_CTX*)pContext, (unsigned char*)(in+ofs), len);
+ }
+ return 0;
+}
+
+// Do digest and free the context immediately
+jint JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeDigest
+ (jint mech, jlong pContext, int notUsed, unsigned char* out, jint ofs, jint digestLen) {
+
+ if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_SHA1) {
+ (*ftab->sha1Final)((unsigned char*)(out + ofs), (SHA1_CTX *)pContext);
+ free((SHA1_CTX *)pContext);
+ } else if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_MD5) {
+ (*ftab->md5Final)((unsigned char*)(out + ofs), (MD5_CTX *)pContext);
+ free((MD5_CTX *)pContext);
+ } else { // SHA-2 family
+ (*ftab->sha2Final)((unsigned char*)(out + ofs), (SHA2_CTX *)pContext);
+ free((SHA2_CTX *)pContext);
+ }
+ return 0;
+}
+
+jlong JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeClone
+ (jint mech, jlong pContext) {
+ void *copy = NULL;
+ size_t len = 0;
+
+ if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_SHA1) {
+ len = sizeof(SHA1_CTX);
+ } else if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_MD5) {
+ len = sizeof(MD5_CTX);
+ } else { // SHA-2 family
+ len = sizeof(SHA2_CTX);
+ }
+ copy = (void*) malloc(len);
+ if (copy != NULL) {
+ bcopy((void *)pContext, copy, len);
+ }
+ return (jlong) copy;
+}
+
+void JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeFree
+ (jint mech, jlong pContext) {
+ if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_SHA1) {
+ free((SHA1_CTX*) pContext);
+ } else if (mech == com_oracle_security_ucrypto_NativeDigest_MECH_MD5) {
+ free((MD5_CTX*) pContext);
+ } else { // SHA-2 family
+ free((SHA2_CTX*) pContext);
+ }
+}
+
+// AES
+jlong JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeInit
+ (jint mech, jboolean encrypt, int keyLen, unsigned char* bufKey,
+ int ivLen, unsigned char* bufIv, jint tagLen, int aadLen, unsigned char* bufAad) {
+ crypto_ctx_t *context = NULL;
+ int rv;
+
+ context = malloc(sizeof(crypto_ctx_t));
+ if (context != NULL) {
+ rv = CipherInit(context, encrypt, (ucrypto_mech_t) mech, bufKey, keyLen,
+ bufIv, ivLen, tagLen, bufAad, aadLen);
+ if (rv) {
+ free(context);
+ return 0L;
+ }
+ }
+ return (jlong)context;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeCipher
+ * Method: nativeUpdate
+ * Signature: (JZ[BII[BI)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeUpdate
+ (jlong pContext, jboolean encrypt, int notUsed, jbyte* bufIn, jint inOfs, jint inLen,
+ int outCapacity, jbyte* bufOut, jint outOfs) {
+ crypto_ctx_t *context;
+ int rv = 0;
+ int outLen = outCapacity - outOfs; // recalculate the real out length
+
+ context = (crypto_ctx_t *) pContext;
+ rv = CipherUpdate(context, encrypt, (unsigned char*)bufIn, inOfs, inLen, (unsigned char*)bufOut, outOfs, &outLen);
+ if (rv) {
+ free(context);
+ context = 0;
+ return -rv; // use negative value to indicate error!
+ }
+
+ return outLen;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeCipher
+ * Method: nativeFinal
+ * Signature: (JZ[BI)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeCipher_nativeFinal
+ (jlong pContext, jboolean encrypt, int outLen, jbyte* bufOut, jint outOfs) {
+ crypto_ctx_t *context;
+ int rv = 0;
+
+ context = (crypto_ctx_t *) pContext;
+ rv = CipherFinal(context, encrypt, (unsigned char*)bufOut, outOfs, &outLen);
+ free(context);
+ if (rv) {
+ return -rv; // use negative value to indicate error!
+ }
+
+ return outLen;
+}
+
+
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeDigest
+ * Method: nativeInit
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_com_oracle_security_ucrypto_NativeDigest_nativeInit
+ (JNIEnv *env, jclass jcls, jint mech) {
+ jlong result = JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeInit(mech);
+ if (result == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ }
+ return result;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeDigest
+ * Method: nativeUpdate
+ * Signature: (IJ[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeDigest_nativeUpdate
+ (JNIEnv *env, jclass jcls, jint mech, jlong pContext, jbyteArray jIn, jint jOfs, jint jLen) {
+ unsigned char *bufIn;
+
+ bufIn = (unsigned char *) getBytes(env, jIn, jOfs, jLen);
+ if (!(*env)->ExceptionCheck(env)) {
+ JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeUpdate(mech, pContext, jLen, bufIn, 0, jLen);
+ free(bufIn);
+ }
+ return 0;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeDigest
+ * Method: nativeDigest
+ * Signature: (IJ[BII)I
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeDigest_nativeDigest
+ (JNIEnv *env, jclass jcls, jint mech, jlong pContext, jbyteArray jOut, jint jOutOfs, jint digestLen) {
+ unsigned char *bufOut;
+
+ bufOut = (unsigned char *) malloc(digestLen);
+ if (bufOut == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return 0;
+ }
+
+ JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeDigest(mech, pContext, digestLen, bufOut, 0, digestLen);
+
+ (*env)->SetByteArrayRegion(env, jOut, jOutOfs, digestLen, (jbyte *) bufOut);
+ free(bufOut);
+ return 0;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeDigest
+ * Method: nativeClone
+ * Signature: (IJ)J
+ */
+JNIEXPORT jlong JNICALL Java_com_oracle_security_ucrypto_NativeDigest_nativeClone
+ (JNIEnv *env, jclass jcls, jint mech, jlong pContext) {
+ return JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeClone(mech, pContext);
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeDigest
+ * Method: nativeFree
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL Java_com_oracle_security_ucrypto_NativeDigest_nativeFree
+ (JNIEnv *env, jclass jcls, jint mech, jlong pContext) {
+ JavaCritical_com_oracle_security_ucrypto_NativeDigest_nativeFree(mech, pContext);
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeCipher
+ * Method: nativeInit
+ * Signature: (IZ[B[BI[B)J
+ */
+JNIEXPORT jlong JNICALL Java_com_oracle_security_ucrypto_NativeCipher_nativeInit
+(JNIEnv *env, jclass jcls, jint mech, jboolean encrypt, jbyteArray jKey,
+ jbyteArray jIv, jint tagLen, jbyteArray jAad) {
+
+ crypto_ctx_t *context;
+ unsigned char *bufKey;
+ unsigned char *bufIv;
+ unsigned char *bufAad;
+ int keyLen, ivLen, aadLen, rv = 0;
+ jlong result = 0L;
+
+ bufKey = bufIv = bufAad = NULL;
+ keyLen = ivLen = aadLen = 0;
+ context = malloc(sizeof(crypto_ctx_t));
+ if (context == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return 0L;
+ }
+
+ // jKey MUST NOT BE NULL;
+ keyLen = (*env)->GetArrayLength(env, jKey);
+ bufKey = (unsigned char *) (*env)->GetByteArrayElements(env, jKey, NULL);
+ if (bufKey == NULL) {
+ goto cleanup;
+ }
+
+ if (jIv != NULL) {
+ ivLen = (*env)->GetArrayLength(env, jIv);
+ bufIv = (unsigned char *) (*env)->GetByteArrayElements(env, jIv, NULL);
+ if (bufIv == NULL) {
+ goto cleanup;
+ }
+ }
+
+ if (jAad != NULL) {
+ aadLen = (*env)->GetArrayLength(env, jAad);
+ bufAad = (unsigned char *) (*env)->GetByteArrayElements(env, jAad, NULL);
+ if (bufAad == NULL) {
+ goto cleanup;
+ }
+ }
+
+ rv = CipherInit(context, encrypt, mech, bufKey, keyLen, bufIv, ivLen, tagLen, bufAad, aadLen);
+ if (rv != 0) {
+ throwUCExceptionUsingRV(env, rv);
+ } else {
+ result = (jlong) context;
+ }
+
+cleanup:
+ if ((result == 0L) && (context != NULL)) {
+ free(context);
+ }
+ if (bufKey != NULL) {
+ (*env)->ReleaseByteArrayElements(env, jKey, (jbyte *)bufKey, 0);
+ }
+ if (bufIv != NULL) {
+ (*env)->ReleaseByteArrayElements(env, jIv, (jbyte *)bufIv, 0);
+ }
+ if (bufAad != NULL) {
+ (*env)->ReleaseByteArrayElements(env, jAad, (jbyte *)bufAad, 0);
+ }
+
+ return result;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeCipher
+ * Method: nativeUpdate
+ * Signature: (JZ[BII[BI)I
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeCipher_nativeUpdate
+ (JNIEnv *env, jclass jcls, jlong contextID, jboolean encrypt,
+ jbyteArray jIn, jint inOfs, jint inLen, jbyteArray jOut, jint outOfs) {
+ crypto_ctx_t *context;
+ unsigned char *bufIn;
+ unsigned char *bufOut;
+ int outLen, rv = 0;
+
+ context = (crypto_ctx_t *) contextID;
+ bufIn = (unsigned char *) getBytes(env, jIn, inOfs, inLen);
+ if ((*env)->ExceptionCheck(env)) {
+ return 0;
+ }
+
+ outLen = (*env)->GetArrayLength(env, jOut) - outOfs;
+ bufOut = calloc(outLen, sizeof(char));
+ if (bufOut == NULL) {
+ free(bufIn);
+ throwOutOfMemoryError(env, NULL);
+ return 0;
+ }
+
+ rv = CipherUpdate(context, encrypt, bufIn, 0, inLen, bufOut, 0, &outLen);
+ if (rv) {
+ free(context);
+ free(bufIn);
+ free(bufOut);
+ return -rv;
+ } else {
+ (*env)->SetByteArrayRegion(env, jOut, outOfs, outLen, (jbyte *)bufOut);
+ free(bufIn);
+ free(bufOut);
+ return outLen;
+ }
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeCipher
+ * Method: nativeFinal
+ * Signature: (JZ[BI)I
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeCipher_nativeFinal
+ (JNIEnv *env, jclass jCls, jlong contextID, jboolean encrypt,
+ jbyteArray out, jint outOfs) {
+ crypto_ctx_t *context;
+ unsigned char *bufIn;
+ unsigned char *bufOut;
+ int outLen, rv = 0;
+
+ context = (crypto_ctx_t *) contextID;
+
+ // out is null when nativeFinal() is called solely for resource clean up
+ if (out == NULL) {
+ bufOut = NULL;
+ outLen = 0;
+ } else {
+ outLen = (*env)->GetArrayLength(env, out) - outOfs;
+ bufOut = calloc(outLen, sizeof(char));
+ if (bufOut == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return 0;
+ }
+ }
+ rv = CipherFinal(context, encrypt, bufOut, 0, &outLen);
+ if (rv) {
+ free(context);
+ free(bufOut);
+ return -rv;
+ } else {
+ if (bufOut != NULL) {
+ (*env)->SetByteArrayRegion(env, out, outOfs, outLen, (jbyte *)bufOut);
+ free(bufOut);
+ }
+ free(context);
+ return outLen;
+ }
+}
+
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeKey
+ * Method: nativeFree
+ * Signature: (JI)V
+ */
+void JavaCritical_com_oracle_security_ucrypto_NativeKey_nativeFree
+ (jlong id, jint numOfComponents) {
+ crypto_object_attribute_t* pKey;
+ int i;
+
+ pKey = (crypto_object_attribute_t*) id;
+ for (i = 0; i < numOfComponents; i++) {
+ free(pKey[i].oa_value);
+ }
+ free(pKey);
+}
+
+JNIEXPORT void JNICALL Java_com_oracle_security_ucrypto_NativeKey_nativeFree
+ (JNIEnv *env, jclass jCls, jlong id, jint numOfComponents) {
+ JavaCritical_com_oracle_security_ucrypto_NativeKey_nativeFree(id, numOfComponents);
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeKey_RSAPrivateCrt
+ * Method: nativeInit
+ * Signature: ([B[B[B[B[B[B[B[B)J
+ */
+jlong JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPrivateCrt_nativeInit
+(int modLen, jbyte* jMod, int pubLen, jbyte* jPub, int privLen, jbyte* jPriv,
+ int pLen, jbyte* jP, int qLen, jbyte* jQ, int expPLen, jbyte* jExpP,
+ int expQLen, jbyte* jExpQ, int crtCoeffLen, jbyte* jCrtCoeff) {
+
+ unsigned char *mod, *pub, *priv, *p, *q, *expP, *expQ, *crtCoeff;
+ crypto_object_attribute_t* pKey = NULL;
+
+ pKey = calloc(8, sizeof(crypto_object_attribute_t));
+ if (pKey == NULL) {
+ return 0L;
+ }
+ mod = pub = priv = p = q = expP = expQ = crtCoeff = NULL;
+ mod = malloc(modLen);
+ pub = malloc(pubLen);
+ priv = malloc(privLen);
+ p = malloc(pLen);
+ q = malloc(qLen);
+ expP = malloc(expPLen);
+ expQ = malloc(expQLen);
+ crtCoeff = malloc(crtCoeffLen);
+ if (mod == NULL || pub == NULL || priv == NULL || p == NULL ||
+ q == NULL || expP == NULL || expQ == NULL || crtCoeff == NULL) {
+ free(pKey);
+ free(mod);
+ free(pub);
+ free(priv);
+ free(p);
+ free(q);
+ free(expP);
+ free(expQ);
+ free(crtCoeff);
+ return 0L;
+ } else {
+ memcpy(mod, jMod, modLen);
+ memcpy(pub, jPub, pubLen);
+ memcpy(priv, jPriv, privLen);
+ memcpy(p, jP, pLen);
+ memcpy(q, jQ, qLen);
+ memcpy(expP, jExpP, expPLen);
+ memcpy(expQ, jExpQ, expQLen);
+ memcpy(crtCoeff, jCrtCoeff, crtCoeffLen);
+ }
+
+ // NOTE: numOfComponents should be 8
+ pKey[0].oa_type = SUN_CKA_MODULUS;
+ pKey[0].oa_value = (char*) mod;
+ pKey[0].oa_value_len = (size_t) modLen;
+ pKey[1].oa_type = SUN_CKA_PUBLIC_EXPONENT;
+ pKey[1].oa_value = (char*) pub;
+ pKey[1].oa_value_len = (size_t) pubLen;
+ pKey[2].oa_type = SUN_CKA_PRIVATE_EXPONENT;
+ pKey[2].oa_value = (char*) priv;
+ pKey[2].oa_value_len = (size_t) privLen;
+ pKey[3].oa_type = SUN_CKA_PRIME_1;
+ pKey[3].oa_value = (char*) p;
+ pKey[3].oa_value_len = (size_t) pLen;
+ pKey[4].oa_type = SUN_CKA_PRIME_2;
+ pKey[4].oa_value = (char*) q;
+ pKey[4].oa_value_len = (size_t) qLen;
+ pKey[5].oa_type = SUN_CKA_EXPONENT_1;
+ pKey[5].oa_value = (char*) expP;
+ pKey[5].oa_value_len = (size_t) expPLen;
+ pKey[6].oa_type = SUN_CKA_EXPONENT_2;
+ pKey[6].oa_value = (char*) expQ;
+ pKey[6].oa_value_len = (size_t) expQLen;
+ pKey[7].oa_type = SUN_CKA_COEFFICIENT;
+ pKey[7].oa_value = (char*) crtCoeff;
+ pKey[7].oa_value_len = (size_t) crtCoeffLen;
+
+ return (jlong) pKey;
+}
+
+
+JNIEXPORT jlong JNICALL
+Java_com_oracle_security_ucrypto_NativeKey_00024RSAPrivateCrt_nativeInit
+ (JNIEnv *env, jclass jCls, jbyteArray jMod, jbyteArray jPub, jbyteArray jPriv,
+ jbyteArray jP, jbyteArray jQ, jbyteArray jExpP, jbyteArray jExpQ,
+ jbyteArray jCrtCoeff) {
+
+ int modLen, pubLen, privLen, pLen, qLen, expPLen, expQLen, crtCoeffLen;
+ jbyte *bufMod, *bufPub, *bufPriv, *bufP, *bufQ, *bufExpP, *bufExpQ, *bufCrtCoeff;
+ crypto_object_attribute_t* pKey = NULL;
+
+ bufMod = bufPub = bufPriv = bufP = bufQ = bufExpP = bufExpQ = bufCrtCoeff = NULL;
+
+ modLen = (*env)->GetArrayLength(env, jMod);
+ bufMod = getBytes(env, jMod, 0, modLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ pubLen = (*env)->GetArrayLength(env, jPub);
+ bufPub = getBytes(env, jPub, 0, pubLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ privLen = (*env)->GetArrayLength(env, jPriv);
+ bufPriv = getBytes(env, jPriv, 0, privLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ pLen = (*env)->GetArrayLength(env, jP);
+ bufP = getBytes(env, jP, 0, pLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ qLen = (*env)->GetArrayLength(env, jQ);
+ bufQ = getBytes(env, jQ, 0, qLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ expPLen = (*env)->GetArrayLength(env, jExpP);
+ bufExpP = getBytes(env, jExpP, 0, expPLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ expQLen = (*env)->GetArrayLength(env, jExpQ);
+ bufExpQ = getBytes(env, jExpQ, 0, expQLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ crtCoeffLen = (*env)->GetArrayLength(env, jCrtCoeff);
+ bufCrtCoeff = getBytes(env, jCrtCoeff, 0, crtCoeffLen);
+ if ((*env)->ExceptionCheck(env)) goto cleanup;
+
+ // proceed if no error; otherwise free allocated memory
+ pKey = calloc(8, sizeof(crypto_object_attribute_t));
+ if (pKey == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ goto cleanup;
+ }
+
+ // NOTE: numOfComponents should be 8
+ pKey[0].oa_type = SUN_CKA_MODULUS;
+ pKey[0].oa_value = (char*) bufMod;
+ pKey[0].oa_value_len = (size_t) modLen;
+ pKey[1].oa_type = SUN_CKA_PUBLIC_EXPONENT;
+ pKey[1].oa_value = (char*) bufPub;
+ pKey[1].oa_value_len = (size_t) pubLen;
+ pKey[2].oa_type = SUN_CKA_PRIVATE_EXPONENT;
+ pKey[2].oa_value = (char*) bufPriv;
+ pKey[2].oa_value_len = (size_t) privLen;
+ pKey[3].oa_type = SUN_CKA_PRIME_1;
+ pKey[3].oa_value = (char*) bufP;
+ pKey[3].oa_value_len = (size_t) pLen;
+ pKey[4].oa_type = SUN_CKA_PRIME_2;
+ pKey[4].oa_value = (char*) bufQ;
+ pKey[4].oa_value_len = (size_t) qLen;
+ pKey[5].oa_type = SUN_CKA_EXPONENT_1;
+ pKey[5].oa_value = (char*) bufExpP;
+ pKey[5].oa_value_len = (size_t) expPLen;
+ pKey[6].oa_type = SUN_CKA_EXPONENT_2;
+ pKey[6].oa_value = (char*) bufExpQ;
+ pKey[6].oa_value_len = (size_t) expQLen;
+ pKey[7].oa_type = SUN_CKA_COEFFICIENT;
+ pKey[7].oa_value = (char*) bufCrtCoeff;
+ pKey[7].oa_value_len = (size_t) crtCoeffLen;
+ return (jlong) pKey;
+
+cleanup:
+ free(bufMod);
+ free(bufPub);
+ free(bufPriv);
+ free(bufP);
+ free(bufQ);
+ free(bufExpP);
+ free(bufExpQ);
+ free(bufCrtCoeff);
+
+ return 0L;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeKey_RSAPublic
+ * Method: nativeInit
+ * Signature: ([B[B)J
+ */
+
+jlong JavaCritical_com_oracle_security_ucrypto_NativeKey_00024RSAPublic_nativeInit
+(int modLen, jbyte* jMod, int pubLen, jbyte* jPub) {
+ unsigned char *mod, *pub;
+ crypto_object_attribute_t* pKey = NULL;
+
+ pKey = calloc(2, sizeof(crypto_object_attribute_t));
+ if (pKey == NULL) {
+ return 0L;
+ }
+ mod = pub = NULL;
+ mod = malloc(modLen);
+ pub = malloc(pubLen);
+ if (mod == NULL || pub == NULL) {
+ free(pKey);
+ free(mod);
+ free(pub);
+ return 0L;
+ } else {
+ memcpy(mod, jMod, modLen);
+ memcpy(pub, jPub, pubLen);
+ }
+
+ if (DEBUG) {
+ printf("RSAPublicKey Init: keyValue=%ld, keyLen=2\n", pKey);
+ printBytes("RSA PublicKey mod: ", (unsigned char*) mod, modLen);
+ printBytes("RSA PublicKey pubExp: ", (unsigned char*) pub, pubLen);
+ }
+
+ pKey[0].oa_type = SUN_CKA_MODULUS;
+ pKey[0].oa_value = (char*) mod;
+ pKey[0].oa_value_len = (size_t) modLen;
+ pKey[1].oa_type = SUN_CKA_PUBLIC_EXPONENT;
+ pKey[1].oa_value = (char*) pub;
+ pKey[1].oa_value_len = (size_t) pubLen;
+
+ return (jlong) pKey;
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_oracle_security_ucrypto_NativeKey_00024RSAPublic_nativeInit
+(JNIEnv *env, jclass jCls, jbyteArray jMod, jbyteArray jPub) {
+ int modLen, pubLen;
+ jbyte *bufMod, *bufPub;
+ crypto_object_attribute_t* pKey = NULL;
+
+ bufMod = bufPub = NULL;
+
+ modLen = (*env)->GetArrayLength(env, jMod);
+ bufMod = getBytes(env, jMod, 0, modLen);
+ if ((*env)->ExceptionCheck(env)) {
+ return 0L;
+ }
+
+ pubLen = (*env)->GetArrayLength(env, jPub);
+ bufPub = getBytes(env, jPub, 0, pubLen);
+ if ((*env)->ExceptionCheck(env)) {
+ free(bufMod);
+ return 0L;
+ }
+
+ // proceed if no error; otherwise free allocated memory
+ pKey = calloc(2, sizeof(crypto_object_attribute_t));
+ if (pKey != NULL) {
+ // NOTE: numOfComponents should be 2
+ pKey[0].oa_type = SUN_CKA_MODULUS;
+ pKey[0].oa_value = (char*) bufMod;
+ pKey[0].oa_value_len = (size_t) modLen;
+ pKey[1].oa_type = SUN_CKA_PUBLIC_EXPONENT;
+ pKey[1].oa_value = (char*) bufPub;
+ pKey[1].oa_value_len = (size_t) pubLen;
+ return (jlong) pKey;
+ } else {
+ free(bufMod);
+ free(bufPub);
+ throwOutOfMemoryError(env, NULL);
+ return 0L;
+ }
+}
+
+////////////////////////
+// NativeRSASignature
+////////////////////////
+
+int
+SignatureInit(crypto_ctx_t *context, jint mechVal, jboolean sign,
+ uchar_t *pKey, size_t keyLength) {
+ ucrypto_mech_t mech;
+ int rv = 0;
+
+ mech = (ucrypto_mech_t) mechVal;
+
+ if (sign) {
+ rv = (*ftab->ucryptoSignInit)(context, mech, pKey, keyLength,
+ NULL, 0);
+ } else {
+ rv = (*ftab->ucryptoVerifyInit)(context, mech, pKey, keyLength,
+ NULL, 0);
+ }
+ if (DEBUG) {
+ printf("SignatureInit: context=%ld, mech=%d, sign=%d, keyValue=%ld, keyLength=%d\n",
+ context, mech, sign, pKey, keyLength);
+ printf("SignatureInit, ret => 0x%x\n", rv);
+ }
+ return rv;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeRSASignature
+ * Method: nativeInit
+ * Signature: (IZJI[B)J
+ */
+jlong JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeInit
+(jint mech, jboolean sign, jlong jKey, jint keyLength) {
+ crypto_ctx_t *context;
+ int rv;
+ uchar_t *pKey;
+
+ context = malloc(sizeof(crypto_ctx_t));
+ if (context != NULL) {
+ pKey = (uchar_t *) jKey;
+ rv = SignatureInit(context, mech, sign, pKey, (size_t)keyLength);
+ if (rv) {
+ free(context);
+ return 0L;
+ }
+ }
+ return (jlong)context;
+}
+
+JNIEXPORT jlong JNICALL Java_com_oracle_security_ucrypto_NativeRSASignature_nativeInit
+(JNIEnv *env, jclass jCls, jint mech, jboolean sign, jlong jKey, jint keyLength) {
+ crypto_ctx_t *context;
+ int rv = 0;
+ uchar_t *pKey;
+
+ context = malloc(sizeof(crypto_ctx_t));
+ if (context == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return 0L;
+ }
+
+ pKey = (uchar_t *) jKey;
+ rv = SignatureInit(context, mech, sign, pKey, (size_t)keyLength);
+ if (rv) {
+ free(context);
+ throwUCExceptionUsingRV(env, rv);
+ return 0L;
+ }
+
+ return (jlong)context;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeRSASignature
+ * Method: nativeUpdate
+ * Signature: (JZ[BII)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
+(jlong pCtxt, jboolean sign, int notUsed, jbyte* jIn, jint jInOfs, jint jInLen) {
+ crypto_ctx_t *context;
+ int rv = 0;
+
+ context = (crypto_ctx_t *) pCtxt;
+ if (DEBUG) {
+ printf("Signature update: context=%ld, sign=%d, jIn=%ld, jInOfs=%d, jInLen=%d\n",
+ context, sign, jIn, jInOfs, jInLen);
+ }
+ if (sign) {
+ rv = (*ftab->ucryptoSignUpdate)(context, (uchar_t *) (jIn + jInOfs), (size_t) jInLen);
+ } else {
+ rv = (*ftab->ucryptoVerifyUpdate)(context, (uchar_t *) (jIn + jInOfs), (size_t) jInLen);
+ }
+ if (DEBUG) printf("Signature update, ret => 0x%x\n", rv);
+ if (rv) {
+ free(context);
+ return -rv; // use negative value to indicate error!
+ }
+
+ return 0;
+}
+
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
+(JNIEnv *env, jclass jCls, jlong pCtxt, jboolean sign, jbyteArray jIn, jint inOfs, jint inLen) {
+ int rv = 0;
+ jbyte* bufIn;
+
+ bufIn = getBytes(env, jIn, inOfs, inLen);
+ if ((*env)->ExceptionCheck(env)) {
+ return -1; // use negative value to indicate error!
+ }
+
+ if (DEBUG) printBytes("Update w/ data: ", (unsigned char*)bufIn, (size_t) inLen);
+
+ rv = JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
+ (pCtxt, sign, inLen, bufIn, 0, inLen);
+
+ free(bufIn);
+ return rv;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeRSASignature
+ * Method: nativeUpdate
+ * Signature: (JZJI)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZJI
+(jlong pCtxt, jboolean sign, jlong inAddr, jint inLen) {
+
+ return JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
+ (pCtxt, sign, inLen, (jbyte*)inAddr, 0, inLen);
+}
+
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZJI
+(JNIEnv *env, jclass jCls, jlong pCtxt, jboolean sign, jlong inAddr, jint inLen) {
+
+ return JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeUpdate__JZ_3BII
+ (pCtxt, sign, inLen, (jbyte*)inAddr, 0, inLen);
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeRSASignature
+ * Method: nativeFinal
+ * Signature: (JZ[BII)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeFinal
+(jlong pCtxt, jboolean sign, int notUsed, jbyte* bufSig, jint sigOfs, jint jSigLen) {
+
+ crypto_ctx_t *context;
+ int rv = 0;
+ size_t sigLength = (size_t) jSigLen;
+
+ context = (crypto_ctx_t *) pCtxt;
+ if (DEBUG) {
+ printf("Signature final: context=%ld, sign=%d, bufSig=%ld, sigOfs=%d, sigLen=%d\n",
+ context, sign, bufSig, sigOfs, jSigLen);
+ printBytes("Before Final: SigBytes ", (unsigned char*) (bufSig + sigOfs), jSigLen);
+ }
+ if (sign) {
+ rv = (*ftab->ucryptoSignFinal)(context, (uchar_t *) (bufSig + sigOfs), &sigLength);
+ } else {
+ rv = (*ftab->ucryptoVerifyFinal)(context, (uchar_t *) (bufSig + sigOfs), &sigLength);
+ }
+
+ if (DEBUG) {
+ printf("Signature nativeFinal, ret => 0x%x\n", rv);
+ if (sigLength != jSigLen) {
+ printf("SIG actual output len=%d\n", sigLength);
+ }
+ if (sign) {
+ printBytes("After nativeFinal: ", (unsigned char*) (bufSig + sigOfs), jSigLen);
+ }
+ }
+
+ free(context);
+ if (rv) {
+ return -rv;
+ } else return 0;
+}
+
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeRSASignature_nativeFinal
+(JNIEnv *env, jclass jCls, jlong pCtxt, jboolean sign, jbyteArray jSig, jint jSigOfs, jint jSigLen) {
+ int rv = 0;
+ jbyte* bufSig = NULL;
+
+ if (jSigLen != 0) {
+ bufSig = calloc(jSigLen, sizeof(char));
+ if (bufSig == NULL) {
+ throwOutOfMemoryError(env, NULL);
+ return 0;
+ }
+ if (!sign) {
+ // need to copy over the to-be-verified signature bytes
+ (*env)->GetByteArrayRegion(env, jSig, jSigOfs, jSigLen, (jbyte *)bufSig);
+ }
+ }
+
+ if (!(*env)->ExceptionCheck(env)) {
+ // Frees context + converts rv to negative if error occurred
+ rv = JavaCritical_com_oracle_security_ucrypto_NativeRSASignature_nativeFinal
+ (pCtxt, sign, jSigLen, bufSig, 0, jSigLen);
+
+ if (rv == 0 && sign) {
+ // need to copy the generated signature bytes to the java bytearray
+ (*env)->SetByteArrayRegion(env, jSig, jSigOfs, jSigLen, (jbyte *)bufSig);
+ }
+ } else {
+ // set rv to negative to indicate error
+ rv = -1;
+ }
+
+ free(bufSig);
+
+ return rv;
+}
+
+/*
+ * Class: com_oracle_security_ucrypto_NativeRSACipher
+ * Method: nativeAtomic
+ * Signature: (IZJI[BI[BII)I
+ */
+jint JavaCritical_com_oracle_security_ucrypto_NativeRSACipher_nativeAtomic
+ (jint mech, jboolean encrypt, jlong keyValue, jint keyLength,
+ int notUsed1, jbyte* bufIn, jint jInLen,
+ int notUsed2, jbyte* bufOut, jint jOutOfs, jint jOutLen) {
+
+ uchar_t *pKey;
+ crypto_object_attribute_t* pKey2;
+ int rv = 0;
+ size_t outLength = (size_t) jOutLen;
+
+ pKey = (uchar_t *) keyValue;
+ if (DEBUG) {
+ printf("Cipher nativeAtomic: mech=%d, encrypt=%d, pKey=%ld, keyLength=%d\n",
+ mech, encrypt, pKey, keyLength);
+ printBytes("Before nativeAtomic: in: ", (unsigned char*) bufIn, jInLen);
+ printBytes("Before nativeAtomic: out: ", (unsigned char*) (bufOut + jOutOfs), jOutLen);
+ }
+
+ if (encrypt) {
+ rv = (*ftab->ucryptoEncrypt)((ucrypto_mech_t)mech, pKey, (size_t)keyLength,
+ NULL, 0, (uchar_t *)bufIn, (size_t)jInLen,
+ (uchar_t *)(bufOut + jOutOfs), &outLength);
+ } else {
+ rv = (*ftab->ucryptoDecrypt)((ucrypto_mech_t)mech, pKey, (size_t)keyLength,
+ NULL, 0, (uchar_t *)bufIn, (size_t)jInLen,
+ (uchar_t *)(bufOut + jOutOfs), &outLength);
+ }
+ if (DEBUG) {
+ printf("Cipher nativeAtomic, ret => 0x%x\n", rv);
+ if (outLength != jOutLen) {
+ printf("CIP actual output len=%d\n", outLength);
+ }
+ printBytes("After nativeAtomic: ", (unsigned char*) (bufOut + jOutOfs), outLength);
+ }
+
+ if (rv) {
+ return -rv;
+ } else return outLength;
+}
+
+JNIEXPORT jint JNICALL Java_com_oracle_security_ucrypto_NativeRSACipher_nativeAtomic
+ (JNIEnv *env, jclass jCls, jint mech, jboolean encrypt,
+ jlong keyValue, jint keyLength, jbyteArray jIn, jint jInLen,
+ jbyteArray jOut, jint jOutOfs, jint jOutLen) {
+ int rv = 0;
+ jbyte *bufIn = NULL;
+ jbyte *bufOut = NULL;
+
+ if (jInLen != 0) {
+ bufIn = (*env)->GetByteArrayElements(env, jIn, NULL);
+ if (bufIn == NULL) {
+ return 0;
+ }
+ }
+ bufOut = calloc(jOutLen, sizeof(jbyte));
+ if (bufOut == NULL) {
+ (*env)->ReleaseByteArrayElements(env, jIn, bufIn, 0);
+ throwOutOfMemoryError(env, NULL);
+ return 0;
+ }
+
+ // rv: output length or error code (if negative)
+ rv = JavaCritical_com_oracle_security_ucrypto_NativeRSACipher_nativeAtomic
+ (mech, encrypt, keyValue, keyLength, jInLen, bufIn, jInLen,
+ jOutLen, bufOut, 0, jOutLen);
+
+ if (rv > 0) {
+ (*env)->SetByteArrayRegion(env, jOut, jOutOfs, rv, (jbyte *)bufOut);
+ }
+
+ if (bufIn != NULL) {
+ (*env)->ReleaseByteArrayElements(env, jIn, bufIn, 0);
+ }
+ free(bufOut);
+ return rv;
+}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMaskV6.java b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h
similarity index 54%
rename from jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMaskV6.java
rename to jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h
index e0857b1fad2..9ad3891d0d0 100644
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMaskV6.java
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeCrypto.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,24 +23,28 @@
* questions.
*/
-/* Generated By:JJTree: Do not edit this line. JDMNetMaskV6.java */
+#ifndef _Included_com_oracle_security_ucrypto_NativeCrypto
+#define _Included_com_oracle_security_ucrypto_NativeCrypto
+#ifdef __cplusplus
+extern "C" {
+#endif
-package com.sun.jmx.snmp.IPAcl;
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_MD5
+#define com_oracle_security_ucrypto_NativeDigest_MECH_MD5 1L
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_SHA1
+#define com_oracle_security_ucrypto_NativeDigest_MECH_SHA1 2L
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_SHA256
+#define com_oracle_security_ucrypto_NativeDigest_MECH_SHA256 3L
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_SHA224
+#define com_oracle_security_ucrypto_NativeDigest_MECH_SHA224 4L
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_SHA384
+#define com_oracle_security_ucrypto_NativeDigest_MECH_SHA384 5L
+#undef com_oracle_security_ucrypto_NativeDigest_MECH_SHA512
+#define com_oracle_security_ucrypto_NativeDigest_MECH_SHA512 6L
-import java.net.UnknownHostException;
+#define DEBUG 0
-class JDMNetMaskV6 extends JDMNetMask {
- private static final long serialVersionUID = 4505256777680576645L;
-
- public JDMNetMaskV6(int id) {
- super(id);
- }
-
- public JDMNetMaskV6(Parser p, int id) {
- super(p, id);
- }
- protected PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException {
- return new NetMaskImpl(address.toString(), Integer.parseInt(mask));
- }
+#ifdef __cplusplus
}
+#endif
+#endif
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.c b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.c
new file mode 100644
index 00000000000..c1ee9027e92
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "nativeFunc.h"
+
+/* standard md5/md/softcrypto method names (ordering is from mapfile) */
+static const char MD5_INIT[] = "MD5Init";
+static const char MD5_UPDATE[] = "MD5Update";
+static const char MD5_FINAL[] = "MD5Final";
+static const char SHA1_INIT[] = "SHA1Init";
+static const char SHA1_UPDATE[] = "SHA1Update";
+static const char SHA1_FINAL[] = "SHA1Final";
+static const char SHA2_INIT[] = "SHA2Init";
+static const char SHA2_UPDATE[] = "SHA2Update";
+static const char SHA2_FINAL[] = "SHA2Final";
+static const char UCRYPTO_VERSION[] = "ucrypto_version";
+static const char UCRYPTO_GET_MECHLIST[] = "ucrypto_get_mechlist";
+static const char UCRYPTO_ENCRYPT_INIT[] = "ucrypto_encrypt_init";
+static const char UCRYPTO_ENCRYPT_UPDATE[] = "ucrypto_encrypt_update";
+static const char UCRYPTO_ENCRYPT_FINAL[] = "ucrypto_encrypt_final";
+static const char UCRYPTO_ENCRYPT[] = "ucrypto_encrypt";
+static const char UCRYPTO_DECRYPT_INIT[] = "ucrypto_decrypt_init";
+static const char UCRYPTO_DECRYPT_UPDATE[] = "ucrypto_decrypt_update";
+static const char UCRYPTO_DECRYPT_FINAL[] = "ucrypto_decrypt_final";
+static const char UCRYPTO_DECRYPT[] = "ucrypto_decrypt";
+static const char UCRYPTO_SIGN_INIT[] = "ucrypto_sign_init";
+static const char UCRYPTO_SIGN_UPDATE[] = "ucrypto_sign_update";
+static const char UCRYPTO_SIGN_FINAL[] = "ucrypto_sign_final";
+static const char UCRYPTO_VERIFY_INIT[] = "ucrypto_verify_init";
+static const char UCRYPTO_VERIFY_UPDATE[] = "ucrypto_verify_update";
+static const char UCRYPTO_VERIFY_FINAL[] = "ucrypto_verify_final";
+
+/**
+ * Initialize native T4 crypto function pointers
+ */
+jboolean* loadNative() {
+
+ jboolean* buf;
+ void *lib;
+
+ buf = malloc(2 * sizeof(jboolean));
+ buf[0] = buf[1] = JNI_FALSE;
+ ftab = (T4CRYPTO_FUNCTION_TABLE_PTR) calloc(1, sizeof(T4CRYPTO_FUNCTION_TABLE));
+ if (ftab == NULL) {
+ free(buf);
+ return NULL;
+ }
+
+ lib = dlopen("libmd.so", RTLD_NOW);
+ if (lib != NULL) {
+ ftab->md5Init = (MD5INIT_FN_PTR) dlsym(lib, MD5_INIT);
+ ftab->md5Update = (MD5UPDATE_FN_PTR) dlsym(lib, MD5_UPDATE);
+ ftab->md5Final = (MD5FINAL_FN_PTR) dlsym(lib, MD5_FINAL);
+ ftab->sha1Init = (SHA1INIT_FN_PTR) dlsym(lib, SHA1_INIT);
+ ftab->sha1Update = (SHA1UPDATE_FN_PTR) dlsym(lib, SHA1_UPDATE);
+ ftab->sha1Final = (SHA1FINAL_FN_PTR) dlsym(lib, SHA1_FINAL);
+ ftab->sha2Init = (SHA2INIT_FN_PTR) dlsym(lib, SHA2_INIT);
+ ftab->sha2Update = (SHA2UPDATE_FN_PTR) dlsym(lib, SHA2_UPDATE);
+ ftab->sha2Final = (SHA2FINAL_FN_PTR) dlsym(lib, SHA2_FINAL);
+ if (ftab->md5Init != NULL && ftab->md5Update != NULL &&
+ ftab->md5Final != NULL && ftab->sha1Init != NULL &&
+ ftab->sha1Update != NULL && ftab->sha1Final != NULL &&
+ ftab->sha2Init != NULL && ftab->sha2Update != NULL &&
+ ftab->sha2Final != NULL) {
+ buf[0] = JNI_TRUE;
+ } else {
+ dlclose(lib);
+ }
+ }
+
+ lib = dlopen("libsoftcrypto.so", RTLD_NOW);
+ if (lib != NULL) {
+ // These APIs aren't available for v0 lib on Solaris 10
+ ftab->ucryptoVersion = (UCRYPTO_VERSION_FN_PTR)
+ dlsym(lib, UCRYPTO_VERSION);
+ ftab->ucryptoGetMechList = (UCRYPTO_GET_MECHLIST_FN_PTR)
+ dlsym(lib, UCRYPTO_GET_MECHLIST);
+ //??
+ ftab->ucryptoSignInit = (UCRYPTO_SIGN_INIT_FN_PTR)
+ dlsym(lib, UCRYPTO_SIGN_INIT);
+ ftab->ucryptoSignUpdate = (UCRYPTO_SIGN_UPDATE_FN_PTR)
+ dlsym(lib, UCRYPTO_SIGN_UPDATE);
+ ftab->ucryptoSignFinal = (UCRYPTO_SIGN_FINAL_FN_PTR)
+ dlsym(lib, UCRYPTO_SIGN_FINAL);
+ ftab->ucryptoVerifyInit = (UCRYPTO_VERIFY_INIT_FN_PTR)
+ dlsym(lib, UCRYPTO_VERIFY_INIT);
+ ftab->ucryptoVerifyUpdate = (UCRYPTO_VERIFY_UPDATE_FN_PTR)
+ dlsym(lib, UCRYPTO_VERIFY_UPDATE);
+ ftab->ucryptoVerifyFinal = (UCRYPTO_VERIFY_FINAL_FN_PTR)
+ dlsym(lib, UCRYPTO_VERIFY_FINAL);
+
+ // These should be avilable for all libsoftcrypto libs
+ ftab->ucryptoEncryptInit = (UCRYPTO_ENCRYPT_INIT_FN_PTR)
+ dlsym(lib, UCRYPTO_ENCRYPT_INIT);
+ ftab->ucryptoEncryptUpdate = (UCRYPTO_ENCRYPT_UPDATE_FN_PTR)
+ dlsym(lib, UCRYPTO_ENCRYPT_UPDATE);
+ ftab->ucryptoEncryptFinal = (UCRYPTO_ENCRYPT_FINAL_FN_PTR)
+ dlsym(lib, UCRYPTO_ENCRYPT_FINAL);
+ ftab->ucryptoEncrypt = (UCRYPTO_ENCRYPT_FN_PTR)
+ dlsym(lib, UCRYPTO_ENCRYPT);
+
+ ftab->ucryptoDecryptInit = (UCRYPTO_DECRYPT_INIT_FN_PTR)
+ dlsym(lib, UCRYPTO_DECRYPT_INIT);
+ ftab->ucryptoDecryptUpdate = (UCRYPTO_DECRYPT_UPDATE_FN_PTR)
+ dlsym(lib, UCRYPTO_DECRYPT_UPDATE);
+ ftab->ucryptoDecryptFinal = (UCRYPTO_DECRYPT_FINAL_FN_PTR)
+ dlsym(lib, UCRYPTO_DECRYPT_FINAL);
+ ftab->ucryptoDecrypt = (UCRYPTO_DECRYPT_FN_PTR)
+ dlsym(lib, UCRYPTO_DECRYPT);
+
+ if (ftab->ucryptoEncryptInit != NULL &&
+ ftab->ucryptoEncryptUpdate != NULL &&
+ ftab->ucryptoEncryptFinal != NULL &&
+ ftab->ucryptoEncrypt != NULL &&
+ ftab->ucryptoDecryptInit != NULL &&
+ ftab->ucryptoDecryptUpdate != NULL &&
+ ftab->ucryptoDecryptFinal != NULL &&
+ ftab->ucryptoDecrypt != NULL) {
+ buf[1] = JNI_TRUE;
+ } else {
+ dlclose(lib);
+ }
+ }
+
+ return buf;
+}
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.h b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.h
new file mode 100644
index 00000000000..d45272f9bab
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/nativeFunc.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef SPARCT4_NATIVE_FUNC_H
+#define SPARCT4_NATIVE_FUNC_H
+#include
+#include
+#include
+#include
+
+jboolean* loadNative();
+
+/* function pointer definitions */
+
+typedef void (*MD5INIT_FN_PTR)(MD5_CTX *context);
+
+typedef void (*MD5UPDATE_FN_PTR)
+ (MD5_CTX *context, unsigned char *input,
+ unsigned int inlen);
+
+typedef void (*MD5FINAL_FN_PTR)
+ (unsigned char *output, MD5_CTX *context);
+
+typedef void (*SHA1INIT_FN_PTR)(SHA1_CTX *context);
+
+typedef void (*SHA1UPDATE_FN_PTR)
+ (SHA1_CTX *context, unsigned char *input,
+ unsigned int inlen);
+
+typedef void (*SHA1FINAL_FN_PTR)
+ (unsigned char *output, SHA1_CTX *context);
+
+typedef void (*SHA2INIT_FN_PTR)(uint64_t mech, SHA2_CTX *context);
+
+typedef void (*SHA2UPDATE_FN_PTR)
+ (SHA2_CTX *context, unsigned char *input,
+ unsigned int inlen);
+
+typedef void (*SHA2FINAL_FN_PTR)
+ (unsigned char *output, SHA2_CTX *context);
+
+typedef int (*UCRYPTO_VERSION_FN_PTR)();
+
+typedef int (*UCRYPTO_GET_MECHLIST_FN_PTR)(char *str);
+
+typedef int (*UCRYPTO_ENCRYPT_INIT_FN_PTR)
+ (crypto_ctx_t *context, ucrypto_mech_t mech_type,
+ uchar_t *key_str, size_t key_len,
+ void *iv, size_t iv_len);
+
+typedef int (*UCRYPTO_ENCRYPT_UPDATE_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *in,
+ size_t in_len, uchar_t *out, size_t *out_len);
+
+typedef int (*UCRYPTO_ENCRYPT_FINAL_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *out,
+ size_t *out_len);
+
+typedef int (*UCRYPTO_ENCRYPT_FN_PTR)
+ (ucrypto_mech_t mech_type, uchar_t *key_str,
+ size_t key_len, void *iv, size_t iv_len, uchar_t *in,
+ size_t in_len, uchar_t *out, size_t *out_len);
+
+typedef int (*UCRYPTO_DECRYPT_INIT_FN_PTR)
+ (crypto_ctx_t *context,
+ ucrypto_mech_t mech_type, uchar_t *key_str, size_t key_len,
+ void *iv, size_t iv_len);
+
+typedef int (*UCRYPTO_DECRYPT_UPDATE_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *in,
+ size_t in_len, uchar_t *out, size_t *out_len);
+
+typedef int (*UCRYPTO_DECRYPT_FINAL_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *out,
+ size_t *out_len);
+
+typedef int (*UCRYPTO_DECRYPT_FN_PTR)
+ (ucrypto_mech_t mech_type, uchar_t *key_str,
+ size_t key_len, void *iv, size_t iv_len, uchar_t *in,
+ size_t in_len, uchar_t *out, size_t *out_len);
+
+typedef int (*UCRYPTO_SIGN_INIT_FN_PTR)
+ (crypto_ctx_t *context, ucrypto_mech_t mech_type,
+ uchar_t *key_str, size_t key_len,
+ void *iv, size_t iv_len);
+
+typedef int (*UCRYPTO_SIGN_UPDATE_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *data_str, size_t data_len);
+
+typedef int (*UCRYPTO_SIGN_FINAL_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len);
+
+typedef int (*UCRYPTO_VERIFY_INIT_FN_PTR)
+ (crypto_ctx_t *context, ucrypto_mech_t mech_type,
+ uchar_t *key_str, size_t key_len,
+ void *iv, size_t iv_len);
+
+typedef int (*UCRYPTO_VERIFY_UPDATE_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *data_str, size_t data_len);
+
+typedef int (*UCRYPTO_VERIFY_FINAL_FN_PTR)
+ (crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len);
+
+
+
+/* dynamically resolved functions from libmd, and libsoftcrypto
+ libraries */
+typedef struct T4CRYPTO_FUNCTION_TABLE {
+ MD5INIT_FN_PTR md5Init;
+ MD5UPDATE_FN_PTR md5Update;
+ MD5FINAL_FN_PTR md5Final;
+ SHA1INIT_FN_PTR sha1Init;
+ SHA1UPDATE_FN_PTR sha1Update;
+ SHA1FINAL_FN_PTR sha1Final;
+ SHA2INIT_FN_PTR sha2Init;
+ SHA2UPDATE_FN_PTR sha2Update;
+ SHA2FINAL_FN_PTR sha2Final;
+ UCRYPTO_VERSION_FN_PTR ucryptoVersion;
+ UCRYPTO_GET_MECHLIST_FN_PTR ucryptoGetMechList;
+ UCRYPTO_ENCRYPT_INIT_FN_PTR ucryptoEncryptInit;
+ UCRYPTO_ENCRYPT_UPDATE_FN_PTR ucryptoEncryptUpdate;
+ UCRYPTO_ENCRYPT_FINAL_FN_PTR ucryptoEncryptFinal;
+ UCRYPTO_ENCRYPT_FN_PTR ucryptoEncrypt;
+ UCRYPTO_DECRYPT_INIT_FN_PTR ucryptoDecryptInit;
+ UCRYPTO_DECRYPT_UPDATE_FN_PTR ucryptoDecryptUpdate;
+ UCRYPTO_DECRYPT_FINAL_FN_PTR ucryptoDecryptFinal;
+ UCRYPTO_DECRYPT_FN_PTR ucryptoDecrypt;
+ UCRYPTO_SIGN_INIT_FN_PTR ucryptoSignInit;
+ UCRYPTO_SIGN_UPDATE_FN_PTR ucryptoSignUpdate;
+ UCRYPTO_SIGN_FINAL_FN_PTR ucryptoSignFinal;
+ UCRYPTO_VERIFY_INIT_FN_PTR ucryptoVerifyInit;
+ UCRYPTO_VERIFY_UPDATE_FN_PTR ucryptoVerifyUpdate;
+ UCRYPTO_VERIFY_FINAL_FN_PTR ucryptoVerifyFinal;
+} T4CRYPTO_FUNCTION_TABLE;
+
+typedef T4CRYPTO_FUNCTION_TABLE *T4CRYPTO_FUNCTION_TABLE_PTR;
+
+/* global function table */
+T4CRYPTO_FUNCTION_TABLE_PTR ftab;
+
+#endif
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/common.h b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/common.h
new file mode 100644
index 00000000000..9ac5202368e
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/common.h
@@ -0,0 +1,637 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef _SYS_CRYPTO_COMMON_H
+#define _SYS_CRYPTO_COMMON_H
+
+/*
+ * Header file for the common data structures of the cryptographic framework
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include
+#include
+#include
+#include
+
+/* Convenience defines/macros */
+
+#define CRYPTO_ARG_INPLACE(input, output) \
+ if ((output) == NULL) \
+ (output) = (input);
+
+#ifdef _KERNEL
+
+#include
+#define CRYPTO_KMFLAG(x) crypto_kmflag((x))
+#define CRYPTO_ALLOC(sz, kmflag) kmem_alloc((sz), (kmflag))
+#define CRYPTO_ZALLOC(sz, kmflag) kmem_zalloc((sz), (kmflag))
+#define CRYPTO_FREE(ptr, sz) kmem_free((ptr), (sz))
+#define CRYPTO_ZFREE(ptr, sz) if (ptr != NULL) { \
+ bzero((ptr), (sz)), \
+ kmem_free((ptr), (sz)); \
+ }
+
+#else /* _KERNEL */
+
+#include
+#define CRYPTO_KMFLAG(x) (0)
+#define CRYPTO_ALLOC(sz, kmflag) malloc((sz))
+#define CRYPTO_ZALLOC(sz, kmflag) calloc(1, (sz))
+#define CRYPTO_FREE(ptr, sz) free((ptr))
+#define CRYPTO_ZFREE(ptr, sz) if (ptr != NULL) { \
+ bzero((ptr), (sz)), \
+ free((ptr)); \
+ }
+
+#endif /* _KERNEL */
+
+/* Cryptographic Mechanisms */
+
+#define CRYPTO_MAX_MECH_NAME 32
+typedef char crypto_mech_name_t[CRYPTO_MAX_MECH_NAME];
+
+typedef uint64_t crypto_mech_type_t;
+
+typedef struct crypto_mechanism {
+ crypto_mech_type_t cm_type; /* mechanism type */
+ caddr_t cm_param; /* mech. parameter */
+ size_t cm_param_len; /* mech. parameter len */
+} crypto_mechanism_t;
+
+#ifdef _SYSCALL32
+
+typedef struct crypto_mechanism32 {
+ crypto_mech_type_t cm_type; /* mechanism type */
+ caddr32_t cm_param; /* mech. parameter */
+ size32_t cm_param_len; /* mech. parameter len */
+} crypto_mechanism32_t;
+
+#endif /* _SYSCALL32 */
+
+#ifdef _KERNEL
+/* CK_AES_CTR_PARAMS provides parameters to the CKM_AES_CTR mechanism */
+typedef struct CK_AES_CTR_PARAMS {
+ ulong_t ulCounterBits;
+ uint8_t cb[16];
+} CK_AES_CTR_PARAMS;
+#endif
+
+/* CK_AES_CCM_PARAMS provides parameters to the CKM_AES_CCM mechanism */
+typedef struct CK_AES_CCM_PARAMS {
+ ulong_t ulMACSize;
+ ulong_t ulNonceSize;
+ ulong_t ulAuthDataSize;
+ ulong_t ulDataSize; /* used for plaintext or ciphertext */
+ uchar_t *nonce;
+ uchar_t *authData;
+} CK_AES_CCM_PARAMS;
+
+/* CK_AES_GCM_PARAMS provides parameters to the CKM_AES_GCM mechanism */
+typedef struct CK_AES_GCM_PARAMS {
+ uchar_t *pIv;
+ ulong_t ulIvLen;
+ ulong_t ulIvBits;
+ uchar_t *pAAD;
+ ulong_t ulAADLen;
+ ulong_t ulTagBits;
+} CK_AES_GCM_PARAMS;
+
+/* CK_AES_GMAC_PARAMS provides parameters to the CKM_AES_GMAC mechanism */
+typedef struct CK_AES_GMAC_PARAMS {
+ uchar_t *pIv;
+ uchar_t *pAAD;
+ ulong_t ulAADLen;
+} CK_AES_GMAC_PARAMS;
+
+#ifdef _KERNEL
+/*
+ * CK_ECDH1_DERIVE_PARAMS provides the parameters to the
+ * CKM_ECDH1_KEY_DERIVE mechanism
+ */
+typedef struct CK_ECDH1_DERIVE_PARAMS {
+ ulong_t kdf;
+ ulong_t ulSharedDataLen;
+ uchar_t *pSharedData;
+ ulong_t ulPublicDataLen;
+ uchar_t *pPublicData;
+} CK_ECDH1_DERIVE_PARAMS;
+#endif
+
+#ifdef _KERNEL
+#ifdef _SYSCALL32
+
+/* needed for 32-bit applications running on 64-bit kernels */
+typedef struct CK_AES_CTR_PARAMS32 {
+ uint32_t ulCounterBits;
+ uint8_t cb[16];
+} CK_AES_CTR_PARAMS32;
+
+/* needed for 32-bit applications running on 64-bit kernels */
+typedef struct CK_AES_CCM_PARAMS32 {
+ uint32_t ulMACSize;
+ uint32_t ulNonceSize;
+ uint32_t ulAuthDataSize;
+ uint32_t ulDataSize;
+ caddr32_t nonce;
+ caddr32_t authData;
+} CK_AES_CCM_PARAMS32;
+
+/* needed for 32-bit applications running on 64-bit kernels */
+typedef struct CK_AES_GCM_PARAMS32 {
+ caddr32_t pIv;
+ uint32_t ulIvLen;
+ uint32_t ulIvBits;
+ caddr32_t pAAD;
+ uint32_t ulAADLen;
+ uint32_t ulTagBits;
+} CK_AES_GCM_PARAMS32;
+
+/* needed for 32-bit applications running on 64-bit kernels */
+typedef struct CK_AES_GMAC_PARAMS32 {
+ caddr32_t pIv;
+ caddr32_t pAAD;
+ uint32_t ulAADLen;
+} CK_AES_GMAC_PARAMS32;
+
+typedef struct CK_ECDH1_DERIVE_PARAMS32 {
+ uint32_t kdf;
+ uint32_t ulSharedDataLen;
+ caddr32_t pSharedData;
+ uint32_t ulPublicDataLen;
+ caddr32_t pPublicData;
+} CK_ECDH1_DERIVE_PARAMS32;
+
+#endif /* _SYSCALL32 */
+#endif /* _KERNEL */
+
+/*
+ * The measurement unit bit flag for a mechanism's minimum or maximum key size.
+ * The unit are mechanism dependent. It can be in bits or in bytes.
+ */
+typedef uint32_t crypto_keysize_unit_t;
+
+/*
+ * The following bit flags are valid in cm_mech_flags field in
+ * the crypto_mech_info_t structure of the SPI.
+ *
+ * Only the first two bit flags are valid in mi_keysize_unit
+ * field in the crypto_mechanism_info_t structure of the API.
+ */
+#define CRYPTO_KEYSIZE_UNIT_IN_BITS 0x00000001
+#define CRYPTO_KEYSIZE_UNIT_IN_BYTES 0x00000002
+#define CRYPTO_CAN_SHARE_OPSTATE 0x00000004 /* supports sharing */
+
+
+/* Mechanisms supported out-of-the-box */
+#define SUN_CKM_MD4 "CKM_MD4"
+#define SUN_CKM_MD5 "CKM_MD5"
+#define SUN_CKM_MD5_HMAC "CKM_MD5_HMAC"
+#define SUN_CKM_MD5_HMAC_GENERAL "CKM_MD5_HMAC_GENERAL"
+#define SUN_CKM_SHA1 "CKM_SHA_1"
+#define SUN_CKM_SHA1_HMAC "CKM_SHA_1_HMAC"
+#define SUN_CKM_SHA1_HMAC_GENERAL "CKM_SHA_1_HMAC_GENERAL"
+#define SUN_CKM_SHA256 "CKM_SHA256"
+#define SUN_CKM_SHA256_HMAC "CKM_SHA256_HMAC"
+#define SUN_CKM_SHA256_HMAC_GENERAL "CKM_SHA256_HMAC_GENERAL"
+#define SUN_CKM_SHA384 "CKM_SHA384"
+#define SUN_CKM_SHA384_HMAC "CKM_SHA384_HMAC"
+#define SUN_CKM_SHA384_HMAC_GENERAL "CKM_SHA384_HMAC_GENERAL"
+#define SUN_CKM_SHA512 "CKM_SHA512"
+#define SUN_CKM_SHA512_HMAC "CKM_SHA512_HMAC"
+#define SUN_CKM_SHA512_HMAC_GENERAL "CKM_SHA512_HMAC_GENERAL"
+#define SUN_CKM_DES_CBC "CKM_DES_CBC"
+#define SUN_CKM_DES3_CBC "CKM_DES3_CBC"
+#define SUN_CKM_DES_ECB "CKM_DES_ECB"
+#define SUN_CKM_DES3_ECB "CKM_DES3_ECB"
+#define SUN_CKM_BLOWFISH_CBC "CKM_BLOWFISH_CBC"
+#define SUN_CKM_BLOWFISH_ECB "CKM_BLOWFISH_ECB"
+#define SUN_CKM_AES_CBC "CKM_AES_CBC"
+#define SUN_CKM_AES_ECB "CKM_AES_ECB"
+#define SUN_CKM_AES_CTR "CKM_AES_CTR"
+#define SUN_CKM_AES_CCM "CKM_AES_CCM"
+#define SUN_CKM_AES_GCM "CKM_AES_GCM"
+#define SUN_CKM_AES_GMAC "CKM_AES_GMAC"
+#define SUN_CKM_AES_CFB128 "CKM_AES_CFB128"
+#define SUN_CKM_RC4 "CKM_RC4"
+#define SUN_CKM_RSA_PKCS "CKM_RSA_PKCS"
+#define SUN_CKM_RSA_X_509 "CKM_RSA_X_509"
+#define SUN_CKM_MD5_RSA_PKCS "CKM_MD5_RSA_PKCS"
+#define SUN_CKM_SHA1_RSA_PKCS "CKM_SHA1_RSA_PKCS"
+#define SUN_CKM_SHA256_RSA_PKCS "CKM_SHA256_RSA_PKCS"
+#define SUN_CKM_SHA384_RSA_PKCS "CKM_SHA384_RSA_PKCS"
+#define SUN_CKM_SHA512_RSA_PKCS "CKM_SHA512_RSA_PKCS"
+#define SUN_CKM_EC_KEY_PAIR_GEN "CKM_EC_KEY_PAIR_GEN"
+#define SUN_CKM_ECDH1_DERIVE "CKM_ECDH1_DERIVE"
+#define SUN_CKM_ECDSA_SHA1 "CKM_ECDSA_SHA1"
+#define SUN_CKM_ECDSA "CKM_ECDSA"
+
+/* Shared operation context format for CKM_RC4 */
+typedef struct {
+#if defined(__amd64)
+ uint32_t i, j;
+ uint32_t arr[256];
+ uint32_t flag;
+#else
+ uchar_t arr[256];
+ uchar_t i, j;
+#endif /* __amd64 */
+ uint64_t pad; /* For 64-bit alignment */
+} arcfour_state_t;
+
+/* Data arguments of cryptographic operations */
+
+typedef enum crypto_data_format {
+ CRYPTO_DATA_RAW = 1,
+ CRYPTO_DATA_UIO,
+ CRYPTO_DATA_MBLK
+} crypto_data_format_t;
+
+typedef struct crypto_data {
+ crypto_data_format_t cd_format; /* Format identifier */
+ off_t cd_offset; /* Offset from the beginning */
+ size_t cd_length; /* # of bytes in use */
+ caddr_t cd_miscdata; /* ancillary data */
+ union {
+ /* Raw format */
+ iovec_t cdu_raw; /* Pointer and length */
+
+ /* uio scatter-gather format */
+ uio_t *cdu_uio;
+
+ /* mblk scatter-gather format */
+ mblk_t *cdu_mp; /* The mblk chain */
+
+ } cdu; /* Crypto Data Union */
+} crypto_data_t;
+
+#define cd_raw cdu.cdu_raw
+#define cd_uio cdu.cdu_uio
+#define cd_mp cdu.cdu_mp
+
+#define CRYPTO_SET_RAW_DATA(var, str, len) \
+ (var).cd_format = CRYPTO_DATA_RAW; \
+ (var).cd_offset = 0; \
+ (var).cd_length = (len); \
+ (var).cd_miscdata = NULL; \
+ (var).cd_raw.iov_base = (caddr_t)(str); \
+ (var).cd_raw.iov_len = (len);
+
+#define CRYPTO_DATA_IS_USERSPACE(buf) \
+ ((buf->cd_format == CRYPTO_DATA_UIO && \
+ buf->cd_uio->uio_segflg == UIO_USERSPACE))
+
+typedef struct crypto_dual_data {
+ crypto_data_t dd_data; /* The data */
+ off_t dd_offset2; /* Used by dual operation */
+ size_t dd_len2; /* # of bytes to take */
+} crypto_dual_data_t;
+
+#define dd_format dd_data.cd_format
+#define dd_offset1 dd_data.cd_offset
+#define dd_len1 dd_data.cd_length
+#define dd_miscdata dd_data.cd_miscdata
+#define dd_raw dd_data.cd_raw
+#define dd_uio dd_data.cd_uio
+#define dd_mp dd_data.cd_mp
+
+/* The keys, and their contents */
+
+typedef enum {
+ CRYPTO_KEY_RAW = 1, /* ck_data is a cleartext key */
+ CRYPTO_KEY_REFERENCE, /* ck_obj_id is an opaque reference */
+ CRYPTO_KEY_ATTR_LIST /* ck_attrs is a list of object attributes */
+} crypto_key_format_t;
+
+typedef uint64_t crypto_attr_type_t;
+
+/* Attribute types to use for passing a RSA public key or a private key. */
+#define SUN_CKA_MODULUS 0x00000120
+#define SUN_CKA_MODULUS_BITS 0x00000121
+#define SUN_CKA_PUBLIC_EXPONENT 0x00000122
+#define SUN_CKA_PRIVATE_EXPONENT 0x00000123
+#define SUN_CKA_PRIME_1 0x00000124
+#define SUN_CKA_PRIME_2 0x00000125
+#define SUN_CKA_EXPONENT_1 0x00000126
+#define SUN_CKA_EXPONENT_2 0x00000127
+#define SUN_CKA_COEFFICIENT 0x00000128
+#define SUN_CKA_PRIME 0x00000130
+#define SUN_CKA_SUBPRIME 0x00000131
+#define SUN_CKA_BASE 0x00000132
+
+#define CKK_EC 0x00000003
+#define CKK_GENERIC_SECRET 0x00000010
+#define CKK_RC4 0x00000012
+#define CKK_AES 0x0000001F
+#define CKK_DES 0x00000013
+#define CKK_DES2 0x00000014
+#define CKK_DES3 0x00000015
+
+#define CKO_PUBLIC_KEY 0x00000002
+#define CKO_PRIVATE_KEY 0x00000003
+#define CKA_CLASS 0x00000000
+#define CKA_VALUE 0x00000011
+#define CKA_KEY_TYPE 0x00000100
+#define CKA_VALUE_LEN 0x00000161
+#define CKA_EC_PARAMS 0x00000180
+#define CKA_EC_POINT 0x00000181
+
+typedef uint32_t crypto_object_id_t;
+
+typedef struct crypto_object_attribute {
+ crypto_attr_type_t oa_type; /* attribute type */
+ caddr_t oa_value; /* attribute value */
+ ssize_t oa_value_len; /* length of attribute value */
+} crypto_object_attribute_t;
+
+typedef struct crypto_key {
+ crypto_key_format_t ck_format; /* format identifier */
+ union {
+ /* for CRYPTO_KEY_RAW ck_format */
+ struct {
+ uint_t cku_v_length; /* # of bits in ck_data */
+ void *cku_v_data; /* ptr to key value */
+ } cku_key_value;
+
+ /* for CRYPTO_KEY_REFERENCE ck_format */
+ crypto_object_id_t cku_key_id; /* reference to object key */
+
+ /* for CRYPTO_KEY_ATTR_LIST ck_format */
+ struct {
+ uint_t cku_a_count; /* number of attributes */
+ crypto_object_attribute_t *cku_a_oattr;
+ } cku_key_attrs;
+ } cku_data; /* Crypto Key union */
+} crypto_key_t;
+
+#ifdef _SYSCALL32
+
+typedef struct crypto_object_attribute32 {
+ uint64_t oa_type; /* attribute type */
+ caddr32_t oa_value; /* attribute value */
+ ssize32_t oa_value_len; /* length of attribute value */
+} crypto_object_attribute32_t;
+
+typedef struct crypto_key32 {
+ crypto_key_format_t ck_format; /* format identifier */
+ union {
+ /* for CRYPTO_KEY_RAW ck_format */
+ struct {
+ uint32_t cku_v_length; /* # of bytes in ck_data */
+ caddr32_t cku_v_data; /* ptr to key value */
+ } cku_key_value;
+
+ /* for CRYPTO_KEY_REFERENCE ck_format */
+ crypto_object_id_t cku_key_id; /* reference to object key */
+
+ /* for CRYPTO_KEY_ATTR_LIST ck_format */
+ struct {
+ uint32_t cku_a_count; /* number of attributes */
+ caddr32_t cku_a_oattr;
+ } cku_key_attrs;
+ } cku_data; /* Crypto Key union */
+} crypto_key32_t;
+
+#endif /* _SYSCALL32 */
+
+#define ck_data cku_data.cku_key_value.cku_v_data
+#define ck_length cku_data.cku_key_value.cku_v_length
+#define ck_obj_id cku_data.cku_key_id
+#define ck_count cku_data.cku_key_attrs.cku_a_count
+#define ck_attrs cku_data.cku_key_attrs.cku_a_oattr
+
+/*
+ * Raw key lengths are expressed in number of bits.
+ * The following macro returns the minimum number of
+ * bytes that can contain the specified number of bits.
+ * Round up without overflowing the integer type.
+ */
+#define CRYPTO_BITS2BYTES(n) ((n) == 0 ? 0 : (((n) - 1) >> 3) + 1)
+#define CRYPTO_BYTES2BITS(n) ((n) << 3)
+
+/* Providers */
+
+typedef enum {
+ CRYPTO_HW_PROVIDER = 0,
+ CRYPTO_SW_PROVIDER,
+ CRYPTO_LOGICAL_PROVIDER
+} crypto_provider_type_t;
+
+typedef uint32_t crypto_provider_id_t;
+#define KCF_PROVID_INVALID ((uint32_t)-1)
+
+typedef struct crypto_provider_entry {
+ crypto_provider_id_t pe_provider_id;
+ uint_t pe_mechanism_count;
+} crypto_provider_entry_t;
+
+typedef struct crypto_dev_list_entry {
+ char le_dev_name[MAXNAMELEN];
+ uint_t le_dev_instance;
+ uint_t le_mechanism_count;
+} crypto_dev_list_entry_t;
+
+/* User type for authentication ioctls and SPI entry points */
+
+typedef enum crypto_user_type {
+ CRYPTO_SO = 0,
+ CRYPTO_USER
+} crypto_user_type_t;
+
+/* Version for provider management ioctls and SPI entry points */
+
+typedef struct crypto_version {
+ uchar_t cv_major;
+ uchar_t cv_minor;
+} crypto_version_t;
+
+/* session data structure opaque to the consumer */
+typedef void *crypto_session_t;
+
+/* provider data structure opaque to the consumer */
+typedef void *crypto_provider_t;
+
+/* Limits used by both consumers and providers */
+#define CRYPTO_EXT_SIZE_LABEL 32
+#define CRYPTO_EXT_SIZE_MANUF 32
+#define CRYPTO_EXT_SIZE_MODEL 16
+#define CRYPTO_EXT_SIZE_SERIAL 16
+#define CRYPTO_EXT_SIZE_TIME 16
+
+typedef struct crypto_provider_ext_info {
+ uchar_t ei_label[CRYPTO_EXT_SIZE_LABEL];
+ uchar_t ei_manufacturerID[CRYPTO_EXT_SIZE_MANUF];
+ uchar_t ei_model[CRYPTO_EXT_SIZE_MODEL];
+ uchar_t ei_serial_number[CRYPTO_EXT_SIZE_SERIAL];
+ ulong_t ei_flags;
+ ulong_t ei_max_session_count;
+ ulong_t ei_max_pin_len;
+ ulong_t ei_min_pin_len;
+ ulong_t ei_total_public_memory;
+ ulong_t ei_free_public_memory;
+ ulong_t ei_total_private_memory;
+ ulong_t ei_free_private_memory;
+ crypto_version_t ei_hardware_version;
+ crypto_version_t ei_firmware_version;
+ uchar_t ei_time[CRYPTO_EXT_SIZE_TIME];
+ int ei_hash_max_input_len;
+ int ei_hmac_max_input_len;
+} crypto_provider_ext_info_t;
+
+typedef uint_t crypto_session_id_t;
+
+typedef enum cmd_type {
+ COPY_FROM_DATA,
+ COPY_TO_DATA,
+ COMPARE_TO_DATA,
+ MD5_DIGEST_DATA,
+ SHA1_DIGEST_DATA,
+ SHA2_DIGEST_DATA,
+ GHASH_DATA
+} cmd_type_t;
+
+#define CRYPTO_DO_UPDATE 0x01
+#define CRYPTO_DO_FINAL 0x02
+#define CRYPTO_DO_MD5 0x04
+#define CRYPTO_DO_SHA1 0x08
+#define CRYPTO_DO_SIGN 0x10
+#define CRYPTO_DO_VERIFY 0x20
+#define CRYPTO_DO_SHA2 0x40
+
+#define PROVIDER_OWNS_KEY_SCHEDULE 0x00000001
+
+/*
+ * Common cryptographic status and error codes.
+ */
+#define CRYPTO_SUCCESS 0x00000000
+#define CRYPTO_CANCEL 0x00000001
+#define CRYPTO_HOST_MEMORY 0x00000002
+#define CRYPTO_GENERAL_ERROR 0x00000003
+#define CRYPTO_FAILED 0x00000004
+#define CRYPTO_ARGUMENTS_BAD 0x00000005
+#define CRYPTO_ATTRIBUTE_READ_ONLY 0x00000006
+#define CRYPTO_ATTRIBUTE_SENSITIVE 0x00000007
+#define CRYPTO_ATTRIBUTE_TYPE_INVALID 0x00000008
+#define CRYPTO_ATTRIBUTE_VALUE_INVALID 0x00000009
+#define CRYPTO_CANCELED 0x0000000A
+#define CRYPTO_DATA_INVALID 0x0000000B
+#define CRYPTO_DATA_LEN_RANGE 0x0000000C
+#define CRYPTO_DEVICE_ERROR 0x0000000D
+#define CRYPTO_DEVICE_MEMORY 0x0000000E
+#define CRYPTO_DEVICE_REMOVED 0x0000000F
+#define CRYPTO_ENCRYPTED_DATA_INVALID 0x00000010
+#define CRYPTO_ENCRYPTED_DATA_LEN_RANGE 0x00000011
+#define CRYPTO_KEY_HANDLE_INVALID 0x00000012
+#define CRYPTO_KEY_SIZE_RANGE 0x00000013
+#define CRYPTO_KEY_TYPE_INCONSISTENT 0x00000014
+#define CRYPTO_KEY_NOT_NEEDED 0x00000015
+#define CRYPTO_KEY_CHANGED 0x00000016
+#define CRYPTO_KEY_NEEDED 0x00000017
+#define CRYPTO_KEY_INDIGESTIBLE 0x00000018
+#define CRYPTO_KEY_FUNCTION_NOT_PERMITTED 0x00000019
+#define CRYPTO_KEY_NOT_WRAPPABLE 0x0000001A
+#define CRYPTO_KEY_UNEXTRACTABLE 0x0000001B
+#define CRYPTO_MECHANISM_INVALID 0x0000001C
+#define CRYPTO_MECHANISM_PARAM_INVALID 0x0000001D
+#define CRYPTO_OBJECT_HANDLE_INVALID 0x0000001E
+#define CRYPTO_OPERATION_IS_ACTIVE 0x0000001F
+#define CRYPTO_OPERATION_NOT_INITIALIZED 0x00000020
+#define CRYPTO_PIN_INCORRECT 0x00000021
+#define CRYPTO_PIN_INVALID 0x00000022
+#define CRYPTO_PIN_LEN_RANGE 0x00000023
+#define CRYPTO_PIN_EXPIRED 0x00000024
+#define CRYPTO_PIN_LOCKED 0x00000025
+#define CRYPTO_SESSION_CLOSED 0x00000026
+#define CRYPTO_SESSION_COUNT 0x00000027
+#define CRYPTO_SESSION_HANDLE_INVALID 0x00000028
+#define CRYPTO_SESSION_READ_ONLY 0x00000029
+#define CRYPTO_SESSION_EXISTS 0x0000002A
+#define CRYPTO_SESSION_READ_ONLY_EXISTS 0x0000002B
+#define CRYPTO_SESSION_READ_WRITE_SO_EXISTS 0x0000002C
+#define CRYPTO_SIGNATURE_INVALID 0x0000002D
+#define CRYPTO_SIGNATURE_LEN_RANGE 0x0000002E
+#define CRYPTO_TEMPLATE_INCOMPLETE 0x0000002F
+#define CRYPTO_TEMPLATE_INCONSISTENT 0x00000030
+#define CRYPTO_UNWRAPPING_KEY_HANDLE_INVALID 0x00000031
+#define CRYPTO_UNWRAPPING_KEY_SIZE_RANGE 0x00000032
+#define CRYPTO_UNWRAPPING_KEY_TYPE_INCONSISTENT 0x00000033
+#define CRYPTO_USER_ALREADY_LOGGED_IN 0x00000034
+#define CRYPTO_USER_NOT_LOGGED_IN 0x00000035
+#define CRYPTO_USER_PIN_NOT_INITIALIZED 0x00000036
+#define CRYPTO_USER_TYPE_INVALID 0x00000037
+#define CRYPTO_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000038
+#define CRYPTO_USER_TOO_MANY_TYPES 0x00000039
+#define CRYPTO_WRAPPED_KEY_INVALID 0x0000003A
+#define CRYPTO_WRAPPED_KEY_LEN_RANGE 0x0000003B
+#define CRYPTO_WRAPPING_KEY_HANDLE_INVALID 0x0000003C
+#define CRYPTO_WRAPPING_KEY_SIZE_RANGE 0x0000003D
+#define CRYPTO_WRAPPING_KEY_TYPE_INCONSISTENT 0x0000003E
+#define CRYPTO_RANDOM_SEED_NOT_SUPPORTED 0x0000003F
+#define CRYPTO_RANDOM_NO_RNG 0x00000040
+#define CRYPTO_DOMAIN_PARAMS_INVALID 0x00000041
+#define CRYPTO_BUFFER_TOO_SMALL 0x00000042
+#define CRYPTO_INFORMATION_SENSITIVE 0x00000043
+#define CRYPTO_NOT_SUPPORTED 0x00000044
+
+#define CRYPTO_QUEUED 0x00000045
+#define CRYPTO_BUFFER_TOO_BIG 0x00000046
+#define CRYPTO_INVALID_CONTEXT 0x00000047
+#define CRYPTO_INVALID_MAC 0x00000048
+#define CRYPTO_MECH_NOT_SUPPORTED 0x00000049
+#define CRYPTO_INCONSISTENT_ATTRIBUTE 0x0000004A
+#define CRYPTO_NO_PERMISSION 0x0000004B
+#define CRYPTO_INVALID_PROVIDER_ID 0x0000004C
+#define CRYPTO_VERSION_MISMATCH 0x0000004D
+#define CRYPTO_BUSY 0x0000004E
+#define CRYPTO_UNKNOWN_PROVIDER 0x0000004F
+#define CRYPTO_MODVERIFICATION_FAILED 0x00000050
+#define CRYPTO_OLD_CTX_TEMPLATE 0x00000051
+#define CRYPTO_WEAK_KEY 0x00000052
+#define CRYPTO_FIPS140_ERROR 0x00000053
+/*
+ * Don't forget to update CRYPTO_LAST_ERROR and the error_number_table[]
+ * in kernelUtil.c when new error code is added.
+ */
+#define CRYPTO_LAST_ERROR 0x00000053
+
+/*
+ * Special values that can be used to indicate that information is unavailable
+ * or that there is not practical limit. These values can be used
+ * by fields of the SPI crypto_provider_ext_info(9S) structure.
+ * The value of CRYPTO_UNAVAILABLE_INFO should be the same as
+ * CK_UNAVAILABLE_INFO in the PKCS#11 spec.
+ */
+#define CRYPTO_UNAVAILABLE_INFO ((ulong_t)(-1))
+#define CRYPTO_EFFECTIVELY_INFINITE 0x0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_CRYPTO_COMMON_H */
diff --git a/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/spi.h b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/spi.h
new file mode 100644
index 00000000000..bf1668509c0
--- /dev/null
+++ b/jdk/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto/sys_old/crypto/spi.h
@@ -0,0 +1,791 @@
+/*
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef _SYS_CRYPTO_SPI_H
+#define _SYS_CRYPTO_SPI_H
+
+/*
+ * CSPI: Cryptographic Service Provider Interface.
+ */
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _KERNEL
+#include
+#include
+#include
+
+#define CRYPTO_SPI_VERSION_1 1
+#define CRYPTO_SPI_VERSION_2 2
+#define CRYPTO_SPI_VERSION_3 3
+#define CRYPTO_SPI_VERSION_4 4
+#define CRYPTO_SPI_VERSION_5 5
+
+#define CRYPTO_OPS_OFFSET(f) offsetof(crypto_ops_t, co_##f)
+#define CRYPTO_PROVIDER_OFFSET(f) \
+ offsetof(crypto_provider_management_ops_t, f)
+#define CRYPTO_OBJECT_OFFSET(f) offsetof(crypto_object_ops_t, f)
+#define CRYPTO_SESSION_OFFSET(f) offsetof(crypto_session_ops_t, f)
+
+#endif
+
+/*
+ * Provider-private handle. This handle is specified by a provider
+ * when it registers by means of the pi_provider_handle field of
+ * the crypto_provider_info structure, and passed to the provider
+ * when its entry points are invoked.
+ */
+typedef void *crypto_provider_handle_t;
+
+/*
+ * Context templates can be used to by software providers to pre-process
+ * keying material, such as key schedules. They are allocated by
+ * a software provider create_ctx_template(9E) entry point, and passed
+ * as argument to initialization and atomic provider entry points.
+ */
+typedef void *crypto_spi_ctx_template_t;
+
+/*
+ * Request handles are used by the kernel to identify an asynchronous
+ * request being processed by a provider. It is passed by the kernel
+ * to a hardware provider when submitting a request, and must be
+ * specified by a provider when calling crypto_op_notification(9F)
+ */
+typedef void *crypto_req_handle_t;
+
+/*
+ * The context structure is passed from kcf to a provider in kernel and
+ * internally in libsoftcrypto between ucrypto and the algorithm.
+ * It contains the information needed to process a multi-part or
+ * single part operation. The context structure is not used
+ * by atomic operations.
+ *
+ * Parameters needed to perform a cryptographic operation, such
+ * as keys, mechanisms, input and output buffers, are passed
+ * as separate arguments to Provider routines.
+ */
+typedef struct crypto_ctx {
+ crypto_provider_handle_t cc_provider;
+ crypto_session_id_t cc_session;
+ void *cc_provider_private; /* owned by provider */
+ void *cc_framework_private; /* owned by framework */
+ uint32_t cc_flags; /* flags */
+ void *cc_opstate; /* state */
+} crypto_ctx_t;
+
+#ifdef _KERNEL
+
+/* Values for cc_flags field */
+#define CRYPTO_INIT_OPSTATE 0x00000001 /* allocate and init cc_opstate */
+#define CRYPTO_USE_OPSTATE 0x00000002 /* .. start using it as context */
+
+/*
+ * Extended provider information.
+ */
+
+/*
+ * valid values for ei_flags field of extended info structure
+ * They match the RSA Security, Inc PKCS#11 tokenInfo flags.
+ */
+#define CRYPTO_EXTF_RNG 0x00000001
+#define CRYPTO_EXTF_WRITE_PROTECTED 0x00000002
+#define CRYPTO_EXTF_LOGIN_REQUIRED 0x00000004
+#define CRYPTO_EXTF_USER_PIN_INITIALIZED 0x00000008
+#define CRYPTO_EXTF_CLOCK_ON_TOKEN 0x00000040
+#define CRYPTO_EXTF_PROTECTED_AUTHENTICATION_PATH 0x00000100
+#define CRYPTO_EXTF_DUAL_CRYPTO_OPERATIONS 0x00000200
+#define CRYPTO_EXTF_TOKEN_INITIALIZED 0x00000400
+#define CRYPTO_EXTF_USER_PIN_COUNT_LOW 0x00010000
+#define CRYPTO_EXTF_USER_PIN_FINAL_TRY 0x00020000
+#define CRYPTO_EXTF_USER_PIN_LOCKED 0x00040000
+#define CRYPTO_EXTF_USER_PIN_TO_BE_CHANGED 0x00080000
+#define CRYPTO_EXTF_SO_PIN_COUNT_LOW 0x00100000
+#define CRYPTO_EXTF_SO_PIN_FINAL_TRY 0x00200000
+#define CRYPTO_EXTF_SO_PIN_LOCKED 0x00400000
+#define CRYPTO_EXTF_SO_PIN_TO_BE_CHANGED 0x00800000
+
+/*
+ * The crypto_control_ops structure contains pointers to control
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_control_ops {
+ void (*provider_status)(crypto_provider_handle_t, uint_t *);
+} crypto_control_ops_t;
+
+/*
+ * The crypto_ctx_ops structure contains points to context and context
+ * templates management operations for cryptographic providers. It is
+ * passed through the crypto_ops(9S) structure when providers register
+ * with the kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_ctx_ops {
+ int (*create_ctx_template)(crypto_provider_handle_t,
+ crypto_mechanism_t *, crypto_key_t *,
+ crypto_spi_ctx_template_t *, size_t *, crypto_req_handle_t);
+ int (*free_context)(crypto_ctx_t *);
+} crypto_ctx_ops_t;
+
+/*
+ * The crypto_digest_ops structure contains pointers to digest
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_digest_ops {
+ int (*digest_init)(crypto_ctx_t *, crypto_mechanism_t *,
+ crypto_req_handle_t);
+ int (*digest)(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
+ crypto_req_handle_t);
+ int (*digest_update)(crypto_ctx_t *, crypto_data_t *,
+ crypto_req_handle_t);
+ int (*digest_key)(crypto_ctx_t *, crypto_key_t *, crypto_req_handle_t);
+ int (*digest_final)(crypto_ctx_t *, crypto_data_t *,
+ crypto_req_handle_t);
+ int (*digest_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_data_t *,
+ crypto_data_t *, crypto_req_handle_t);
+} crypto_digest_ops_t;
+
+/*
+ * The crypto_cipher_ops structure contains pointers to encryption
+ * and decryption operations for cryptographic providers. It is
+ * passed through the crypto_ops(9S) structure when providers register
+ * with the kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_cipher_ops {
+ int (*encrypt_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*encrypt)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*encrypt_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*encrypt_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*encrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t);
+
+ int (*decrypt_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*decrypt)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*decrypt_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*decrypt_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*decrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t);
+} crypto_cipher_ops_t;
+
+/*
+ * The crypto_mac_ops structure contains pointers to MAC
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_mac_ops {
+ int (*mac_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*mac)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*mac_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*mac_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*mac_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*mac_verify_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+} crypto_mac_ops_t;
+
+/*
+ * The crypto_sign_ops structure contains pointers to signing
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_sign_ops {
+ int (*sign_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*sign)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*sign_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*sign_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*sign_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*sign_recover_init)(crypto_ctx_t *, crypto_mechanism_t *,
+ crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*sign_recover)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*sign_recover_atomic)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
+ crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+} crypto_sign_ops_t;
+
+/*
+ * The crypto_verify_ops structure contains pointers to verify
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_verify_ops {
+ int (*verify_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*verify)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*verify_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*verify_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*verify_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*verify_recover_init)(crypto_ctx_t *, crypto_mechanism_t *,
+ crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+ int (*verify_recover)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*verify_recover_atomic)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
+ crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_req_handle_t);
+} crypto_verify_ops_t;
+
+/*
+ * The crypto_dual_ops structure contains pointers to dual
+ * cipher and sign/verify operations for cryptographic providers.
+ * It is passed through the crypto_ops(9S) structure when
+ * providers register with the kernel using
+ * crypto_register_provider(9F).
+ */
+typedef struct crypto_dual_ops {
+ int (*digest_encrypt_update)(
+ crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*decrypt_digest_update)(
+ crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*sign_encrypt_update)(
+ crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *,
+ crypto_data_t *, crypto_req_handle_t);
+ int (*decrypt_verify_update)(
+ crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *,
+ crypto_data_t *, crypto_req_handle_t);
+} crypto_dual_ops_t;
+
+/*
+ * The crypto_dual_cipher_mac_ops structure contains pointers to dual
+ * cipher and MAC operations for cryptographic providers.
+ * It is passed through the crypto_ops(9S) structure when
+ * providers register with the kernel using
+ * crypto_register_provider(9F).
+ */
+typedef struct crypto_dual_cipher_mac_ops {
+ int (*encrypt_mac_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *,
+ crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*encrypt_mac)(crypto_ctx_t *,
+ crypto_data_t *, crypto_dual_data_t *, crypto_data_t *,
+ crypto_req_handle_t);
+ int (*encrypt_mac_update)(crypto_ctx_t *,
+ crypto_data_t *, crypto_dual_data_t *, crypto_req_handle_t);
+ int (*encrypt_mac_final)(crypto_ctx_t *,
+ crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*encrypt_mac_atomic)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *,
+ crypto_key_t *, crypto_data_t *, crypto_dual_data_t *,
+ crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+
+ int (*mac_decrypt_init)(crypto_ctx_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_mechanism_t *,
+ crypto_key_t *, crypto_spi_ctx_template_t,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*mac_decrypt)(crypto_ctx_t *,
+ crypto_dual_data_t *, crypto_data_t *, crypto_data_t *,
+ crypto_req_handle_t);
+ int (*mac_decrypt_update)(crypto_ctx_t *,
+ crypto_dual_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*mac_decrypt_final)(crypto_ctx_t *,
+ crypto_data_t *, crypto_data_t *, crypto_req_handle_t);
+ int (*mac_decrypt_atomic)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *,
+ crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+ int (*mac_verify_decrypt_atomic)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
+ crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *,
+ crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
+ crypto_spi_ctx_template_t, crypto_req_handle_t);
+} crypto_dual_cipher_mac_ops_t;
+
+/*
+ * The crypto_random_number_ops structure contains pointers to random
+ * number operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_random_number_ops {
+ int (*seed_random)(crypto_provider_handle_t, crypto_session_id_t,
+ uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t);
+ int (*generate_random)(crypto_provider_handle_t, crypto_session_id_t,
+ uchar_t *, size_t, crypto_req_handle_t);
+} crypto_random_number_ops_t;
+
+/*
+ * Flag values for seed_random.
+ */
+#define CRYPTO_SEED_NOW 0x00000001
+
+/*
+ * The crypto_session_ops structure contains pointers to session
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_session_ops {
+ int (*session_open)(crypto_provider_handle_t, crypto_session_id_t *,
+ crypto_req_handle_t);
+ int (*session_close)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_req_handle_t);
+ int (*session_login)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_user_type_t, char *, size_t, crypto_req_handle_t);
+ int (*session_logout)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_req_handle_t);
+} crypto_session_ops_t;
+
+/*
+ * The crypto_object_ops structure contains pointers to object
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_object_ops {
+ int (*object_create)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_object_attribute_t *, uint_t, crypto_object_id_t *,
+ crypto_req_handle_t);
+ int (*object_copy)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_object_id_t, crypto_object_attribute_t *, uint_t,
+ crypto_object_id_t *, crypto_req_handle_t);
+ int (*object_destroy)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_object_id_t, crypto_req_handle_t);
+ int (*object_get_size)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_object_id_t, size_t *, crypto_req_handle_t);
+ int (*object_get_attribute_value)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_object_id_t,
+ crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
+ int (*object_set_attribute_value)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_object_id_t,
+ crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
+ int (*object_find_init)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_object_attribute_t *, uint_t, void **,
+ crypto_req_handle_t);
+ int (*object_find)(crypto_provider_handle_t, void *,
+ crypto_object_id_t *, uint_t, uint_t *, crypto_req_handle_t);
+ int (*object_find_final)(crypto_provider_handle_t, void *,
+ crypto_req_handle_t);
+} crypto_object_ops_t;
+
+/*
+ * The crypto_key_ops structure contains pointers to key
+ * operations for cryptographic providers. It is passed through
+ * the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_key_ops {
+ int (*key_generate)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_object_attribute_t *, uint_t,
+ crypto_object_id_t *, crypto_req_handle_t);
+ int (*key_generate_pair)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_object_attribute_t *, uint_t,
+ crypto_object_attribute_t *, uint_t, crypto_object_id_t *,
+ crypto_object_id_t *, crypto_req_handle_t);
+ int (*key_wrap)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_object_id_t *,
+ uchar_t *, size_t *, crypto_req_handle_t);
+ int (*key_unwrap)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, uchar_t *, size_t *,
+ crypto_object_attribute_t *, uint_t,
+ crypto_object_id_t *, crypto_req_handle_t);
+ int (*key_derive)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *,
+ uint_t, crypto_object_id_t *, crypto_req_handle_t);
+ int (*key_check)(crypto_provider_handle_t, crypto_mechanism_t *,
+ crypto_key_t *);
+} crypto_key_ops_t;
+
+/*
+ * The crypto_provider_management_ops structure contains pointers
+ * to management operations for cryptographic providers. It is passed
+ * through the crypto_ops(9S) structure when providers register with the
+ * kernel using crypto_register_provider(9F).
+ */
+typedef struct crypto_provider_management_ops {
+ int (*ext_info)(crypto_provider_handle_t,
+ crypto_provider_ext_info_t *, crypto_req_handle_t);
+ int (*init_token)(crypto_provider_handle_t, char *, size_t,
+ char *, crypto_req_handle_t);
+ int (*init_pin)(crypto_provider_handle_t, crypto_session_id_t,
+ char *, size_t, crypto_req_handle_t);
+ int (*set_pin)(crypto_provider_handle_t, crypto_session_id_t,
+ char *, size_t, char *, size_t, crypto_req_handle_t);
+} crypto_provider_management_ops_t;
+
+typedef struct crypto_mech_ops {
+ int (*copyin_mechanism)(crypto_provider_handle_t,
+ crypto_mechanism_t *, crypto_mechanism_t *, int *, int);
+ int (*copyout_mechanism)(crypto_provider_handle_t,
+ crypto_mechanism_t *, crypto_mechanism_t *, int *, int);
+ int (*free_mechanism)(crypto_provider_handle_t, crypto_mechanism_t *);
+} crypto_mech_ops_t;
+
+typedef struct crypto_nostore_key_ops {
+ int (*nostore_key_generate)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *,
+ crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
+ uint_t, crypto_req_handle_t);
+ int (*nostore_key_generate_pair)(crypto_provider_handle_t,
+ crypto_session_id_t, crypto_mechanism_t *,
+ crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
+ uint_t, crypto_object_attribute_t *, uint_t,
+ crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
+ int (*nostore_key_derive)(crypto_provider_handle_t, crypto_session_id_t,
+ crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *,
+ uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
+} crypto_nostore_key_ops_t;
+
+/*
+ * crypto_fips140_ops provides a function for FIPS 140 Power-On Self Test for
+ * those providers that are part of the Cryptographic Framework bounday. See
+ * crypto_fips140_ops(9s) for details.
+ */
+typedef struct crypto_fips140_ops {
+ void (*fips140_post)(int *);
+} crypto_fips140_ops_t;
+
+/*
+ * The crypto_ops(9S) structure contains the structures containing
+ * the pointers to functions implemented by cryptographic providers.
+ * It is specified as part of the crypto_provider_info(9S)
+ * supplied by a provider when it registers with the kernel
+ * by calling crypto_register_provider(9F).
+ */
+typedef struct crypto_ops_v1 {
+ crypto_control_ops_t *co_control_ops;
+ crypto_digest_ops_t *co_digest_ops;
+ crypto_cipher_ops_t *co_cipher_ops;
+ crypto_mac_ops_t *co_mac_ops;
+ crypto_sign_ops_t *co_sign_ops;
+ crypto_verify_ops_t *co_verify_ops;
+ crypto_dual_ops_t *co_dual_ops;
+ crypto_dual_cipher_mac_ops_t *co_dual_cipher_mac_ops;
+ crypto_random_number_ops_t *co_random_ops;
+ crypto_session_ops_t *co_session_ops;
+ crypto_object_ops_t *co_object_ops;
+ crypto_key_ops_t *co_key_ops;
+ crypto_provider_management_ops_t *co_provider_ops;
+ crypto_ctx_ops_t *co_ctx_ops;
+} crypto_ops_v1_t;
+
+typedef struct crypto_ops_v2 {
+ crypto_ops_v1_t v1_ops;
+ crypto_mech_ops_t *co_mech_ops;
+} crypto_ops_v2_t;
+
+typedef struct crypto_ops_v3 {
+ crypto_ops_v2_t v2_ops;
+ crypto_nostore_key_ops_t *co_nostore_key_ops;
+} crypto_ops_v3_t;
+
+typedef struct crypto_ops_v4 {
+ crypto_ops_v3_t v3_ops;
+ crypto_fips140_ops_t *co_fips140_ops;
+} crypto_ops_v4_t;
+
+typedef struct crypto_ops_v5 {
+ crypto_ops_v4_t v4_ops;
+ boolean_t co_uio_userspace_ok;
+} crypto_ops_v5_t;
+
+typedef struct crypto_ops {
+ union {
+ crypto_ops_v5_t cou_v5;
+ crypto_ops_v4_t cou_v4;
+ crypto_ops_v3_t cou_v3;
+ crypto_ops_v2_t cou_v2;
+ crypto_ops_v1_t cou_v1;
+ } cou;
+} crypto_ops_t;
+
+#define co_control_ops cou.cou_v1.co_control_ops
+#define co_digest_ops cou.cou_v1.co_digest_ops
+#define co_cipher_ops cou.cou_v1.co_cipher_ops
+#define co_mac_ops cou.cou_v1.co_mac_ops
+#define co_sign_ops cou.cou_v1.co_sign_ops
+#define co_verify_ops cou.cou_v1.co_verify_ops
+#define co_dual_ops cou.cou_v1.co_dual_ops
+#define co_dual_cipher_mac_ops cou.cou_v1.co_dual_cipher_mac_ops
+#define co_random_ops cou.cou_v1.co_random_ops
+#define co_session_ops cou.cou_v1.co_session_ops
+#define co_object_ops cou.cou_v1.co_object_ops
+#define co_key_ops cou.cou_v1.co_key_ops
+#define co_provider_ops cou.cou_v1.co_provider_ops
+#define co_ctx_ops cou.cou_v1.co_ctx_ops
+#define co_mech_ops cou.cou_v2.co_mech_ops
+#define co_nostore_key_ops cou.cou_v3.co_nostore_key_ops
+#define co_fips140_ops cou.cou_v4.co_fips140_ops
+#define co_uio_userspace_ok cou.cou_v5.co_uio_userspace_ok
+
+/*
+ * Provider device specification passed during registration.
+ *
+ * Software providers set the pi_provider_type field of provider_info_t
+ * to CRYPTO_SW_PROVIDER, and set the pd_sw field of
+ * crypto_provider_dev_t to the address of their modlinkage.
+ *
+ * Hardware providers set the pi_provider_type field of provider_info_t
+ * to CRYPTO_HW_PROVIDER, and set the pd_hw field of
+ * crypto_provider_dev_t to the dev_info structure corresponding
+ * to the device instance being registered.
+ *
+ * Logical providers set the pi_provider_type field of provider_info_t
+ * to CRYPTO_LOGICAL_PROVIDER, and set the pd_hw field of
+ * crypto_provider_dev_t to the dev_info structure corresponding
+ * to the device instance being registered.
+ */
+
+typedef union crypto_provider_dev {
+ struct modlinkage *pd_sw; /* for CRYPTO_SW_PROVIDER */
+ dev_info_t *pd_hw; /* for CRYPTO_HW_PROVIDER */
+} crypto_provider_dev_t;
+
+/*
+ * The mechanism info structure crypto_mech_info_t contains a function group
+ * bit mask cm_func_group_mask. This field, of type crypto_func_group_t,
+ * specifies the provider entry point that can be used a particular
+ * mechanism. The function group mask is a combination of the following values.
+ */
+
+typedef uint32_t crypto_func_group_t;
+
+#endif /* _KERNEL */
+
+#define CRYPTO_FG_ENCRYPT 0x00000001 /* encrypt_init() */
+#define CRYPTO_FG_DECRYPT 0x00000002 /* decrypt_init() */
+#define CRYPTO_FG_DIGEST 0x00000004 /* digest_init() */
+#define CRYPTO_FG_SIGN 0x00000008 /* sign_init() */
+#define CRYPTO_FG_SIGN_RECOVER 0x00000010 /* sign_recover_init() */
+#define CRYPTO_FG_VERIFY 0x00000020 /* verify_init() */
+#define CRYPTO_FG_VERIFY_RECOVER 0x00000040 /* verify_recover_init() */
+#define CRYPTO_FG_GENERATE 0x00000080 /* key_generate() */
+#define CRYPTO_FG_GENERATE_KEY_PAIR 0x00000100 /* key_generate_pair() */
+#define CRYPTO_FG_WRAP 0x00000200 /* key_wrap() */
+#define CRYPTO_FG_UNWRAP 0x00000400 /* key_unwrap() */
+#define CRYPTO_FG_DERIVE 0x00000800 /* key_derive() */
+#define CRYPTO_FG_MAC 0x00001000 /* mac_init() */
+#define CRYPTO_FG_ENCRYPT_MAC 0x00002000 /* encrypt_mac_init() */
+#define CRYPTO_FG_MAC_DECRYPT 0x00004000 /* decrypt_mac_init() */
+#define CRYPTO_FG_ENCRYPT_ATOMIC 0x00008000 /* encrypt_atomic() */
+#define CRYPTO_FG_DECRYPT_ATOMIC 0x00010000 /* decrypt_atomic() */
+#define CRYPTO_FG_MAC_ATOMIC 0x00020000 /* mac_atomic() */
+#define CRYPTO_FG_DIGEST_ATOMIC 0x00040000 /* digest_atomic() */
+#define CRYPTO_FG_SIGN_ATOMIC 0x00080000 /* sign_atomic() */
+#define CRYPTO_FG_SIGN_RECOVER_ATOMIC 0x00100000 /* sign_recover_atomic() */
+#define CRYPTO_FG_VERIFY_ATOMIC 0x00200000 /* verify_atomic() */
+#define CRYPTO_FG_VERIFY_RECOVER_ATOMIC 0x00400000 /* verify_recover_atomic() */
+#define CRYPTO_FG_ENCRYPT_MAC_ATOMIC 0x00800000 /* encrypt_mac_atomic() */
+#define CRYPTO_FG_MAC_DECRYPT_ATOMIC 0x01000000 /* mac_decrypt_atomic() */
+#define CRYPTO_FG_RESERVED 0x80000000
+
+/*
+ * Maximum length of the pi_provider_description field of the
+ * crypto_provider_info structure.
+ */
+#define CRYPTO_PROVIDER_DESCR_MAX_LEN 64
+
+#ifdef _KERNEL
+
+/* Bit mask for all the simple operations */
+#define CRYPTO_FG_SIMPLEOP_MASK (CRYPTO_FG_ENCRYPT | CRYPTO_FG_DECRYPT | \
+ CRYPTO_FG_DIGEST | CRYPTO_FG_SIGN | CRYPTO_FG_VERIFY | CRYPTO_FG_MAC | \
+ CRYPTO_FG_ENCRYPT_ATOMIC | CRYPTO_FG_DECRYPT_ATOMIC | \
+ CRYPTO_FG_MAC_ATOMIC | CRYPTO_FG_DIGEST_ATOMIC | CRYPTO_FG_SIGN_ATOMIC | \
+ CRYPTO_FG_VERIFY_ATOMIC)
+
+/* Bit mask for all the dual operations */
+#define CRYPTO_FG_MAC_CIPHER_MASK (CRYPTO_FG_ENCRYPT_MAC | \
+ CRYPTO_FG_MAC_DECRYPT | CRYPTO_FG_ENCRYPT_MAC_ATOMIC | \
+ CRYPTO_FG_MAC_DECRYPT_ATOMIC)
+
+/* Add other combos to CRYPTO_FG_DUAL_MASK */
+#define CRYPTO_FG_DUAL_MASK CRYPTO_FG_MAC_CIPHER_MASK
+
+/*
+ * The crypto_mech_info structure specifies one of the mechanisms
+ * supported by a cryptographic provider. The pi_mechanisms field of
+ * the crypto_provider_info structure contains a pointer to an array
+ * of crypto_mech_info's.
+ */
+typedef struct crypto_mech_info {
+ crypto_mech_name_t cm_mech_name;
+ crypto_mech_type_t cm_mech_number;
+ crypto_func_group_t cm_func_group_mask;
+ ssize_t cm_min_key_length;
+ ssize_t cm_max_key_length;
+ uint32_t cm_mech_flags;
+} crypto_mech_info_t;
+
+/* Alias the old name to the new name for compatibility. */
+#define cm_keysize_unit cm_mech_flags
+
+/*
+ * crypto_kcf_provider_handle_t is a handle allocated by the kernel.
+ * It is returned after the provider registers with
+ * crypto_register_provider(), and must be specified by the provider
+ * when calling crypto_unregister_provider(), and
+ * crypto_provider_notification().
+ */
+typedef uint_t crypto_kcf_provider_handle_t;
+
+/*
+ * Provider information. Passed as argument to crypto_register_provider(9F).
+ * Describes the provider and its capabilities. Multiple providers can
+ * register for the same device instance. In this case, the same
+ * pi_provider_dev must be specified with a different pi_provider_handle.
+ */
+typedef struct crypto_provider_info_v1 {
+ uint_t pi_interface_version;
+ char *pi_provider_description;
+ crypto_provider_type_t pi_provider_type;
+ crypto_provider_dev_t pi_provider_dev;
+ crypto_provider_handle_t pi_provider_handle;
+ crypto_ops_t *pi_ops_vector;
+ uint_t pi_mech_list_count;
+ crypto_mech_info_t *pi_mechanisms;
+ uint_t pi_logical_provider_count;
+ crypto_kcf_provider_handle_t *pi_logical_providers;
+} crypto_provider_info_v1_t;
+
+typedef struct crypto_provider_info_v2 {
+ crypto_provider_info_v1_t v1_info;
+ uint_t pi_flags;
+} crypto_provider_info_v2_t;
+
+typedef struct crypto_provider_info {
+ union {
+ crypto_provider_info_v2_t piu_v2;
+ crypto_provider_info_v1_t piu_v1;
+ } piu;
+} crypto_provider_info_t;
+
+#define pi_interface_version piu.piu_v1.pi_interface_version
+#define pi_provider_description piu.piu_v1.pi_provider_description
+#define pi_provider_type piu.piu_v1.pi_provider_type
+#define pi_provider_dev piu.piu_v1.pi_provider_dev
+#define pi_provider_handle piu.piu_v1.pi_provider_handle
+#define pi_ops_vector piu.piu_v1.pi_ops_vector
+#define pi_mech_list_count piu.piu_v1.pi_mech_list_count
+#define pi_mechanisms piu.piu_v1.pi_mechanisms
+#define pi_logical_provider_count piu.piu_v1.pi_logical_provider_count
+#define pi_logical_providers piu.piu_v1.pi_logical_providers
+#define pi_flags piu.piu_v2.pi_flags
+
+/* hidden providers can only be accessed via a logical provider */
+#define CRYPTO_HIDE_PROVIDER 0x00000001
+/*
+ * provider can not do multi-part digest (updates) and has a limit
+ * on maximum input data that it can digest. The provider sets
+ * this value in crypto_provider_ext_info_t by implementing
+ * the ext_info entry point in the co_provider_ops vector.
+ */
+#define CRYPTO_HASH_NO_UPDATE 0x00000002
+/*
+ * provider can not do multi-part HMAC (updates) and has a limit
+ * on maximum input data that it can hmac. The provider sets
+ * this value in crypto_provider_ext_info_t by implementing
+ * the ext_info entry point in the co_provider_ops vector.
+ */
+#define CRYPTO_HMAC_NO_UPDATE 0x00000008
+
+/* provider can handle the request without returning a CRYPTO_QUEUED */
+#define CRYPTO_SYNCHRONOUS 0x00000004
+
+#define CRYPTO_PIFLAGS_RESERVED2 0x40000000
+#define CRYPTO_PIFLAGS_RESERVED1 0x80000000
+
+/*
+ * Provider status passed by a provider to crypto_provider_notification(9F)
+ * and returned by the provider_stauts(9E) entry point.
+ */
+#define CRYPTO_PROVIDER_READY 0
+#define CRYPTO_PROVIDER_BUSY 1
+#define CRYPTO_PROVIDER_FAILED 2
+
+/*
+ * Functions exported by Solaris to cryptographic providers. Providers
+ * call these functions to register and unregister, notify the kernel
+ * of state changes, and notify the kernel when a asynchronous request
+ * completed.
+ */
+extern int crypto_register_provider(crypto_provider_info_t *,
+ crypto_kcf_provider_handle_t *);
+extern int crypto_unregister_provider(crypto_kcf_provider_handle_t);
+extern void crypto_provider_notification(crypto_kcf_provider_handle_t, uint_t);
+extern void crypto_op_notification(crypto_req_handle_t, int);
+extern int crypto_kmflag(crypto_req_handle_t);
+
+#endif /* _KERNEL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_CRYPTO_SPI_H */
diff --git a/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/ExtCheck.java b/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/ExtCheck.java
deleted file mode 100644
index d29e2cbfe10..00000000000
--- a/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/ExtCheck.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.extcheck;
-
-import java.util.*;
-import java.net.MalformedURLException;
-import java.util.Vector;
-import java.io.*;
-import java.util.StringTokenizer;
-import java.net.URL;
-import java.util.jar.JarFile;
-import java.util.jar.JarEntry;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes;
-import java.util.jar.Attributes.Name;
-import java.net.URLConnection;
-import java.security.Permission;
-import java.util.jar.*;
-import java.net.JarURLConnection;
-import sun.net.www.ParseUtil;
-
-/**
- * ExtCheck reports on clashes between a specified (target)
- * jar file and jar files already installed in the extensions
- * directory.
- *
- * @author Benedict Gomes
- * @since 1.2
- */
-
-public class ExtCheck {
-
- private static final boolean DEBUG = false;
-
- // The following strings hold the values of the version variables
- // for the target jar file
- private String targetSpecTitle;
- private String targetSpecVersion;
- private String targetSpecVendor;
- private String targetImplTitle;
- private String targetImplVersion;
- private String targetImplVendor;
- private String targetsealed;
-
- /* Flag to indicate whether extra information should be dumped to stdout */
- private boolean verboseFlag;
-
- /*
- * Create a new instance of the jar reporting tool for a particular
- * targetFile.
- * @param targetFile is the file to compare against.
- * @param verbose indicates whether to dump filenames and manifest
- * information (on conflict) to the standard output.
- */
- static ExtCheck create(File targetFile, boolean verbose) {
- return new ExtCheck(targetFile, verbose);
- }
-
- private ExtCheck(File targetFile, boolean verbose) {
- verboseFlag = verbose;
- investigateTarget(targetFile);
- }
-
-
- private void investigateTarget(File targetFile) {
- verboseMessage("Target file:" + targetFile);
- Manifest targetManifest = null;
- try {
- File canon = new File(targetFile.getCanonicalPath());
- URL url = ParseUtil.fileToEncodedURL(canon);
- if (url != null){
- JarLoader loader = new JarLoader(url);
- JarFile jarFile = loader.getJarFile();
- targetManifest = jarFile.getManifest();
- }
- } catch (MalformedURLException e){
- error("Malformed URL ");
- } catch (IOException e) {
- error("IO Exception ");
- }
- if (targetManifest == null)
- error("No manifest available in "+targetFile);
- Attributes attr = targetManifest.getMainAttributes();
- if (attr != null) {
- targetSpecTitle = attr.getValue(Name.SPECIFICATION_TITLE);
- targetSpecVersion = attr.getValue(Name.SPECIFICATION_VERSION);
- targetSpecVendor = attr.getValue(Name.SPECIFICATION_VENDOR);
- targetImplTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
- targetImplVersion = attr.getValue(Name.IMPLEMENTATION_VERSION);
- targetImplVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
- targetsealed = attr.getValue(Name.SEALED);
- } else {
- error("No attributes available in the manifest");
- }
- if (targetSpecTitle == null)
- error("The target file does not have a specification title");
- if (targetSpecVersion == null)
- error("The target file does not have a specification version");
- verboseMessage("Specification title:" + targetSpecTitle);
- verboseMessage("Specification version:" + targetSpecVersion);
- if (targetSpecVendor != null)
- verboseMessage("Specification vendor:" + targetSpecVendor);
- if (targetImplVersion != null)
- verboseMessage("Implementation version:" + targetImplVersion);
- if (targetImplVendor != null)
- verboseMessage("Implementation vendor:" + targetImplVendor);
- verboseMessage("");
- }
-
- /**
- * Verify that none of the jar files in the install directory
- * has the same specification-title and the same or a newer
- * specification-version.
- *
- * @return Return true if the target jar file is newer
- * than any installed jar file with the same specification-title,
- * otherwise return false
- */
- boolean checkInstalledAgainstTarget(){
- String s = System.getProperty("java.ext.dirs");
- File [] dirs;
- if (s != null) {
- StringTokenizer st =
- new StringTokenizer(s, File.pathSeparator);
- int count = st.countTokens();
- dirs = new File[count];
- for (int i = 0; i < count; i++) {
- dirs[i] = new File(st.nextToken());
- }
- } else {
- dirs = new File[0];
- }
-
- boolean result = true;
- for (int i = 0; i < dirs.length; i++) {
- String[] files = dirs[i].list();
- if (files != null) {
- for (int j = 0; j < files.length; j++) {
- try {
- File f = new File(dirs[i],files[j]);
- File canon = new File(f.getCanonicalPath());
- URL url = ParseUtil.fileToEncodedURL(canon);
- if (url != null){
- result = result && checkURLRecursively(1,url);
- }
- } catch (MalformedURLException e){
- error("Malformed URL");
- } catch (IOException e) {
- error("IO Exception");
- }
- }
- }
- }
- if (result) {
- generalMessage("No conflicting installed jar found.");
- } else {
- generalMessage("Conflicting installed jar found. "
- + " Use -verbose for more information.");
- }
- return result;
- }
-
- /**
- * Recursively verify that a jar file, and any urls mentioned
- * in its class path, do not conflict with the target jar file.
- *
- * @param indent is the current nesting level
- * @param url is the path to the jar file being checked.
- * @return true if there is no newer URL, otherwise false
- */
- private boolean checkURLRecursively(int indent, URL url)
- throws IOException
- {
- verboseMessage("Comparing with " + url);
- JarLoader jarloader = new JarLoader(url);
- JarFile j = jarloader.getJarFile();
- Manifest man = j.getManifest();
- if (man != null) {
- Attributes attr = man.getMainAttributes();
- if (attr != null){
- String title = attr.getValue(Name.SPECIFICATION_TITLE);
- String version = attr.getValue(Name.SPECIFICATION_VERSION);
- String vendor = attr.getValue(Name.SPECIFICATION_VENDOR);
- String implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE);
- String implVersion
- = attr.getValue(Name.IMPLEMENTATION_VERSION);
- String implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR);
- String sealed = attr.getValue(Name.SEALED);
- if (title != null){
- if (title.equals(targetSpecTitle)){
- if (version != null){
- if (version.equals(targetSpecVersion) ||
- isNotOlderThan(version,targetSpecVersion)){
- verboseMessage("");
- verboseMessage("CONFLICT DETECTED ");
- verboseMessage("Conflicting file:"+ url);
- verboseMessage("Installed Version:" +
- version);
- if (implTitle != null)
- verboseMessage("Implementation Title:"+
- implTitle);
- if (implVersion != null)
- verboseMessage("Implementation Version:"+
- implVersion);
- if (implVendor != null)
- verboseMessage("Implementation Vendor:"+
- implVendor);
- return false;
- }
- }
- }
- }
- }
- }
- boolean result = true;
- URL[] loaderList = jarloader.getClassPath();
- if (loaderList != null) {
- for(int i=0; i < loaderList.length; i++){
- if (url != null){
- boolean res = checkURLRecursively(indent+1,loaderList[i]);
- result = res && result;
- }
- }
- }
- return result;
- }
-
- /**
- * See comment in method java.lang.Package.isCompatibleWith.
- * Return true if already is not older than target. i.e. the
- * target file may be superseded by a file already installed
- */
- private boolean isNotOlderThan(String already,String target)
- throws NumberFormatException
- {
- if (already == null || already.length() < 1) {
- throw new NumberFormatException("Empty version string");
- }
-
- // Until it matches scan and compare numbers
- StringTokenizer dtok = new StringTokenizer(target, ".", true);
- StringTokenizer stok = new StringTokenizer(already, ".", true);
- while (dtok.hasMoreTokens() || stok.hasMoreTokens()) {
- int dver;
- int sver;
- if (dtok.hasMoreTokens()) {
- dver = Integer.parseInt(dtok.nextToken());
- } else
- dver = 0;
-
- if (stok.hasMoreTokens()) {
- sver = Integer.parseInt(stok.nextToken());
- } else
- sver = 0;
-
- if (sver < dver)
- return false; // Known to be incompatible
- if (sver > dver)
- return true; // Known to be compatible
-
- // Check for and absorb separators
- if (dtok.hasMoreTokens())
- dtok.nextToken();
- if (stok.hasMoreTokens())
- stok.nextToken();
- // Compare next component
- }
- // All components numerically equal
- return true;
- }
-
-
- /**
- * Prints out message if the verboseFlag is set
- */
- void verboseMessage(String message){
- if (verboseFlag) {
- System.err.println(message);
- }
- }
-
- void generalMessage(String message){
- System.err.println(message);
- }
-
- /**
- * Throws a RuntimeException with a message describing the error.
- */
- static void error(String message) throws RuntimeException {
- throw new RuntimeException(message);
- }
-
-
- /**
- * Inner class used to represent a loader of resources and classes
- * from a base URL. Somewhat modified version of code in
- * sun.misc.URLClassPath.JarLoader
- */
- private static class JarLoader {
- private final URL base;
- private JarFile jar;
- private URL csu;
-
- /*
- * Creates a new Loader for the specified URL.
- */
- JarLoader(URL url) {
- String urlName = url + "!/";
- URL tmpBaseURL = null;
- try {
- tmpBaseURL = new URL("jar","",urlName);
- jar = findJarFile(url);
- csu = url;
- } catch (MalformedURLException e) {
- ExtCheck.error("Malformed url "+urlName);
- } catch (IOException e) {
- ExtCheck.error("IO Exception occurred");
- }
- base = tmpBaseURL;
-
- }
-
- /*
- * Returns the base URL for this Loader.
- */
- URL getBaseURL() {
- return base;
- }
-
- JarFile getJarFile() {
- return jar;
- }
-
- private JarFile findJarFile(URL url) throws IOException {
- // Optimize case where url refers to a local jar file
- if ("file".equals(url.getProtocol())) {
- String path = url.getFile().replace('/', File.separatorChar);
- File file = new File(path);
- if (!file.exists()) {
- throw new FileNotFoundException(path);
- }
- return new JarFile(path);
- }
- URLConnection uc = getBaseURL().openConnection();
- //uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
- return ((JarURLConnection)uc).getJarFile();
- }
-
-
- /*
- * Returns the JAR file local class path, or null if none.
- */
- URL[] getClassPath() throws IOException {
- Manifest man = jar.getManifest();
- if (man != null) {
- Attributes attr = man.getMainAttributes();
- if (attr != null) {
- String value = attr.getValue(Name.CLASS_PATH);
- if (value != null) {
- return parseClassPath(csu, value);
- }
- }
- }
- return null;
- }
-
- /*
- * Parses value of the Class-Path manifest attribute and returns
- * an array of URLs relative to the specified base URL.
- */
- private URL[] parseClassPath(URL base, String value)
- throws MalformedURLException
- {
- StringTokenizer st = new StringTokenizer(value);
- URL[] urls = new URL[st.countTokens()];
- int i = 0;
- while (st.hasMoreTokens()) {
- String path = st.nextToken();
- urls[i] = new URL(base, path);
- i++;
- }
- return urls;
- }
- }
-
-
-}
diff --git a/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/Main.java b/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/Main.java
deleted file mode 100644
index b3f76a33d9c..00000000000
--- a/jdk/src/jdk.dev/share/classes/com/sun/tools/extcheck/Main.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.extcheck;
-
-import java.io.*;
-
-/**
- * Main program of extcheck
- */
-
-public final class Main {
- public static final String INSUFFICIENT = "Insufficient number of arguments";
- public static final String MISSING = "Missing argument";
- public static final String DOES_NOT_EXIST = "Jarfile does not exist: ";
- public static final String EXTRA = "Extra command line argument: ";
-
- /**
- * Terminates with one of the following codes
- * 1 A newer (or same version) jar file is already installed
- * 0 No newer jar file was found
- * -1 An internal error occurred
- */
- public static void main(String args[]) {
- try {
- realMain(args);
- } catch (Exception ex) {
- System.err.println(ex.getMessage());
- System.exit(-1);
- }
- }
-
- public static void realMain(String[] args) throws Exception {
- if (args.length < 1) {
- usage(INSUFFICIENT);
- }
- int argIndex = 0;
- boolean verboseFlag = false;
- if (args[argIndex].equals("-verbose")) {
- verboseFlag = true;
- argIndex++;
- if (argIndex >= args.length) {
- usage(MISSING);
- }
- }
- String jarName = args[argIndex];
- argIndex++;
- File jarFile = new File(jarName);
- if (!jarFile.exists()){
- usage(DOES_NOT_EXIST + jarName);
- }
- if (argIndex < args.length) {
- usage(EXTRA + args[argIndex]);
- }
- ExtCheck jt = ExtCheck.create(jarFile,verboseFlag);
- boolean result = jt.checkInstalledAgainstTarget();
- if (result) {
- System.exit(0);
- } else {
- System.exit(1);
- }
- }
-
- private static void usage(String msg) throws Exception {
- throw new Exception(msg + "\nUsage: extcheck [-verbose] ");
- }
-}
-
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerDecoder.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerDecoder.java
deleted file mode 100644
index 40b4c603e82..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerDecoder.java
+++ /dev/null
@@ -1,757 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp;
-
-
-
-
-/**
- * The BerDecoder
class is used for decoding
- * BER-encoded data.
- *
- * A BerDecoder
needs to be set up with the byte string containing
- * the encoding. It maintains a current position in the byte string.
- *
- * Methods allows to fetch integer, string, OID, etc., from the current
- * position. After a fetch the current position is moved forward.
- *
- * A fetch throws a BerException
if the encoding is not of the
- * expected type.
- *
- * This API is a Sun Microsystems internal API and is subject
- * to change without notice.
- *
- * @since 1.5
- */
-
-public class BerDecoder {
-
- /**
- * Constructs a new decoder and attaches it to the specified byte string.
- *
- * @param b The byte string containing the encoded data.
- */
-
- public BerDecoder(byte b[]) {
- bytes = b ;
- reset() ;
- }
-
- public void reset() {
- next = 0 ;
- stackTop = 0 ;
- }
-
- /**
- * Fetch an integer.
- *
- * @return The decoded integer.
- *
- * @exception BerException Current position does not point to an integer.
- */
-
- public int fetchInteger() throws BerException {
- return fetchInteger(IntegerTag) ;
- }
-
-
- /**
- * Fetch an integer with the specified tag.
- *
- * @param tag The expected tag.
- *
- * @return The decoded integer.
- *
- * @exception BerException Current position does not point to an integer
- * or the tag is not the expected one.
- */
-
- public int fetchInteger(int tag) throws BerException {
- int result = 0 ;
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- result = fetchIntegerValue() ;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
-
- return result ;
- }
-
-
-
- /**
- * Fetch an integer and return a long value.
- *
- * @return The decoded integer.
- *
- * @exception BerException Current position does not point to an integer.
- */
-
- public long fetchIntegerAsLong() throws BerException {
- return fetchIntegerAsLong(IntegerTag) ;
- }
-
-
- /**
- * Fetch an integer with the specified tag and return a long value.
- *
- * @param tag The expected tag.
- *
- * @return The decoded integer.
- *
- * @exception BerException Current position does not point to an integer
- * or the tag is not the expected one.
- */
-
- public long fetchIntegerAsLong(int tag) throws BerException {
- long result = 0 ;
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- result = fetchIntegerValueAsLong() ;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
-
- return result ;
- }
-
-
-
- /**
- * Fetch an octet string.
- *
- * @return The decoded string.
- *
- * @exception BerException Current position does not point to an octet string.
- */
-
- public byte[] fetchOctetString() throws BerException {
- return fetchOctetString(OctetStringTag) ;
- }
-
-
- /**
- * Fetch an octet string with a specified tag.
- *
- * @param tag The expected tag.
- *
- * @return The decoded string.
- *
- * @exception BerException Current position does not point to an octet string
- * or the tag is not the expected one.
- */
-
- public byte[] fetchOctetString(int tag) throws BerException {
- byte[] result = null ;
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- result = fetchStringValue() ;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
-
- return result ;
- }
-
-
- /**
- * Fetch an object identifier.
- *
- * @return The decoded object identifier as an array of long.
- */
-
- public long[] fetchOid() throws BerException {
- return fetchOid(OidTag) ;
- }
-
-
- /**
- * Fetch an object identifier with a specified tag.
- *
- * @param tag The expected tag.
- *
- * @return The decoded object identifier as an array of long.
- *
- * @exception BerException Current position does not point to an oid
- * or the tag is not the expected one.
- */
-
- public long[] fetchOid(int tag) throws BerException {
- long[] result = null ;
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- result = fetchOidValue() ;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
-
- return result ;
- }
-
-
- /**
- * Fetch a NULL
value.
- *
- * @exception BerException Current position does not point to NULL
value.
- */
-
- public void fetchNull() throws BerException {
- fetchNull(NullTag) ;
- }
-
-
- /**
- * Fetch a NULL
value with a specified tag.
- *
- * @param tag The expected tag.
- *
- * @exception BerException Current position does not point to
- * NULL
value or the tag is not the expected one.
- */
-
- public void fetchNull(int tag) throws BerException {
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- final int length = fetchLength();
- if (length != 0) throw new BerException();
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- }
-
-
-
- /**
- * Fetch an ANY
value. In fact, this method does not decode anything
- * it simply returns the next TLV as an array of bytes.
- *
- * @return The TLV as a byte array.
- *
- * @exception BerException The next TLV is really badly encoded...
- */
-
- public byte[] fetchAny() throws BerException {
- byte[] result = null ;
- final int backup = next ;
- try {
- final int tag = fetchTag() ;
- final int contentLength = fetchLength() ;
- if (contentLength < 0) throw new BerException() ;
- final int tlvLength = next + contentLength - backup ;
- if (contentLength > (bytes.length - next))
- throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
- final byte[] data = new byte[tlvLength] ;
- java.lang.System.arraycopy(bytes,backup,data,0,tlvLength);
- // for (int i = 0 ; i < tlvLength ; i++) {
- // data[i] = bytes[backup + i] ;
- // }
- next = next + contentLength ;
- result = data;
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
- // catch(Error e) {
- // debug("fetchAny: Error decoding BER: " + e);
- // throw e;
- // }
-
- return result ;
- }
-
-
- /**
- * Fetch an ANY
value with a specific tag.
- *
- * @param tag The expected tag.
- *
- * @return The TLV as a byte array.
- *
- * @exception BerException The next TLV is really badly encoded...
- */
-
- public byte[] fetchAny(int tag) throws BerException {
- if (getTag() != tag) {
- throw new BerException() ;
- }
- return fetchAny() ;
- }
-
-
-
- /**
- * Fetch a sequence header.
- * The decoder computes the end position of the sequence and push it
- * on its stack.
- *
- * @exception BerException Current position does not point to a sequence header.
- */
-
- public void openSequence() throws BerException {
- openSequence(SequenceTag) ;
- }
-
-
- /**
- * Fetch a sequence header with a specific tag.
- *
- * @param tag The expected tag.
- *
- * @exception BerException Current position does not point to a sequence header
- * or the tag is not the expected one.
- */
-
- public void openSequence(int tag) throws BerException {
- final int backup = next ;
- try {
- if (fetchTag() != tag) {
- throw new BerException() ;
- }
- final int l = fetchLength() ;
- if (l < 0) throw new BerException();
- if (l > (bytes.length - next)) throw new BerException();
- stackBuf[stackTop++] = next + l ;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- }
-
-
- /**
- * Close a sequence.
- * The decode pull the stack and verifies that the current position
- * matches with the calculated end of the sequence. If not it throws
- * an exception.
- *
- * @exception BerException The sequence is not expected to finish here.
- */
-
- public void closeSequence() throws BerException {
- if (stackBuf[stackTop - 1] == next) {
- stackTop-- ;
- }
- else {
- throw new BerException() ;
- }
- }
-
-
- /**
- * Return true
if the end of the current sequence is not reached.
- * When this method returns false
, closeSequence
can (and must) be
- * invoked.
- *
- * @return true
if there is still some data in the sequence.
- */
-
- public boolean cannotCloseSequence() {
- return (next < stackBuf[stackTop - 1]) ;
- }
-
-
- /**
- * Get the tag of the data at the current position.
- * Current position is unchanged.
- *
- * @return The next tag.
- */
-
- public int getTag() throws BerException {
- int result = 0 ;
- final int backup = next ;
- try {
- result = fetchTag() ;
- }
- finally {
- next = backup ;
- }
-
- return result ;
- }
-
-
-
- public String toString() {
- final StringBuffer result = new StringBuffer(bytes.length * 2) ;
- for (int i = 0 ; i < bytes.length ; i++) {
- final int b = (bytes[i] > 0) ? bytes[i] : bytes[i] + 256 ;
- if (i == next) {
- result.append("(") ;
- }
- result.append(Character.forDigit(b / 16, 16)) ;
- result.append(Character.forDigit(b % 16, 16)) ;
- if (i == next) {
- result.append(")") ;
- }
- }
- if (bytes.length == next) {
- result.append("()") ;
- }
-
- return new String(result) ;
- }
-
-
- //
- // Some standard tags
- //
- public final static int BooleanTag = 1 ;
- public final static int IntegerTag = 2 ;
- public final static int OctetStringTag = 4 ;
- public final static int NullTag = 5 ;
- public final static int OidTag = 6 ;
- public final static int SequenceTag = 0x30 ;
-
-
-
-
- ////////////////////////// PRIVATE ///////////////////////////////
-
-
-
- /**
- * Fetch a tag and move the current position forward.
- *
- * @return The tag
- */
-
- private final int fetchTag() throws BerException {
- int result = 0 ;
- final int backup = next ;
-
- try {
- final byte b0 = bytes[next++] ;
- result = (b0 >= 0) ? b0 : b0 + 256 ;
- if ((result & 31) == 31) {
- while ((bytes[next] & 128) != 0) {
- result = result << 7 ;
- result = result | (bytes[next++] & 127);
- }
- }
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
-
- return result ;
- }
-
-
- /**
- * Fetch a length and move the current position forward.
- *
- * @return The length
- */
-
- private final int fetchLength() throws BerException {
- int result = 0 ;
- final int backup = next ;
-
- try {
- final byte b0 = bytes[next++] ;
- if (b0 >= 0) {
- result = b0 ;
- }
- else {
- for (int c = 128 + b0 ; c > 0 ; c--) {
- final byte bX = bytes[next++] ;
- result = result << 8 ;
- result = result | ((bX >= 0) ? bX : bX+256) ;
- }
- }
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
-
- return result ;
- }
-
-
- /**
- * Fetch an integer value and move the current position forward.
- *
- * @return The integer
- */
-
- private int fetchIntegerValue() throws BerException {
- int result = 0 ;
- final int backup = next ;
-
- try {
- final int length = fetchLength() ;
- if (length <= 0) throw new BerException() ;
- if (length > (bytes.length - next)) throw
- new IndexOutOfBoundsException("Decoded length exceeds buffer");
- final int end = next + length ;
- result = bytes[next++] ;
- while (next < end) {
- final byte b = bytes[next++] ;
- if (b < 0) {
- result = (result << 8) | (256 + b) ;
- }
- else {
- result = (result << 8) | b ;
- }
- }
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
- catch(ArithmeticException e) {
- next = backup ;
- throw new BerException() ;
- }
- return result ;
- }
-
-
- /**
- * Fetch an integer value and return a long value.
- * FIX ME: someday we could have only on fetchIntegerValue() which always
- * returns a long value.
- *
- * @return The integer
- */
-
- private final long fetchIntegerValueAsLong() throws BerException {
- long result = 0 ;
- final int backup = next ;
-
- try {
- final int length = fetchLength() ;
- if (length <= 0) throw new BerException() ;
- if (length > (bytes.length - next)) throw
- new IndexOutOfBoundsException("Decoded length exceeds buffer");
-
- final int end = next + length ;
- result = bytes[next++] ;
- while (next < end) {
- final byte b = bytes[next++] ;
- if (b < 0) {
- result = (result << 8) | (256 + b) ;
- }
- else {
- result = (result << 8) | b ;
- }
- }
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
- catch(ArithmeticException e) {
- next = backup ;
- throw new BerException() ;
- }
- return result ;
- }
-
-
- /**
- * Fetch a byte string and move the current position forward.
- *
- * @return The byte string
- */
-
- private byte[] fetchStringValue() throws BerException {
- byte[] result = null ;
- final int backup = next ;
-
- try {
- final int length = fetchLength() ;
- if (length < 0) throw new BerException() ;
- if (length > (bytes.length - next))
- throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
- final byte data[] = new byte[length] ;
- java.lang.System.arraycopy(bytes,next,data,0,length);
- next += length;
- // int i = 0 ;
- // while (i < length) {
- // result[i++] = bytes[next++] ;
- // }
- result = data;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
- catch(ArithmeticException e) {
- next = backup ;
- throw new BerException() ;
- }
- // catch(Error e) {
- // debug("fetchStringValue: Error decoding BER: " + e);
- // throw e;
- // }
-
- return result ;
- }
-
-
-
- /**
- * Fetch an oid and move the current position forward.
- *
- * @return The oid
- */
-
- private final long[] fetchOidValue() throws BerException {
- long[] result = null ;
- final int backup = next ;
-
- try {
- final int length = fetchLength() ;
- if (length <= 0) throw new BerException() ;
- if (length > (bytes.length - next))
- throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
- // Count how many bytes have their 8th bit to 0
- // -> this gives the number of components in the oid
- int subidCount = 2 ;
- for (int i = 1 ; i < length ; i++) {
- if ((bytes[next + i] & 0x80) == 0) {
- subidCount++ ;
- }
- }
- final int datalen = subidCount;
- final long[] data = new long[datalen];
- final byte b0 = bytes[next++] ;
-
- // bugId 4641746
- // The 8th bit of the first byte should always be set to 0
- if (b0 < 0) throw new BerException();
-
- // bugId 4641746
- // The first sub Id cannot be greater than 2
- final long lb0 = b0 / 40 ;
- if (lb0 > 2) throw new BerException();
-
- final long lb1 = b0 % 40;
- data[0] = lb0 ;
- data[1] = lb1 ;
- int i = 2 ;
- while (i < datalen) {
- long subid = 0 ;
- byte b = bytes[next++] ;
- while ((b & 0x80) != 0) {
- subid = (subid << 7) | (b & 0x7f) ;
- // bugId 4654674
- if (subid < 0) throw new BerException();
- b = bytes[next++] ;
- }
- subid = (subid << 7) | b ;
- // bugId 4654674
- if (subid < 0) throw new BerException();
- data[i++] = subid ;
- }
- result = data;
- }
- catch(BerException e) {
- next = backup ;
- throw e ;
- }
- catch(IndexOutOfBoundsException e) {
- next = backup ;
- throw new BerException() ;
- }
- // catch(Error e) {
- // debug("fetchOidValue: Error decoding BER: " + e);
- // throw e;
- // }
-
- return result ;
- }
-
- // private static final void debug(String str) {
- // System.out.println(str);
- // }
-
- //
- // This is the byte array containing the encoding.
- //
- private final byte bytes[];
-
- //
- // This is the current location. It is the next byte
- // to be decoded. It's an index in bytes[].
- //
- private int next = 0 ;
-
- //
- // This is the stack where end of sequences are kept.
- // A value is computed and pushed in it each time openSequence()
- // is invoked.
- // A value is pulled and checked each time closeSequence() is called.
- //
- private final int stackBuf[] = new int[200] ;
- private int stackTop = 0 ;
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerEncoder.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerEncoder.java
deleted file mode 100644
index 0866f15a5f6..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerEncoder.java
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp;
-
-
-/**
- * The BerEncoder
class is used for encoding data using BER.
- *
- * A BerEncoder
needs to be set up with a byte buffer. The encoded
- * data are stored in this byte buffer.
- *
- * NOTE : the buffer is filled from end to start. This means the caller
- * needs to encode its data in the reverse order.
- *
- *
- *
This API is a Sun Microsystems internal API and is subject
- * to change without notice.
- *
- * @since 1.5
- */
-
-public class BerEncoder {
-
- /**
- * Constructs a new encoder and attaches it to the specified byte string.
- *
- * @param b The byte string containing the encoded data.
- */
-
- public BerEncoder(byte b[]) {
- bytes = b ;
- start = b.length ;
- stackTop = 0 ;
- }
-
-
- /**
- * Trim the encoding data and returns the length of the encoding.
- *
- * The encoder does backward encoding : so the bytes buffer is
- * filled from end to start. The encoded data must be shift before
- * the buffer can be used. This is the purpose of the trim
method.
- *
- * After a call to the trim
method, the encoder is reinitialized and putXXX
- * overwrite any existing encoded data.
- *
- * @return The length of the encoded data.
- */
-
- public int trim() {
- final int result = bytes.length - start ;
-
- // for (int i = start ; i < bytes.length ; i++) {
- // bytes[i-start] = bytes[i] ;
- // }
- if (result > 0)
- java.lang.System.arraycopy(bytes,start,bytes,0,result);
-
- start = bytes.length ;
- stackTop = 0 ;
-
- return result ;
- }
-
- /**
- * Put an integer.
- *
- * @param v The integer to encode.
- */
-
- public void putInteger(int v) {
- putInteger(v, IntegerTag) ;
- }
-
-
- /**
- * Put an integer with the specified tag.
- *
- * @param v The integer to encode.
- * @param tag The tag to encode.
- */
-
- public void putInteger(int v, int tag) {
- putIntegerValue(v) ;
- putTag(tag) ;
- }
-
-
-
- /**
- * Put an integer expressed as a long.
- *
- * @param v The long to encode.
- */
-
- public void putInteger(long v) {
- putInteger(v, IntegerTag) ;
- }
-
-
- /**
- * Put an integer expressed as a long with the specified tag.
- *
- * @param v The long to encode
- * @param tag The tag to encode.
- */
-
- public void putInteger(long v, int tag) {
- putIntegerValue(v) ;
- putTag(tag) ;
- }
-
-
-
- /**
- * Put an octet string.
- *
- * @param s The bytes to encode
- */
-
- public void putOctetString(byte[] s) {
- putOctetString(s, OctetStringTag) ;
- }
-
-
- /**
- * Put an octet string with a specified tag.
- *
- * @param s The bytes to encode
- * @param tag The tag to encode.
- */
-
- public void putOctetString(byte[] s, int tag) {
- putStringValue(s) ;
- putTag(tag) ;
- }
-
-
- /**
- * Put an object identifier.
- *
- * @param s The oid to encode.
- */
-
- public void putOid(long[] s) {
- putOid(s, OidTag) ;
- }
-
-
- /**
- * Put an object identifier with a specified tag.
- *
- * @param s The integer to encode.
- * @param tag The tag to encode.
- */
-
- public void putOid(long[] s, int tag) {
- putOidValue(s) ;
- putTag(tag) ;
- }
-
-
- /**
- * Put a NULL
value.
- */
-
- public void putNull() {
- putNull(NullTag) ;
- }
-
-
- /**
- * Put a NULL
value with a specified tag.
- *
- * @param tag The tag to encode.
- */
-
- public void putNull(int tag) {
- putLength(0) ;
- putTag(tag) ;
- }
-
-
-
- /**
- * Put an ANY
value. In fact, this method does not encode anything.
- * It simply copies the specified bytes into the encoding.
- *
- * @param s The encoding of the ANY
value.
- */
-
- public void putAny(byte[] s) {
- putAny(s, s.length) ;
- }
-
-
- /**
- * Put an ANY
value. Only the first byteCount
are considered.
- *
- * @param s The encoding of the ANY
value.
- * @param byteCount The number of bytes of the encoding.
- */
-
- public void putAny(byte[] s, int byteCount) {
- java.lang.System.arraycopy(s,0,bytes,start-byteCount,byteCount);
- start -= byteCount;
- // for (int i = byteCount - 1 ; i >= 0 ; i--) {
- // bytes[--start] = s[i] ;
- // }
- }
-
-
- /**
- * Open a sequence.
- * The encoder push the current position on its stack.
- */
-
- public void openSequence() {
- stackBuf[stackTop++] = start ;
- }
-
-
- /**
- * Close a sequence.
- * The decode pull the stack to know the end of the current sequence.
- */
-
- public void closeSequence() {
- closeSequence(SequenceTag) ;
- }
-
-
- /**
- * Close a sequence with the specified tag.
- */
-
- public void closeSequence(int tag) {
- final int end = stackBuf[--stackTop] ;
- putLength(end - start) ;
- putTag(tag) ;
- }
-
-
- //
- // Some standard tags
- //
- public final static int BooleanTag = 1 ;
- public final static int IntegerTag = 2 ;
- public final static int OctetStringTag = 4 ;
- public final static int NullTag = 5 ;
- public final static int OidTag = 6 ;
- public final static int SequenceTag = 0x30 ;
-
-
-
-
- ////////////////////////// PROTECTED ///////////////////////////////
-
-
-
- /**
- * Put a tag and move the current position backward.
- *
- * @param tag The tag to encode.
- */
-
- protected final void putTag(int tag) {
- if (tag < 256) {
- bytes[--start] = (byte)tag ;
- }
- else {
- while (tag != 0) {
- bytes[--start] = (byte)(tag & 127) ;
- tag = tag << 7 ;
- }
- }
- }
-
-
- /**
- * Put a length and move the current position backward.
- *
- * @param length The length to encode.
- */
-
- protected final void putLength(final int length) {
- if (length < 0) {
- throw new IllegalArgumentException() ;
- }
- else if (length < 128) {
- bytes[--start] = (byte)length ;
- }
- else if (length < 256) {
- bytes[--start] = (byte)length ;
- bytes[--start] = (byte)0x81 ;
- }
- else if (length < 65536) {
- bytes[--start] = (byte)(length) ;
- bytes[--start] = (byte)(length >> 8) ;
- bytes[--start] = (byte)0x82 ;
- }
- else if (length < 16777126) {
- bytes[--start] = (byte)(length) ;
- bytes[--start] = (byte)(length >> 8) ;
- bytes[--start] = (byte)(length >> 16) ;
- bytes[--start] = (byte)0x83 ;
- }
- else {
- bytes[--start] = (byte)(length) ;
- bytes[--start] = (byte)(length >> 8) ;
- bytes[--start] = (byte)(length >> 16) ;
- bytes[--start] = (byte)(length >> 24) ;
- bytes[--start] = (byte)0x84 ;
- }
- }
-
-
- /**
- * Put an integer value and move the current position backward.
- *
- * @param v The integer to encode.
- */
-
- protected final void putIntegerValue(int v) {
- final int end = start ;
- int mask = 0x7f800000 ;
- int byteNeeded = 4 ;
- if (v < 0) {
- while (((mask & v) == mask) && (byteNeeded > 1)) {
- mask = mask >> 8 ;
- byteNeeded-- ;
- }
- }
- else {
- while (((mask & v) == 0) && (byteNeeded > 1)) {
- mask = mask >> 8 ;
- byteNeeded-- ;
- }
- }
- for (int i = 0 ; i < byteNeeded ; i++) {
- bytes[--start] = (byte)v ;
- v = v >> 8 ;
- }
- putLength(end - start) ;
- }
-
-
- /**
- * Put an integer value expressed as a long.
- *
- * @param v The integer to encode.
- */
-
- protected final void putIntegerValue(long v) {
- final int end = start ;
- long mask = 0x7f80000000000000L ;
- int byteNeeded = 8 ;
- if (v < 0) {
- while (((mask & v) == mask) && (byteNeeded > 1)) {
- mask = mask >> 8 ;
- byteNeeded-- ;
- }
- }
- else {
- while (((mask & v) == 0) && (byteNeeded > 1)) {
- mask = mask >> 8 ;
- byteNeeded-- ;
- }
- }
- for (int i = 0 ; i < byteNeeded ; i++) {
- bytes[--start] = (byte)v ;
- v = v >> 8 ;
- }
- putLength(end - start) ;
- }
-
-
- /**
- * Put a byte string and move the current position backward.
- *
- * @param s The byte string to encode.
- */
-
- protected final void putStringValue(byte[] s) {
- final int datalen = s.length;
- java.lang.System.arraycopy(s,0,bytes,start-datalen,datalen);
- start -= datalen;
- // for (int i = s.length - 1 ; i >= 0 ; i--) {
- // bytes[--start] = s[i] ;
- // }
- putLength(datalen) ;
- }
-
-
-
- /**
- * Put an oid and move the current position backward.
- *
- * @param s The oid to encode.
- */
-
- protected final void putOidValue(final long[] s) {
- final int end = start ;
- final int slength = s.length;
-
- // bugId 4641746: 0, 1, and 2 are legal values.
- if ((slength < 2) || (s[0] > 2) || (s[1] >= 40)) {
- throw new IllegalArgumentException() ;
- }
- for (int i = slength - 1 ; i >= 2 ; i--) {
- long c = s[i] ;
- if (c < 0) {
- throw new IllegalArgumentException() ;
- }
- else if (c < 128) {
- bytes[--start] = (byte)c ;
- }
- else {
- bytes[--start] = (byte)(c & 127) ;
- c = c >> 7 ;
- while (c != 0) {
- bytes[--start] = (byte)(c | 128) ;
- c = c >> 7 ;
- }
- }
- }
- bytes[--start] = (byte)(s[0] * 40 + s[1]) ;
- putLength(end - start) ;
- }
-
-
- //
- // This is the byte array containing the encoding.
- //
- protected final byte bytes[];
-
- //
- // This is the index of the first byte of the encoding.
- // It is initialized to bytes.length
and decrease each time
- // an value is put in the encoder.
- //
- protected int start = -1 ;
-
- //
- // This is the stack where end of sequences are kept.
- // A value is computed and pushed in it each time the openSequence
method
- // is invoked.
- // A value is pulled and checked each time the closeSequence
method is called.
- //
- protected final int stackBuf[] = new int[200] ;
- protected int stackTop = 0 ;
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerException.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerException.java
deleted file mode 100644
index 8560f383c6b..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/BerException.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp;
-
-
-
-
-
-/**
- * Exception thrown when a BER encoding/decoding error occurs.
- *
- * This API is a Sun Microsystems internal API and is subject
- * to change without notice.
- *
- * @since 1.5
- */
-
-public class BerException extends Exception {
- private static final long serialVersionUID = 494709767137042951L;
-
- public static final int BAD_VERSION=1;
-
- private int errorType= 0;
-
- public BerException() {
- errorType= 0;
- }
-
- public BerException(int x) {
- errorType= x;
- }
-
- public boolean isInvalidSnmpVersion() {
- if (errorType == BAD_VERSION)
- return true;
- else
- return false;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/EnumRowStatus.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/EnumRowStatus.java
deleted file mode 100644
index 303b8235272..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/EnumRowStatus.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.jmx.snmp;
-
-import java.io.Serializable;
-import java.util.Hashtable;
-
-
-/**
- * This class is an internal class which is used to represent RowStatus
- * codes as defined in RFC 2579.
- *
- * It defines an additional code, unspecified, which is
- * implementation specific, and is used to identify
- * unspecified actions (when for instance the RowStatus variable
- * is not present in the varbind list) or uninitialized values.
- *
- * mibgen does not generate objects of this class but any variable
- * using the RowStatus textual convention can be converted into an
- * object of this class thanks to the
- * EnumRowStatus(Enumerated valueIndex)
constructor.
- *
- * This API is a Sun Microsystems internal API and is subject
- * to change without notice.
- **/
-
-public class EnumRowStatus extends Enumerated implements Serializable {
- private static final long serialVersionUID = 8966519271130162420L;
-
- /**
- * This value is SNMP Runtime implementation specific, and is used to identify
- * unspecified actions (when for instance the RowStatus variable
- * is not present in the varbind list) or uninitialized values.
- */
- public final static int unspecified = 0;
-
- /**
- * This value corresponds to the active RowStatus, as defined in
- * RFC 2579 from SMIv2:
- *
- * active indicates that the conceptual row is available for
- * use by the managed device;
- *
- */
- public final static int active = 1;
-
- /**
- * This value corresponds to the notInService RowStatus, as
- * defined in RFC 2579 from SMIv2:
- *
- * notInService indicates that the conceptual
- * row exists in the agent, but is unavailable for use by
- * the managed device; notInService has
- * no implication regarding the internal consistency of
- * the row, availability of resources, or consistency with
- * the current state of the managed device;
- *
- **/
- public final static int notInService = 2;
-
- /**
- * This value corresponds to the notReady RowStatus, as defined
- * in RFC 2579 from SMIv2:
- *
- * notReady indicates that the conceptual row
- * exists in the agent, but is missing information
- * necessary in order to be available for use by the
- * managed device (i.e., one or more required columns in
- * the conceptual row have not been instantiated);
- *
- */
- public final static int notReady = 3;
-
- /**
- * This value corresponds to the createAndGo RowStatus,
- * as defined in RFC 2579 from SMIv2:
- *
- * createAndGo is supplied by a management
- * station wishing to create a new instance of a
- * conceptual row and to have its status automatically set
- * to active, making it available for use by the managed
- * device;
- *
- */
- public final static int createAndGo = 4;
-
- /**
- * This value corresponds to the createAndWait RowStatus,
- * as defined in RFC 2579 from SMIv2:
- *
- * createAndWait is supplied by a management
- * station wishing to create a new instance of a
- * conceptual row (but not make it available for use by
- * the managed device);
- *
- */
- public final static int createAndWait = 5;
-
- /**
- * This value corresponds to the destroy RowStatus, as defined in
- * RFC 2579 from SMIv2:
- *
- * destroy is supplied by a management station
- * wishing to delete all of the instances associated with
- * an existing conceptual row.
- *
- */
- public final static int destroy = 6;
-
- /**
- * Build an EnumRowStatus
from an int
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(int valueIndex)
- throws IllegalArgumentException {
- super(valueIndex);
- }
-
- /**
- * Build an EnumRowStatus
from an Enumerated
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(Enumerated valueIndex)
- throws IllegalArgumentException {
- this(valueIndex.intValue());
- }
-
- /**
- * Build an EnumRowStatus
from a long
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(long valueIndex)
- throws IllegalArgumentException {
- this((int)valueIndex);
- }
-
- /**
- * Build an EnumRowStatus
from an Integer
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(Integer valueIndex)
- throws IllegalArgumentException {
- super(valueIndex);
- }
-
- /**
- * Build an EnumRowStatus
from a Long
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(Long valueIndex)
- throws IllegalArgumentException {
- this(valueIndex.longValue());
- }
-
- /**
- * Build an EnumRowStatus
with unspecified value.
- **/
- public EnumRowStatus()
- throws IllegalArgumentException {
- this(unspecified);
- }
-
- /**
- * Build an EnumRowStatus
from a String
.
- * @param x should be either "unspecified", or one of
- * the values defined in RFC 2579 ("active", "notReady", etc...)
- * @exception IllegalArgumentException if the given String
- * x
is not valid.
- **/
- public EnumRowStatus(String x)
- throws IllegalArgumentException {
- super(x);
- }
-
- /**
- * Build an EnumRowStatus
from an SnmpInt
.
- * @param valueIndex should be either 0 (unspecified), or one of
- * the values defined in RFC 2579.
- * @exception IllegalArgumentException if the given
- * valueIndex
is not valid.
- **/
- public EnumRowStatus(SnmpInt valueIndex)
- throws IllegalArgumentException {
- this(valueIndex.intValue());
- }
-
- /**
- * Build an SnmpValue from this object.
- *
- * @exception IllegalArgumentException if this object holds an
- * unspecified value.
- * @return an SnmpInt containing this object value.
- **/
- public SnmpInt toSnmpValue()
- throws IllegalArgumentException {
- if (value == unspecified)
- throw new
- IllegalArgumentException("`unspecified' is not a valid SNMP value.");
- return new SnmpInt(value);
- }
-
- /**
- * Check that the given value
is valid.
- *
- * Valid values are:
- * - unspecified(0)
- * - active(1)
- * - notInService(2)
- * - notReady(3)
- * - createAndGo(4)
- * - createAndWait(5)
- * - destroy(6)
- *
- *
- **/
- static public boolean isValidValue(int value) {
- if (value < 0) return false;
- if (value > 6) return false;
- return true;
- }
-
- // Documented in Enumerated
- //
- @Override
- protected Hashtable getIntTable() {
- return EnumRowStatus.getRSIntTable();
- }
-
- // Documented in Enumerated
- //
- @Override
- protected Hashtable getStringTable() {
- return EnumRowStatus.getRSStringTable();
- }
-
- static Hashtable getRSIntTable() {
- return intTable ;
- }
-
- static Hashtable getRSStringTable() {
- return stringTable ;
- }
-
- // Initialize the mapping tables.
- //
- final static Hashtable intTable = new Hashtable<>();
- final static Hashtable stringTable = new Hashtable<>();
- static {
- intTable.put(0, "unspecified");
- intTable.put(3, "notReady");
- intTable.put(6, "destroy");
- intTable.put(2, "notInService");
- intTable.put(5, "createAndWait");
- intTable.put(1, "active");
- intTable.put(4, "createAndGo");
- stringTable.put("unspecified", 0);
- stringTable.put("notReady", 3);
- stringTable.put("destroy", 6);
- stringTable.put("notInService", 2);
- stringTable.put("createAndWait", 5);
- stringTable.put("active", 1);
- stringTable.put("createAndGo", 4);
- }
-
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/Enumerated.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/Enumerated.java
deleted file mode 100644
index e2760cdfe58..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/Enumerated.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.jmx.snmp;
-
-
-import java.io.*;
-import java.util.Hashtable;
-import java.util.*;
-
-
-
-/** This class is used for implementing enumerated values.
- *
- * An enumeration is represented by a class derived from Enumerated.
- * The derived class defines what are the permitted values in the enumeration.
- *
- * An enumerated value is represented by an instance of the derived class.
- * It can be represented :
- * - as an integer
- * - as a string
- *
- * This API is a Sun Microsystems internal API and is subject
- * to change without notice.
- */
-@SuppressWarnings("serial") // JDK implementation class
-abstract public class Enumerated implements Serializable {
-
- /**
- * Construct an enumerated with a default value.
- * The default value is the first available in getIntTable().
- * @exception IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.
- */
- public Enumerated() throws IllegalArgumentException {
- Enumeration e =getIntTable().keys();
- if (e.hasMoreElements()) {
- value = e.nextElement().intValue() ;
- }
- else {
- throw new IllegalArgumentException() ;
- }
- }
-
- /**
- * Construct an enumerated from its integer form.
- *
- * @param valueIndex The integer form.
- * @exception IllegalArgumentException One of the arguments passed to
- * the method is illegal or inappropriate.
- */
- public Enumerated(int valueIndex) throws IllegalArgumentException {
- if (getIntTable().get(valueIndex) == null) {
- throw new IllegalArgumentException() ;
- }
- value = valueIndex ;
- }
-
- /**
- * Construct an enumerated from its Integer form.
- *
- * @param valueIndex The Integer form.
- * @exception IllegalArgumentException One of the arguments passed to
- * the method is illegal or inappropriate.
- */
- public Enumerated(Integer valueIndex) throws IllegalArgumentException {
- if (getIntTable().get(valueIndex) == null) {
- throw new IllegalArgumentException() ;
- }
- value = valueIndex.intValue() ;
- }
-
-
- /**
- * Construct an enumerated from its string form.
- *
- * @param valueString The string form.
- * @exception IllegalArgumentException One of the arguments passed
- * to the method is illegal or inappropriate.
- */
- public Enumerated(String valueString) throws IllegalArgumentException {
- Integer index = getStringTable().get(valueString) ;
- if (index == null) {
- throw new IllegalArgumentException() ;
- }
- else {
- value = index.intValue() ;
- }
- }
-
-
- /**
- * Return the integer form of the enumerated.
- *
- * @return The integer form
- */
-
- public int intValue() {
- return value ;
- }
-
-
- /**
- * Returns an Java enumeration of the permitted integers.
- *
- * @return An enumeration of Integer instances
- */
-
- public Enumeration valueIndexes() {
- return getIntTable().keys() ;
- }
-
-
- /**
- * Returns an Java enumeration of the permitted strings.
- *
- * @return An enumeration of String instances
- */
-
- public Enumeration valueStrings() {
- return getStringTable().keys() ;
- }
-
-
- /**
- * Compares this enumerated to the specified enumerated.
- *
- * The result is true if and only if the argument is not null
- * and is of the same class.
- *
- * @param obj The object to compare with.
- *
- * @return True if this and obj are the same; false otherwise
- */
- @Override
- public boolean equals(Object obj) {
-
- return ((obj != null) &&
- (getClass() == obj.getClass()) &&
- (value == ((Enumerated)obj).value)) ;
- }
-
-
- /**
- * Returns the hash code for this enumerated.
- *
- * @return A hash code value for this object.
- */
- @Override
- public int hashCode() {
- String hashString = getClass().getName() + String.valueOf(value) ;
- return hashString.hashCode() ;
- }
-
-
- /**
- * Returns the string form of this enumerated.
- *
- * @return The string for for this object.
- */
- @Override
- public String toString() {
- return getIntTable().get(value);
- }
-
-
- /**
- * Returns the hashtable of the integer forms.
- * getIntTable().get(x) returns the string form associated
- * to the integer x.
- *
- * This method must be implemented by the derived class.
- *
- * @return An hashtable for read-only purpose
- */
-
- protected abstract Hashtable getIntTable() ;
-
-
-
- /**
- * Returns the hashtable of the string forms.
- * getStringTable().get(s) returns the integer form associated
- * to the string s.
- *
- * This method must be implemented by the derived class.
- *
- * @return An hashtable for read-only purpose
- */
-
- protected abstract Hashtable getStringTable() ;
-
-
- /**
- * This variable keeps the integer form of the enumerated.
- * The string form is retrieved using getIntTable().
- */
- protected int value ;
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.README b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.README
deleted file mode 100644
index 6e6fd813e52..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.README
+++ /dev/null
@@ -1,23 +0,0 @@
-WARNING : ASCII_CharStream.java must be PATCHED.
-
-The following methods should be removed after javacc generation.
-The goal is to simplify 100%-pure testing (see bug 4127719).
-
-
- /**
- * @deprecated
- * @see #getEndColumn
- */
-
- public final int getColumn() {
- return bufcolumn[bufpos];
- }
-
- /**
- * @deprecated
- * @see #getEndLine
- */
-
- public final int getLine() {
- return bufline[bufpos];
- }
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.java
deleted file mode 100644
index d6fa3088de2..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JavaCC: Do not edit this line. ASCII_CharStream.java Version 0.7pre6 */
-package com.sun.jmx.snmp.IPAcl;
-
-/**
- * An implementation of interface CharStream, where the stream is assumed to
- * contain only ASCII characters (without unicode processing).
- */
-
-final class ASCII_CharStream
-{
- public static final boolean staticFlag = false;
- int bufsize;
- int available;
- int tokenBegin;
- public int bufpos = -1;
- private int bufline[];
- private int bufcolumn[];
-
- private int column = 0;
- private int line = 1;
-
- private boolean prevCharIsCR = false;
- private boolean prevCharIsLF = false;
-
- private java.io.Reader inputStream;
-
- private char[] buffer;
- private int maxNextCharInd = 0;
- private int inBuf = 0;
-
- private final void ExpandBuff(boolean wrapAround)
- {
- char[] newbuffer = new char[bufsize + 2048];
- int newbufline[] = new int[bufsize + 2048];
- int newbufcolumn[] = new int[bufsize + 2048];
-
- try
- {
- if (wrapAround)
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- System.arraycopy(buffer, 0, newbuffer,
- bufsize - tokenBegin, bufpos);
- buffer = newbuffer;
-
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
- bufline = newbufline;
-
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
- bufcolumn = newbufcolumn;
-
- maxNextCharInd = (bufpos += (bufsize - tokenBegin));
- }
- else
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- buffer = newbuffer;
-
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- bufline = newbufline;
-
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- bufcolumn = newbufcolumn;
-
- maxNextCharInd = (bufpos -= tokenBegin);
- }
- }
- catch (Throwable t)
- {
- throw new Error(t.getMessage());
- }
-
-
- bufsize += 2048;
- available = bufsize;
- tokenBegin = 0;
- }
-
- private final void FillBuff() throws java.io.IOException
- {
- if (maxNextCharInd == available)
- {
- if (available == bufsize)
- {
- if (tokenBegin > 2048)
- {
- bufpos = maxNextCharInd = 0;
- available = tokenBegin;
- }
- else if (tokenBegin < 0)
- bufpos = maxNextCharInd = 0;
- else
- ExpandBuff(false);
- }
- else if (available > tokenBegin)
- available = bufsize;
- else if ((tokenBegin - available) < 2048)
- ExpandBuff(true);
- else
- available = tokenBegin;
- }
-
- int i;
- try {
- if ((i = inputStream.read(buffer, maxNextCharInd,
- available - maxNextCharInd)) == -1)
- {
- inputStream.close();
- throw new java.io.IOException();
- }
- else
- maxNextCharInd += i;
- return;
- }
- catch(java.io.IOException e) {
- --bufpos;
- backup(0);
- if (tokenBegin == -1)
- tokenBegin = bufpos;
- throw e;
- }
- }
-
- public final char BeginToken() throws java.io.IOException
- {
- tokenBegin = -1;
- char c = readChar();
- tokenBegin = bufpos;
-
- return c;
- }
-
- private final void UpdateLineColumn(char c)
- {
- column++;
-
- if (prevCharIsLF)
- {
- prevCharIsLF = false;
- line += (column = 1);
- }
- else if (prevCharIsCR)
- {
- prevCharIsCR = false;
- if (c == '\n')
- {
- prevCharIsLF = true;
- }
- else
- line += (column = 1);
- }
-
- switch (c)
- {
- case '\r' :
- prevCharIsCR = true;
- break;
- case '\n' :
- prevCharIsLF = true;
- break;
- case '\t' :
- column--;
- column += (8 - (column & 07));
- break;
- default :
- break;
- }
-
- bufline[bufpos] = line;
- bufcolumn[bufpos] = column;
- }
-
- public final char readChar() throws java.io.IOException
- {
- if (inBuf > 0)
- {
- --inBuf;
- return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
- }
-
- if (++bufpos >= maxNextCharInd)
- FillBuff();
-
- char c = (char)((char)0xff & buffer[bufpos]);
-
- UpdateLineColumn(c);
- return (c);
- }
-
- /**
- * @deprecated
- * @see #getEndColumn
- */
- @Deprecated
- public final int getColumn() {
- return bufcolumn[bufpos];
- }
-
- /**
- * @deprecated
- * @see #getEndLine
- */
- @Deprecated
- public final int getLine() {
- return bufline[bufpos];
- }
-
- public final int getEndColumn() {
- return bufcolumn[bufpos];
- }
-
- public final int getEndLine() {
- return bufline[bufpos];
- }
-
- public final int getBeginColumn() {
- return bufcolumn[tokenBegin];
- }
-
- public final int getBeginLine() {
- return bufline[tokenBegin];
- }
-
- public final void backup(int amount) {
-
- inBuf += amount;
- if ((bufpos -= amount) < 0)
- bufpos += bufsize;
- }
-
- public ASCII_CharStream(java.io.Reader dstream, int startline,
- int startcolumn, int buffersize)
- {
- inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
-
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- }
-
- public ASCII_CharStream(java.io.Reader dstream, int startline,
- int startcolumn)
- {
- this(dstream, startline, startcolumn, 4096);
- }
- public void ReInit(java.io.Reader dstream, int startline,
- int startcolumn, int buffersize)
- {
- inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
-
- if (buffer == null || buffersize != buffer.length)
- {
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- }
- prevCharIsLF = prevCharIsCR = false;
- tokenBegin = inBuf = maxNextCharInd = 0;
- bufpos = -1;
- }
-
- public void ReInit(java.io.Reader dstream, int startline,
- int startcolumn)
- {
- ReInit(dstream, startline, startcolumn, 4096);
- }
- public ASCII_CharStream(java.io.InputStream dstream, int startline,
- int startcolumn, int buffersize)
- {
- this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
- }
-
- public ASCII_CharStream(java.io.InputStream dstream, int startline,
- int startcolumn)
- {
- this(dstream, startline, startcolumn, 4096);
- }
-
- public void ReInit(java.io.InputStream dstream, int startline,
- int startcolumn, int buffersize)
- {
- ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
- }
- public void ReInit(java.io.InputStream dstream, int startline,
- int startcolumn)
- {
- ReInit(dstream, startline, startcolumn, 4096);
- }
- public final String GetImage()
- {
- if (bufpos >= tokenBegin)
- return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
- else
- return new String(buffer, tokenBegin, bufsize - tokenBegin) +
- new String(buffer, 0, bufpos + 1);
- }
-
- public final char[] GetSuffix(int len)
- {
- char[] ret = new char[len];
-
- if ((bufpos + 1) >= len)
- System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
- else
- {
- System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
- len - bufpos - 1);
- System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
- }
-
- return ret;
- }
-
- public void Done()
- {
- buffer = null;
- bufline = null;
- bufcolumn = null;
- }
-
- /**
- * Method to adjust line and column numbers for the start of a token.
- */
- public void adjustBeginLineColumn(int newLine, int newCol)
- {
- int start = tokenBegin;
- int len;
-
- if (bufpos >= tokenBegin)
- {
- len = bufpos - tokenBegin + inBuf + 1;
- }
- else
- {
- len = bufsize - tokenBegin + bufpos + 1 + inBuf;
- }
-
- int i = 0, j = 0, k = 0;
- int nextColDiff = 0, columnDiff = 0;
-
- while (i < len &&
- bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
- {
- bufline[j] = newLine;
- nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
- bufcolumn[j] = newCol + columnDiff;
- columnDiff = nextColDiff;
- i++;
- }
-
- if (i < len)
- {
- bufline[j] = newLine++;
- bufcolumn[j] = newCol + columnDiff;
-
- while (i++ < len)
- {
- if (bufline[j = start % bufsize] != bufline[++start % bufsize])
- bufline[j] = newLine++;
- else
- bufline[j] = newLine;
- }
- }
-
- line = bufline[j];
- column = bufcolumn[j];
- }
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclEntryImpl.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclEntryImpl.java
deleted file mode 100644
index 30da053026c..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclEntryImpl.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-
-import java.security.acl.Permission;
-import java.util.Vector;
-import java.util.Enumeration;
-import java.io.Serializable;
-import java.net.UnknownHostException;
-
-import java.security.Principal;
-import java.security.acl.AclEntry;
-
-
-/**
- * Represent one entry in the Access Control List (ACL).
- * This ACL entry object contains a permission associated with a particular principal.
- * (A principal represents an entity such as an individual machine or a group).
- *
- * @see java.security.acl.AclEntry
- */
-
-class AclEntryImpl implements AclEntry, Serializable {
- private static final long serialVersionUID = -5047185131260073216L;
-
- private AclEntryImpl (AclEntryImpl i) throws UnknownHostException {
- setPrincipal(i.getPrincipal());
- permList = new Vector();
- commList = new Vector();
-
- for (Enumeration en = i.communities(); en.hasMoreElements();){
- addCommunity(en.nextElement());
- }
-
- for (Enumeration en = i.permissions(); en.hasMoreElements();){
- addPermission(en.nextElement());
- }
- if (i.isNegative()) setNegativePermissions();
- }
-
- /**
- * Contructs an empty ACL entry.
- */
- public AclEntryImpl (){
- princ = null;
- permList = new Vector();
- commList = new Vector();
- }
-
- /**
- * Constructs an ACL entry with a specified principal.
- *
- * @param p the principal to be set for this entry.
- */
- public AclEntryImpl (Principal p) throws UnknownHostException {
- princ = p;
- permList = new Vector();
- commList = new Vector();
- }
-
- /**
- * Clones this ACL entry.
- *
- * @return a clone of this ACL entry.
- */
- public Object clone() {
- AclEntryImpl i;
- try {
- i = new AclEntryImpl(this);
- }catch (UnknownHostException e) {
- i = null;
- }
- return (Object) i;
- }
-
- /**
- * Returns true if this is a negative ACL entry (one denying the associated principal
- * the set of permissions in the entry), false otherwise.
- *
- * @return true if this is a negative ACL entry, false if it's not.
- */
- public boolean isNegative(){
- return neg;
- }
-
- /**
- * Adds the specified permission to this ACL entry. Note: An entry can
- * have multiple permissions.
- *
- * @param perm the permission to be associated with the principal in this
- * entry
- * @return true if the permission is removed, false if the permission was
- * not part of this entry's permission set.
- *
- */
- public boolean addPermission(java.security.acl.Permission perm){
- if (permList.contains(perm)) return false;
- permList.addElement(perm);
- return true;
- }
-
- /**
- * Removes the specified permission from this ACL entry.
- *
- * @param perm the permission to be removed from this entry.
- * @return true if the permission is removed, false if the permission
- * was not part of this entry's permission set.
- */
- public boolean removePermission(java.security.acl.Permission perm){
- if (!permList.contains(perm)) return false;
- permList.removeElement(perm);
- return true;
- }
-
- /**
- * Checks if the specified permission is part of the permission set in
- * this entry.
- *
- * @param perm the permission to be checked for.
- * @return true if the permission is part of the permission set in this
- * entry, false otherwise.
- */
-
- public boolean checkPermission(java.security.acl.Permission perm){
- return (permList.contains(perm));
- }
-
- /**
- * Returns an enumeration of the permissions in this ACL entry.
- *
- * @return an enumeration of the permissions in this ACL entry.
- */
- public Enumeration permissions(){
- return permList.elements();
- }
-
- /**
- * Sets this ACL entry to be a negative one. That is, the associated principal
- * (e.g., a user or a group) will be denied the permission set specified in the
- * entry. Note: ACL entries are by default positive. An entry becomes a negative
- * entry only if this setNegativePermissions method is called on it.
- *
- * Not Implemented.
- */
- public void setNegativePermissions(){
- neg = true;
- }
-
- /**
- * Returns the principal for which permissions are granted or denied by this ACL
- * entry. Returns null if there is no principal set for this entry yet.
- *
- * @return the principal associated with this entry.
- */
- public Principal getPrincipal(){
- return princ;
- }
-
- /**
- * Specifies the principal for which permissions are granted or denied by
- * this ACL entry. If a principal was already set for this ACL entry,
- * false is returned, otherwise true is returned.
- *
- * @param p the principal to be set for this entry.
- * @return true if the principal is set, false if there was already a
- * principal set for this entry.
- */
- public boolean setPrincipal(Principal p) {
- if (princ != null )
- return false;
- princ = p;
- return true;
- }
-
- /**
- * Returns a string representation of the contents of this ACL entry.
- *
- * @return a string representation of the contents.
- */
- public String toString(){
- return "AclEntry:"+princ.toString();
- }
-
- /**
- * Returns an enumeration of the communities in this ACL entry.
- *
- * @return an enumeration of the communities in this ACL entry.
- */
- public Enumeration communities(){
- return commList.elements();
- }
-
- /**
- * Adds the specified community to this ACL entry. Note: An entry can
- * have multiple communities.
- *
- * @param comm the community to be associated with the principal
- * in this entry.
- * @return true if the community was added, false if the community was
- * already part of this entry's community set.
- */
- public boolean addCommunity(String comm){
- if (commList.contains(comm)) return false;
- commList.addElement(comm);
- return true;
- }
-
- /**
- * Removes the specified community from this ACL entry.
- *
- * @param comm the community to be removed from this entry.
- * @return true if the community is removed, false if the community was
- * not part of this entry's community set.
- */
- public boolean removeCommunity(String comm){
- if (!commList.contains(comm)) return false;
- commList.removeElement(comm);
- return true;
- }
-
- /**
- * Checks if the specified community is part of the community set in this
- * entry.
- *
- * @param comm the community to be checked for.
- * @return true if the community is part of the community set in this
- * entry, false otherwise.
- */
- public boolean checkCommunity(String comm){
- return (commList.contains(comm));
- }
-
- private Principal princ = null;
- private boolean neg = false;
- private Vector permList = null;
- private Vector commList = null;
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclImpl.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclImpl.java
deleted file mode 100644
index d29c4e06a5e..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/AclImpl.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-
-import java.security.Principal;
-import java.security.acl.Acl;
-import java.security.acl.AclEntry;
-import java.security.acl.NotOwnerException;
-
-import java.io.Serializable;
-import java.security.acl.Permission;
-import java.util.Vector;
-import java.util.Enumeration;
-
-
-/**
- * Represent an Access Control List (ACL) which is used to guard access to http adaptor.
- *
- * It is a data structure with multiple ACL entries. Each ACL entry, of interface type
- * AclEntry, contains a set of permissions and a set of communities associated with a
- * particular principal. (A principal represents an entity such as a host or a group of host).
- * Additionally, each ACL entry is specified as being either positive or negative.
- * If positive, the permissions are to be granted to the associated principal.
- * If negative, the permissions are to be denied.
- *
- * @see java.security.acl.Acl
- */
-
-class AclImpl extends OwnerImpl implements Acl, Serializable {
- private static final long serialVersionUID = -2250957591085270029L;
-
- private Vector entryList = null;
- private String aclName = null;
-
- /**
- * Constructs the ACL with a specified owner
- *
- * @param owner owner of the ACL.
- * @param name name of this ACL.
- */
- public AclImpl (PrincipalImpl owner, String name) {
- super(owner);
- entryList = new Vector<>();
- aclName = name;
- }
-
- /**
- * Sets the name of this ACL.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of this ACL.
- * @param name the name to be given to this ACL.
- *
- * @exception NotOwnerException if the caller principal is not an owner
- * of this ACL.
- * @see java.security.Principal
- */
- @Override
- public void setName(Principal caller, String name)
- throws NotOwnerException {
- if (!isOwner(caller))
- throw new NotOwnerException();
- aclName = name;
- }
-
- /**
- * Returns the name of this ACL.
- *
- * @return the name of this ACL.
- */
- @Override
- public String getName(){
- return aclName;
- }
-
- /**
- * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
- * with a set of permissions. Each principal can have at most one positive ACL entry
- * (specifying permissions to be granted to the principal) and one negative ACL entry
- * (specifying permissions to be denied). If there is already an ACL entry
- * of the same type (negative or positive) already in the ACL, false is returned.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of this ACL.
- * @param entry the ACL entry to be added to this ACL.
- * @return true on success, false if an entry of the same type (positive
- * or negative) for the same principal is already present in this ACL.
- * @exception NotOwnerException if the caller principal is not an owner of
- * this ACL.
- * @see java.security.Principal
- */
- @Override
- public boolean addEntry(Principal caller, AclEntry entry)
- throws NotOwnerException {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- if (entryList.contains(entry))
- return false;
- /*
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntry ent = (AclEntry) e.nextElement();
- if (ent.getPrincipal().equals(entry.getPrincipal()))
- return false;
- }
- */
-
- entryList.addElement(entry);
- return true;
- }
-
- /**
- * Removes an ACL entry from this ACL.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of this ACL.
- * @param entry the ACL entry to be removed from this ACL.
- * @return true on success, false if the entry is not part of this ACL.
- * @exception NotOwnerException if the caller principal is not an owner
- * of this Acl.
- * @see java.security.Principal
- * @see java.security.acl.AclEntry
- */
- @Override
- public boolean removeEntry(Principal caller, AclEntry entry)
- throws NotOwnerException {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- return (entryList.removeElement(entry));
- }
-
- /**
- * Removes all ACL entries from this ACL.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of this ACL.
- * @exception NotOwnerException if the caller principal is not an owner of
- * this Acl.
- * @see java.security.Principal
- */
- public void removeAll(Principal caller)
- throws NotOwnerException {
- if (!isOwner(caller))
- throw new NotOwnerException();
- entryList.removeAllElements();
- }
-
- /**
- * Returns an enumeration for the set of allowed permissions for
- * the specified principal
- * (representing an entity such as an individual or a group).
- * This set of allowed permissions is calculated as follows:
- *
- * - If there is no entry in this Access Control List for the specified
- * principal, an empty permission set is returned.
- * - Otherwise, the principal's group permission sets are determined.
- * (A principal can belong to one or more groups, where a group is a group
- * of principals, represented by the Group interface.)
- *
- * @param user the principal whose permission set is to be returned.
- * @return the permission set specifying the permissions the principal
- * is allowed.
- * @see java.security.Principal
- */
- @Override
- public Enumeration getPermissions(Principal user){
- Vector empty = new Vector<>();
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntry ent = e.nextElement();
- if (ent.getPrincipal().equals(user))
- return ent.permissions();
- }
- return empty.elements();
- }
-
- /**
- * Returns an enumeration of the entries in this ACL. Each element in the
- * enumeration is of type AclEntry.
- *
- * @return an enumeration of the entries in this ACL.
- */
- @Override
- public Enumeration entries(){
- return entryList.elements();
- }
-
- /**
- * Checks whether or not the specified principal has the specified
- * permission.
- * If it does, true is returned, otherwise false is returned.
- * More specifically, this method checks whether the passed permission
- * is a member of the allowed permission set of the specified principal.
- * The allowed permission set is determined by the same algorithm as is
- * used by the getPermissions method.
- *
- * @param user the principal, assumed to be a valid authenticated Principal.
- * @param perm the permission to be checked for.
- * @return true if the principal has the specified permission,
- * false otherwise.
- * @see java.security.Principal
- * @see java.security.Permission
- */
- @Override
- public boolean checkPermission(Principal user,
- java.security.acl.Permission perm) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntry ent = e.nextElement();
- if (ent.getPrincipal().equals(user))
- if (ent.checkPermission(perm)) return true;
- }
- return false;
- }
-
- /**
- * Checks whether or not the specified principal has the specified
- * permission.
- * If it does, true is returned, otherwise false is returned.
- * More specifically, this method checks whether the passed permission
- * is a member of the allowed permission set of the specified principal.
- * The allowed permission set is determined by the same algorithm as is
- * used by the getPermissions method.
- *
- * @param user the principal, assumed to be a valid authenticated Principal.
- * @param community the community name associated with the principal.
- * @param perm the permission to be checked for.
- * @return true if the principal has the specified permission, false
- * otherwise.
- * @see java.security.Principal
- * @see java.security.Permission
- */
- public boolean checkPermission(Principal user, String community,
- java.security.acl.Permission perm) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntryImpl ent = (AclEntryImpl) e.nextElement();
- if (ent.getPrincipal().equals(user))
- if (ent.checkPermission(perm) && ent.checkCommunity(community)) return true;
- }
- return false;
- }
-
- /**
- * Checks whether or not the specified community string is defined.
- *
- * @param community the community name associated with the principal.
- *
- * @return true if the specified community string is defined, false
- * otherwise.
- * @see java.security.Principal
- * @see java.security.Permission
- */
- public boolean checkCommunity(String community) {
- for (Enumeration e = entryList.elements();e.hasMoreElements();){
- AclEntryImpl ent = (AclEntryImpl) e.nextElement();
- if (ent.checkCommunity(community)) return true;
- }
- return false;
- }
-
- /**
- * Returns a string representation of the ACL contents.
- *
- * @return a string representation of the ACL contents.
- */
- @Override
- public String toString(){
- return ("AclImpl: "+ getName());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/GroupImpl.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/GroupImpl.java
deleted file mode 100644
index 82856781232..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/GroupImpl.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-
-import java.util.Vector;
-import java.util.Enumeration;
-import java.io.Serializable;
-import java.net.UnknownHostException;
-
-
-import java.security.Principal;
-import java.security.acl.Group;
-
-
-/**
- * This class is used to represent a subnet mask (a group of hosts
- * matching the same
- * IP mask).
- *
- */
-
-class GroupImpl extends PrincipalImpl implements Group, Serializable {
- private static final long serialVersionUID = -7777387035032541168L;
-
- /**
- * Constructs an empty group.
- * @exception UnknownHostException Not implemented
- */
- public GroupImpl () throws UnknownHostException {
- }
-
- /**
- * Constructs a group using the specified subnet mask.
- *
- * @param mask The subnet mask to use to build the group.
- * @exception UnknownHostException if the subnet mask cann't be built.
- */
- public GroupImpl (String mask) throws UnknownHostException {
- super(mask);
- }
-
- /**
- * Adds the specified member to the group.
- *
- * @param p the principal to add to this group.
- * @return true if the member was successfully added, false if the
- * principal was already a member.
- */
- public boolean addMember(Principal p) {
- // we don't need to add members because the ip address is a
- // subnet mask
- return true;
- }
-
- public int hashCode() {
- return super.hashCode();
- }
-
- /**
- * Compares this group to the specified object. Returns true if the object
- * passed in matches the group represented.
- *
- * @param p the object to compare with.
- * @return true if the object passed in matches the subnet mask,
- * false otherwise.
- */
- public boolean equals (Object p) {
- if (p instanceof PrincipalImpl || p instanceof GroupImpl){
- if ((super.hashCode() & p.hashCode()) == p.hashCode()) return true;
- else return false;
- } else {
- return false;
- }
- }
-
- /**
- * Returns true if the passed principal is a member of the group.
- *
- * @param p the principal whose membership is to be checked.
- * @return true if the principal is a member of this group, false otherwise.
- */
- public boolean isMember(Principal p) {
- if ((p.hashCode() & super.hashCode()) == p.hashCode()) return true;
- else return false;
- }
-
- /**
- * Returns an enumeration which contains the subnet mask.
- *
- * @return an enumeration which contains the subnet mask.
- */
- public Enumeration extends Principal> members(){
- Vector v = new Vector(1);
- v.addElement(this);
- return v.elements();
- }
-
- /**
- * Removes the specified member from the group. (Not implemented)
- *
- * @param p the principal to remove from this group.
- * @return allways return true.
- */
- public boolean removeMember(Principal p) {
- return true;
- }
-
- /**
- * Prints a string representation of this group.
- *
- * @return a string representation of this group.
- */
- public String toString() {
- return ("GroupImpl :"+super.getAddress().toString());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Host.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Host.java
deleted file mode 100644
index b502f79509a..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Host.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-
-// java import
-//
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Hashtable;
-import java.util.logging.Level;
-import java.util.Vector;
-import java.security.acl.NotOwnerException;
-
-import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
-
-/**
- * The class defines an abstract representation of a host.
- *
- */
-@SuppressWarnings("serial") // JDK implementation class
-abstract class Host extends SimpleNode implements Serializable {
-
- public Host(int id) {
- super(id);
- }
-
- public Host(Parser p, int id) {
- super(p, id);
- }
-
- protected abstract PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException;
-
- protected abstract String getHname();
-
- public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {
- // Create a principal
- //
- PrincipalImpl p=null;
- try {
- p = createAssociatedPrincipal();
- } catch(UnknownHostException e) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
- "buildAclEntries",
- "Cannot create ACL entry; got exception", e);
- }
- throw new IllegalArgumentException("Cannot create ACL entry for " + e.getMessage());
- }
-
- // Create an AclEntry
- //
- AclEntryImpl entry= null;
- try {
- entry = new AclEntryImpl(p);
- // Add permission
- //
- registerPermission(entry);
- acl.addEntry(owner, entry);
- } catch(UnknownHostException e) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
- "buildAclEntries",
- "Cannot create ACL entry; got exception", e);
- }
- return;
- } catch(NotOwnerException a) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
- "buildAclEntries",
- "Cannot create ACL entry; got exception", a);
- }
- return;
- }
- }
-
- private void registerPermission(AclEntryImpl entry) {
- JDMHost host= (JDMHost) jjtGetParent();
- JDMManagers manager= (JDMManagers) host.jjtGetParent();
- JDMAclItem acl= (JDMAclItem) manager.jjtGetParent();
- JDMAccess access= acl.getAccess();
- access.putPermission(entry);
- JDMCommunities comm= acl.getCommunities();
- comm.buildCommunities(entry);
- }
-
- public void buildTrapEntries(Hashtable> dest) {
-
- JDMHostTrap host= (JDMHostTrap) jjtGetParent();
- JDMTrapInterestedHost hosts= (JDMTrapInterestedHost) host.jjtGetParent();
- JDMTrapItem trap = (JDMTrapItem) hosts.jjtGetParent();
- JDMTrapCommunity community = trap.getCommunity();
- String comm = community.getCommunity();
-
- InetAddress add = null;
- try {
- add = java.net.InetAddress.getByName(getHname());
- } catch(UnknownHostException e) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
- "buildTrapEntries",
- "Cannot create TRAP entry; got exception", e);
- }
- return;
- }
-
- Vector list = null;
- if (dest.containsKey(add)){
- list = dest.get(add);
- if (!list.contains(comm)){
- list.addElement(comm);
- }
- } else {
- list = new Vector();
- list.addElement(comm);
- dest.put(add,list);
- }
- }
-
- public void buildInformEntries(Hashtable> dest) {
-
- JDMHostInform host= (JDMHostInform) jjtGetParent();
- JDMInformInterestedHost hosts= (JDMInformInterestedHost) host.jjtGetParent();
- JDMInformItem inform = (JDMInformItem) hosts.jjtGetParent();
- JDMInformCommunity community = inform.getCommunity();
- String comm = community.getCommunity();
-
- InetAddress add = null;
- try {
- add = java.net.InetAddress.getByName(getHname());
- } catch(UnknownHostException e) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
- "buildTrapEntries",
- "Cannot create INFORM entry; got exception", e);
- }
- return;
- }
-
- Vector list = null;
- if (dest.containsKey(add)){
- list = dest.get(add);
- if (!list.contains(comm)){
- list.addElement(comm);
- }
- } else {
- list = new Vector();
- list.addElement(comm);
- dest.put(add,list);
- }
- }
-
-
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAccess.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAccess.java
deleted file mode 100644
index b598aab5b76..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAccess.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMAccess.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-class JDMAccess extends SimpleNode {
- protected int access= -1;
-
- JDMAccess(int id) {
- super(id);
- }
-
- JDMAccess(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMAccess(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMAccess(p, id);
- }
-
- protected void putPermission(AclEntryImpl entry) {
- if (access == ParserConstants.RO) {
- // We have a read-only access.
- //
- entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getREAD());
- }
- if (access == ParserConstants.RW) {
- // We have a read-write access.
- //
- entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getREAD());
- entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getWRITE());
- }
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java
deleted file mode 100644
index 1062575c859..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMAclBlock.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.net.InetAddress;
-import java.util.Hashtable;
-import java.util.Vector;
-
-class JDMAclBlock extends SimpleNode {
- JDMAclBlock(int id) {
- super(id);
- }
-
- JDMAclBlock(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMAclBlock(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMAclBlock(p, id);
- }
-
- /**
- * Do no need to go through this part of the tree for
- * building TrapEntry.
- */
- @Override
- public void buildTrapEntries(Hashtable> dest) {}
-
- /**
- * Do no need to go through this part of the tree for
- * building InformEntry.
- */
- @Override
- public void buildInformEntries(Hashtable> dest) {}
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclItem.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclItem.java
deleted file mode 100644
index e2756f956bc..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMAclItem.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMAclItem.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMAclItem extends SimpleNode {
- protected JDMAccess access= null;
- protected JDMCommunities com= null;
-
- JDMAclItem(int id) {
- super(id);
- }
-
- JDMAclItem(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMAclItem(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMAclItem(p, id);
- }
-
- public JDMAccess getAccess() {
- return access;
- }
-
- public JDMCommunities getCommunities() {
- return com;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunities.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunities.java
deleted file mode 100644
index cc88a96e81d..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunities.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMCommunities.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-class JDMCommunities extends SimpleNode {
- JDMCommunities(int id) {
- super(id);
- }
-
- JDMCommunities(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMCommunities(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMCommunities(p, id);
- }
-
- public void buildCommunities(AclEntryImpl entry){
- for (int i =0 ; i < children.length ; i++)
- entry.addCommunity(((JDMCommunity)children[i]).getCommunity());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunity.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunity.java
deleted file mode 100644
index 883b266d0aa..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMCommunity.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMCommunity.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMCommunity extends SimpleNode {
- protected String communityString= "";
-
- JDMCommunity(int id) {
- super(id);
- }
-
- JDMCommunity(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMCommunity(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMCommunity(p, id);
- }
-
- public String getCommunity(){
- return communityString;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMEnterprise.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMEnterprise.java
deleted file mode 100644
index 37f6d82ec43..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMEnterprise.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMEnterprise.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMEnterprise extends SimpleNode {
- protected String enterprise= "";
-
- JDMEnterprise(int id) {
- super(id);
- }
-
- JDMEnterprise(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMEnterprise(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMEnterprise(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHost.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHost.java
deleted file mode 100644
index d1ffcf50c6d..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHost.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMHost.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-class JDMHost extends SimpleNode {
-
- JDMHost(int id) {
- super(id);
- }
-
- JDMHost(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMHost(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMHost(p, id);
- }
-
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostInform.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostInform.java
deleted file mode 100644
index 7c7a7e6c082..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostInform.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMHostInform.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMHostInform extends SimpleNode {
- protected String name= "";
-
- JDMHostInform(int id) {
- super(id);
- }
-
- JDMHostInform(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMHostInform(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMHostInform(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostName.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostName.java
deleted file mode 100644
index e51ab02d7fb..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostName.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMHostName.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.net.UnknownHostException;
-
-class JDMHostName extends Host {
- private static final long serialVersionUID = -9120082068923591122L;
-
- protected StringBuffer name = new StringBuffer();
-
- JDMHostName(int id) {
- super(id);
- }
-
- JDMHostName(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMHostName(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMHostName(p, id);
- }
-
- protected String getHname() {
- return name.toString();
- }
-
- protected PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException {
- return new PrincipalImpl(name.toString());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostTrap.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostTrap.java
deleted file mode 100644
index f5163922101..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMHostTrap.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMHostTrap.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMHostTrap extends SimpleNode {
- protected String name= "";
-
- JDMHostTrap(int id) {
- super(id);
- }
-
- JDMHostTrap(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMHostTrap(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMHostTrap(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java
deleted file mode 100644
index 10390f05ef4..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMInformBlock.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.net.InetAddress;
-import java.util.Hashtable;
-import java.util.Vector;
-
-class JDMInformBlock extends SimpleNode {
- JDMInformBlock(int id) {
- super(id);
- }
-
- JDMInformBlock(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMInformBlock(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMInformBlock(p, id);
- }
-
- /**
- * Do no need to go through this part of the tree for
- * building AclEntry.
- */
- @Override
- public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
-
- /**
- * Do no need to go through this part of the tree for
- * building TrapEntry.
- */
- @Override
- public void buildTrapEntries(Hashtable> dest) {}
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformCommunity.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformCommunity.java
deleted file mode 100644
index a8058468685..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformCommunity.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMInformCommunity.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMInformCommunity extends SimpleNode {
- protected String community= "";
- JDMInformCommunity(int id) {
- super(id);
- }
-
- JDMInformCommunity(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMInformCommunity(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMInformCommunity(p, id);
- }
-
- public String getCommunity() {
- return community;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformInterestedHost.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformInterestedHost.java
deleted file mode 100644
index 9ad2a849ad3..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformInterestedHost.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMInformInterestedHost.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMInformInterestedHost extends SimpleNode {
- JDMInformInterestedHost(int id) {
- super(id);
- }
-
- JDMInformInterestedHost(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMInformInterestedHost(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMInformInterestedHost(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformItem.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformItem.java
deleted file mode 100644
index 03d068f40b9..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMInformItem.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMInformItem.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMInformItem extends SimpleNode {
- protected JDMInformCommunity comm = null;
- JDMInformItem(int id) {
- super(id);
- }
-
- JDMInformItem(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMInformItem(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMInformItem(p, id);
- }
-
- public JDMInformCommunity getCommunity(){
- return comm;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpAddress.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpAddress.java
deleted file mode 100644
index c0caa7cf496..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpAddress.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMIpAddress.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.lang.StringBuffer;
-import java.net.UnknownHostException;
-
-class JDMIpAddress extends Host {
- private static final long serialVersionUID = 849729919486384484L;
-
- protected StringBuffer address= new StringBuffer();
-
- JDMIpAddress(int id) {
- super(id);
- }
-
- JDMIpAddress(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMIpAddress(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMIpAddress(p, id);
- }
-
- protected String getHname() {
- return address.toString();
- }
-
- protected PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException {
- return new PrincipalImpl(address.toString());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpMask.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpMask.java
deleted file mode 100644
index fb6197e95a7..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpMask.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMIpMask.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.lang.StringBuffer;
-import java.net.UnknownHostException;
-
-class JDMIpMask extends Host {
- private static final long serialVersionUID = -8211312690652331386L;
-
- protected StringBuffer address= new StringBuffer();
-
- JDMIpMask(int id) {
- super(id);
- }
-
- JDMIpMask(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMIpMask(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMIpMask(p, id);
- }
-
- protected String getHname() {
- return address.toString();
- }
-
- protected PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException {
- return new GroupImpl(address.toString());
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpV6Address.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpV6Address.java
deleted file mode 100644
index d072a5473f9..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMIpV6Address.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JDMIpV6Address.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMIpV6Address extends JDMIpAddress {
- private static final long serialVersionUID = -5929917334606674243L;
-
- public JDMIpV6Address(int id) {
- super(id);
- }
-
- public JDMIpV6Address(Parser p, int id) {
- super(p, id);
- }
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMManagers.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMManagers.java
deleted file mode 100644
index 5b07c0895f3..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMManagers.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMManagers.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMManagers extends SimpleNode {
- JDMManagers(int id) {
- super(id);
- }
-
- JDMManagers(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMManagers(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMManagers(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMask.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMask.java
deleted file mode 100644
index fa790b7540c..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMNetMask.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-/* Generated By:JJTree: Do not edit this line. JDMNetMask.java */
-
-package com.sun.jmx.snmp.IPAcl;
-import java.net.UnknownHostException;
-
-class JDMNetMask extends Host {
- private static final long serialVersionUID = -1979318280250821787L;
-
- protected StringBuffer address= new StringBuffer();
- protected String mask = null;
- public JDMNetMask(int id) {
- super(id);
- }
-
- public JDMNetMask(Parser p, int id) {
- super(p, id);
- }
-public static Node jjtCreate(int id) {
- return new JDMNetMask(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMNetMask(p, id);
- }
-
- protected String getHname() {
- return address.toString();
- }
-
- protected PrincipalImpl createAssociatedPrincipal()
- throws UnknownHostException {
- return new NetMaskImpl(address.toString(), Integer.parseInt(mask));
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMSecurityDefs.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMSecurityDefs.java
deleted file mode 100644
index 727b29b47be..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMSecurityDefs.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMSecurityDefs.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMSecurityDefs extends SimpleNode {
- JDMSecurityDefs(int id) {
- super(id);
- }
-
- JDMSecurityDefs(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMSecurityDefs(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMSecurityDefs(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java
deleted file mode 100644
index 5801d390984..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMTrapBlock.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.net.InetAddress;
-import java.util.Hashtable;
-import java.util.Vector;
-
-class JDMTrapBlock extends SimpleNode {
- JDMTrapBlock(int id) {
- super(id);
- }
-
- JDMTrapBlock(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMTrapBlock(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMTrapBlock(p, id);
- }
-
- /**
- * Do no need to go through this part of the tree for
- * building AclEntry.
- */
- @Override
- public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
-
- /**
- * Do no need to go through this part of the tree for
- * building InformEntry.
- */
- @Override
- public void buildInformEntries(Hashtable> dest) {}
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapCommunity.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapCommunity.java
deleted file mode 100644
index 82cc8e14625..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapCommunity.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMTrapCommunity.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMTrapCommunity extends SimpleNode {
- protected String community= "";
- JDMTrapCommunity(int id) {
- super(id);
- }
-
- JDMTrapCommunity(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMTrapCommunity(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMTrapCommunity(p, id);
- }
-
- public String getCommunity() {
- return community;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapInterestedHost.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapInterestedHost.java
deleted file mode 100644
index 1ca4eebd644..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapInterestedHost.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMTrapInterestedHost.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMTrapInterestedHost extends SimpleNode {
- JDMTrapInterestedHost(int id) {
- super(id);
- }
-
- JDMTrapInterestedHost(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMTrapInterestedHost(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMTrapInterestedHost(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapItem.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapItem.java
deleted file mode 100644
index f7379fe9ddd..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapItem.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMTrapItem.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMTrapItem extends SimpleNode {
- protected JDMTrapCommunity comm = null;
-
- JDMTrapItem(int id) {
- super(id);
- }
-
- JDMTrapItem(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMTrapItem(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMTrapItem(p, id);
- }
-
- public JDMTrapCommunity getCommunity(){
- return comm;
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapNum.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapNum.java
deleted file mode 100644
index 1b38ecdc893..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JDMTrapNum.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. JDMTrapNum.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JDMTrapNum extends SimpleNode {
- protected int low=0;
- protected int high=0;
-
- JDMTrapNum(int id) {
- super(id);
- }
-
- JDMTrapNum(Parser p, int id) {
- super(p, id);
- }
-
- public static Node jjtCreate(int id) {
- return new JDMTrapNum(id);
- }
-
- public static Node jjtCreate(Parser p, int id) {
- return new JDMTrapNum(p, id);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JJTParserState.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JJTParserState.java
deleted file mode 100644
index ea457515d05..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/JJTParserState.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree: Do not edit this line. JJTParserState.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-class JJTParserState {
- private java.util.Stack nodes;
- private java.util.Stack marks;
-
- private int sp; // number of nodes on stack
- private int mk; // current mark
- private boolean node_created;
-
- JJTParserState() {
- nodes = new java.util.Stack<>();
- marks = new java.util.Stack<>();
- sp = 0;
- mk = 0;
- }
-
- /* Determines whether the current node was actually closed and
- pushed. This should only be called in the final user action of a
- node scope. */
- boolean nodeCreated() {
- return node_created;
- }
-
- /* Call this to reinitialize the node stack. It is called
- automatically by the parser's ReInit() method. */
- void reset() {
- nodes.removeAllElements();
- marks.removeAllElements();
- sp = 0;
- mk = 0;
- }
-
- /* Returns the root node of the AST. It only makes sense to call
- this after a successful parse. */
- Node rootNode() {
- return nodes.elementAt(0);
- }
-
- /* Pushes a node on to the stack. */
- void pushNode(Node n) {
- nodes.push(n);
- ++sp;
- }
-
- /* Returns the node on the top of the stack, and remove it from the
- stack. */
- Node popNode() {
- if (--sp < mk) {
- mk = marks.pop().intValue();
- }
- return nodes.pop();
- }
-
- /* Returns the node currently on the top of the stack. */
- Node peekNode() {
- return nodes.peek();
- }
-
- /* Returns the number of children on the stack in the current node
- scope. */
- int nodeArity() {
- return sp - mk;
- }
-
-
- void clearNodeScope(Node n) {
- while (sp > mk) {
- popNode();
- }
- mk = marks.pop().intValue();
- }
-
-
- void openNodeScope(Node n) {
- marks.push(mk);
- mk = sp;
- n.jjtOpen();
- }
-
-
- /* A definite node is constructed from a specified number of
- children. That number of nodes are popped from the stack and
- made the children of the definite node. Then the definite node
- is pushed on to the stack. */
- void closeNodeScope(Node n, int num) {
- mk = marks.pop().intValue();
- while (num-- > 0) {
- Node c = popNode();
- c.jjtSetParent(n);
- n.jjtAddChild(c, num);
- }
- n.jjtClose();
- pushNode(n);
- node_created = true;
- }
-
-
- /* A conditional node is constructed if its condition is true. All
- the nodes that have been pushed since the node was opened are
- made children of the the conditional node, which is then pushed
- on to the stack. If the condition is false the node is not
- constructed and they are left on the stack. */
- void closeNodeScope(Node n, boolean condition) {
- if (condition) {
- int a = nodeArity();
- mk = marks.pop().intValue();
- while (a-- > 0) {
- Node c = popNode();
- c.jjtSetParent(n);
- n.jjtAddChild(c, a);
- }
- n.jjtClose();
- pushNode(n);
- node_created = true;
- } else {
- mk = marks.pop().intValue();
- node_created = false;
- }
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java
deleted file mode 100644
index 9606c020266..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.jmx.snmp.IPAcl;
-
-import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
-
-import java.util.logging.Level;
-import java.util.Vector;
-import java.util.Enumeration;
-import java.io.Serializable;
-import java.net.UnknownHostException;
-import java.net.InetAddress;
-
-import java.security.Principal;
-import java.security.acl.Group;
-
-
-/**
- * This class is used to represent a subnet mask (a group of hosts matching the same
- * IP mask).
- *
- * @see java.security.acl.Group
- */
-
-class NetMaskImpl extends PrincipalImpl implements Group, Serializable {
- private static final long serialVersionUID = -7332541893877932896L;
-
- protected byte[] subnet = null;
- protected int prefix = -1;
- /**
- * Constructs an empty group.
- * @exception UnknownHostException Not implemented
- */
- public NetMaskImpl () throws UnknownHostException {
- }
-
- private byte[] extractSubNet(byte[] b) {
- int addrLength = b.length;
- byte[] subnet = null;
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
- "extractSubNet", "BINARY ARRAY :");
- StringBuilder sb = new StringBuilder();
- for(int i =0; i < addrLength; i++) {
- sb.append((b[i] & 0xFF) + ":");
- }
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
- "extractSubNet", sb.toString());
- }
-
- // 8 is a byte size. Common to any InetAddress (V4 or V6).
- int fullyCoveredByte = prefix / 8;
- if(fullyCoveredByte == addrLength) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "The mask is the complete address, strange..." + addrLength);
- }
- subnet = b;
- return subnet;
- }
- if(fullyCoveredByte > addrLength) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "The number of covered byte is longer than the address. BUG");
- }
- throw new IllegalArgumentException("The number of covered byte is longer than the address.");
- }
- int partialyCoveredIndex = fullyCoveredByte;
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Partially covered index : " + partialyCoveredIndex);
- }
- byte toDeal = b[partialyCoveredIndex];
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Partially covered byte : " + toDeal);
- }
-
- // 8 is a byte size. Common to any InetAddress (V4 or V6).
- int nbbits = prefix % 8;
- int subnetSize = 0;
-
- if(nbbits == 0)
- subnetSize = partialyCoveredIndex;
- else
- subnetSize = partialyCoveredIndex + 1;
-
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Remains : " + nbbits);
- }
-
- byte mask = 0;
- for(int i = 0; i < nbbits; i++) {
- mask |= (1 << (7 - i));
- }
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Mask value : " + (mask & 0xFF));
- }
-
- byte maskedValue = (byte) ((int)toDeal & (int)mask);
-
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Masked byte : " + (maskedValue &0xFF));
- }
- subnet = new byte[subnetSize];
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Resulting subnet : ");
- }
- for(int i = 0; i < partialyCoveredIndex; i++) {
- subnet[i] = b[i];
-
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- (subnet[i] & 0xFF) +":");
- }
- }
-
- if(nbbits != 0) {
- subnet[partialyCoveredIndex] = maskedValue;
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
- "Last subnet byte : " + (subnet[partialyCoveredIndex] &0xFF));
- }
- }
- return subnet;
- }
-
- /**
- * Constructs a group using the specified subnet mask.
- * THIS ALGORITHM IS V4 and V6 compatible.
- *
- * @exception UnknownHostException if the subnet mask cann't be built.
- */
- public NetMaskImpl (String a, int prefix) throws UnknownHostException {
- super(a);
- this.prefix = prefix;
- subnet = extractSubNet(getAddress().getAddress());
- }
-
- /**
- * Adds the specified member to the group.
- *
- * @param p the principal to add to this group.
- * @return true if the member was successfully added, false if the
- * principal was already a member.
- */
- public boolean addMember(Principal p) {
- // we don't need to add members because the ip address is a subnet mask
- return true;
- }
-
- public int hashCode() {
- return super.hashCode();
- }
-
- /**
- * Compares this group to the specified object. Returns true if the object
- * passed in matches the group represented.
- *
- * @param p the object to compare with.
- * @return true if the object passed in matches the subnet mask,
- * false otherwise.
- */
- public boolean equals (Object p) {
- if (p instanceof PrincipalImpl || p instanceof NetMaskImpl){
- PrincipalImpl received = (PrincipalImpl) p;
- InetAddress addr = received.getAddress();
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
- "Received Address : " + addr);
- }
- byte[] recAddr = addr.getAddress();
- for(int i = 0; i < subnet.length; i++) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
- "(recAddr[i]) : " + (recAddr[i] & 0xFF));
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
- "(recAddr[i] & subnet[i]) : " +
- ((recAddr[i] & (int)subnet[i]) &0xFF) +
- " subnet[i] : " + (subnet[i] &0xFF));
- }
- if((recAddr[i] & subnet[i]) != subnet[i]) {
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
- "FALSE");
- }
- return false;
- }
- }
- if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
- SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
- "TRUE");
- }
- return true;
- } else
- return false;
- }
- /**
- * Returns true if the passed principal is a member of the group.
- *
- * @param p the principal whose membership is to be checked.
- * @return true if the principal is a member of this group, false otherwise.
- */
- public boolean isMember(Principal p) {
- if ((p.hashCode() & super.hashCode()) == p.hashCode()) return true;
- else return false;
- }
-
- /**
- * Returns an enumeration which contains the subnet mask.
- *
- * @return an enumeration which contains the subnet mask.
- */
- public Enumeration extends Principal> members(){
- Vector v = new Vector(1);
- v.addElement(this);
- return v.elements();
- }
-
- /**
- * Removes the specified member from the group. (Not implemented)
- *
- * @param p the principal to remove from this group.
- * @return allways return true.
- */
- public boolean removeMember(Principal p) {
- return true;
- }
-
- /**
- * Prints a string representation of this group.
- *
- * @return a string representation of this group.
- */
- public String toString() {
- return ("NetMaskImpl :"+ super.getAddress().toString() + "/" + prefix);
- }
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Node.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Node.java
deleted file mode 100644
index fa0d2159731..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Node.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JJTree: Do not edit this line. Node.java */
-
-package com.sun.jmx.snmp.IPAcl;
-
-/* All AST nodes must implement this interface. It provides basic
- machinery for constructing the parent and child relationships
- between nodes. */
-
-interface Node {
-
- /** This method is called after the node has been made the current
- node. It indicates that child nodes can now be added to it. */
- public void jjtOpen();
-
- /** This method is called after all the child nodes have been
- added. */
- public void jjtClose();
-
- /** This pair of methods are used to inform the node of its
- parent. */
- public void jjtSetParent(Node n);
- public Node jjtGetParent();
-
- /** This method tells the node to add its argument to the node's
- list of children. */
- public void jjtAddChild(Node n, int i);
-
- /** This method returns a child node. The children are numbered
- from zero, left to right. */
- public Node jjtGetChild(int i);
-
- /** Return the number of children the node has. */
- public int jjtGetNumChildren();
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/OwnerImpl.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/OwnerImpl.java
deleted file mode 100644
index d72b973390e..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/OwnerImpl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-package com.sun.jmx.snmp.IPAcl;
-
-
-
-import java.util.Vector;
-import java.io.Serializable;
-
-import java.security.Principal;
-import java.security.acl.Owner;
-import java.security.acl.LastOwnerException;
-import java.security.acl.NotOwnerException;
-
-
-/**
- * Owner of Access Control Lists (ACLs).
- * The initial owner Principal should be specified as an
- * argument to the constructor of the class AclImpl.
- *
- * @see java.security.acl.Owner
- */
-
-class OwnerImpl implements Owner, Serializable {
- private static final long serialVersionUID = -576066072046319874L;
-
- private Vector ownerList = null;
-
- /**
- * Constructs an empty list of owner.
- */
- public OwnerImpl (){
- ownerList = new Vector();
- }
-
- /**
- * Constructs a list of owner with the specified principal as first element.
- *
- * @param owner the principal added to the owner list.
- */
- public OwnerImpl (PrincipalImpl owner){
- ownerList = new Vector();
- ownerList.addElement(owner);
- }
-
- /**
- * Adds an owner. Only owners can modify ACL contents. The caller principal
- * must be an owner of the ACL in order to invoke this method. That is, only
- * an owner can add another owner. The initial owner is configured at
- * ACL construction time.
- *
- * @param caller the principal invoking this method.
- * It must be an owner of the ACL.
- * @param owner the owner that should be added to the list of owners.
- * @return true if successful, false if owner is already an owner.
- * @exception NotOwnerException if the caller principal is not an owner
- * of the ACL.
- */
- public boolean addOwner(Principal caller, Principal owner)
- throws NotOwnerException {
- if (!ownerList.contains(caller))
- throw new NotOwnerException();
-
- if (ownerList.contains(owner)) {
- return false;
- } else {
- ownerList.addElement(owner);
- return true;
- }
- }
-
- /**
- * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
- *
- * The caller principal must be an owner of the ACL in order to invoke this method.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of the ACL.
- * @param owner the owner to be removed from the list of owners.
- * @return true if successful, false if owner is already an owner.
- * @exception NotOwnerException if the caller principal is not an owner
- * of the ACL.
- * @exception LastOwnerException if there is only one owner left, so that
- * deleteOwner would leave the ACL owner-less.
- */
- public boolean deleteOwner(Principal caller, Principal owner)
- throws NotOwnerException,LastOwnerException {
-
- if (!ownerList.contains(caller))
- throw new NotOwnerException();
-
- if (!ownerList.contains(owner)){
- return false;
- } else {
- if (ownerList.size() == 1)
- throw new LastOwnerException();
-
- ownerList.removeElement(owner);
- return true;
- }
- }
-
- /**
- * Returns true if the given principal is an owner of the ACL.
- *
- * @param owner the principal to be checked to determine whether or
- * not it is an owner.
- * @return true if the given principal is an owner of the ACL.
- */
- public boolean isOwner(Principal owner){
- return ownerList.contains(owner);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseError.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseError.java
deleted file mode 100644
index 230d4d3d238..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseError.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* Generated By:JavaCC: Do not edit this line. ParseError.java Version 0.7pre1 */
-package com.sun.jmx.snmp.IPAcl;
-
-class ParseError extends Exception {
- private static final long serialVersionUID = 4907307342076722310L;
-
- public ParseError() {
- }
- public ParseError(String message) {
- super(message);
- }
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java
deleted file mode 100644
index 78be1da103b..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/ParseException.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */
-package com.sun.jmx.snmp.IPAcl;
-
-/**
- * This exception is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by
- * calling the method generateParseException in the generated
- * parser.
- *
- * You can modify this class to customize your error reporting
- * mechanisms so long as you retain the public fields.
- */
-class ParseException extends Exception {
- private static final long serialVersionUID = -3695190720704845876L;
-
- /**
- * This constructor is used by the method "generateParseException"
- * in the generated parser. Calling this constructor generates
- * a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set. The boolean
- * flag "specialConstructor" is also set to true to indicate that
- * this constructor was used to create this object.
- * This constructor calls its super class with the empty string
- * to force the "toString" method of parent class "Throwable" to
- * print the error message in the form:
- * ParseException:
- */
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal,
- String[] tokenImageVal
- )
- {
- super("");
- specialConstructor = true;
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- tokenImage = tokenImageVal;
- }
-
- /**
- * The following constructors are for use by you for whatever
- * purpose you can think of. Constructing the exception in this
- * manner makes the exception behave in the normal way - i.e., as
- * documented in the class "Throwable". The fields "errorToken",
- * "expectedTokenSequences", and "tokenImage" do not contain
- * relevant information. The JavaCC generated code does not use
- * these constructors.
- */
-
- public ParseException() {
- super();
- specialConstructor = false;
- }
-
- public ParseException(String message) {
- super(message);
- specialConstructor = false;
- }
-
- /**
- * This variable determines which constructor was used to create
- * this object and thereby affects the semantics of the
- * "getMessage" method (see below).
- */
- protected boolean specialConstructor;
-
- /**
- * This is the last token that has been consumed successfully. If
- * this object has been created due to a parse error, the token
- * followng this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers. Each array
- * of integers represents a sequence of tokens (by their ordinal
- * values) that is expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * This is a reference to the "tokenImage" array of the generated
- * parser within which the parse error occurred. This array is
- * defined in the generated ...Constants interface.
- */
- public String[] tokenImage;
-
- /**
- * This method has the standard behavior when this object has been
- * created using the standard constructors. Otherwise, it uses
- * "currentToken" and "expectedTokenSequences" to generate a parse
- * error message and returns it. If this object has been created
- * due to a parse error, and you do not catch it (it gets thrown
- * from the parser), then this method is called during the printing
- * of the final stack trace, and hence the correct error message
- * gets displayed.
- */
- public String getMessage() {
- if (!specialConstructor) {
- return super.getMessage();
- }
- String expected = "";
- int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.length; i++) {
- if (maxSize < expectedTokenSequences[i].length) {
- maxSize = expectedTokenSequences[i].length;
- }
- for (int j = 0; j < expectedTokenSequences[i].length; j++) {
- expected += tokenImage[expectedTokenSequences[i][j]] + " ";
- }
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
- expected += "...";
- }
- expected += eol + " ";
- }
- String retval = "Encountered \"";
- Token tok = currentToken.next;
- for (int i = 0; i < maxSize; i++) {
- if (i != 0) retval += " ";
- if (tok.kind == 0) {
- retval += tokenImage[0];
- break;
- }
- retval += add_escapes(tok.image);
- tok = tok.next;
- }
- retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
- if (expectedTokenSequences.length == 1) {
- retval += "Was expecting:" + eol + " ";
- } else {
- retval += "Was expecting one of:" + eol + " ";
- }
- retval += expected;
- return retval;
- }
-
- /**
- * The end of line string for this machine.
- */
- protected String eol = System.getProperty("line.separator", "\n");
-
- /**
- * Used to convert raw characters to their escaped version
- * when these raw version cannot be used as part of an ASCII
- * string literal.
- */
- protected String add_escapes(String str) {
- StringBuilder retval = new StringBuilder();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
- }
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java
deleted file mode 100644
index bf1041b3bd1..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.java
+++ /dev/null
@@ -1,1285 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* Generated By:JJTree&JavaCC: Do not edit this line. Parser.java */
-package com.sun.jmx.snmp.IPAcl;
-
-import java.io.*;
-
-@SuppressWarnings("unchecked") // generated code, not worth fixing
-class Parser/*@bgen(jjtree)*/implements ParserTreeConstants, ParserConstants {/*@bgen(jjtree)*/
- protected JJTParserState jjtree = new JJTParserState();
-
-// A file can contain several acl definitions
-//
- final public JDMSecurityDefs SecurityDefs() throws ParseException {
- /*@bgen(jjtree) SecurityDefs */
- JDMSecurityDefs jjtn000 = new JDMSecurityDefs(JJTSECURITYDEFS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case ACL:
- AclBlock();
- break;
- default:
- jj_la1[0] = jj_gen;
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case TRAP:
- TrapBlock();
- break;
- default:
- jj_la1[1] = jj_gen;
- ;
- }
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case INFORM:
- InformBlock();
- break;
- default:
- jj_la1[2] = jj_gen;
- ;
- }
- jj_consume_token(0);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- {if (true) return jjtn000;}
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- throw new Error("Missing return statement in function");
- }
-
- final public void AclBlock() throws ParseException {
- /*@bgen(jjtree) AclBlock */
- JDMAclBlock jjtn000 = new JDMAclBlock(JJTACLBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(ACL);
- jj_consume_token(ASSIGN);
- jj_consume_token(LBRACE);
- label_1:
- while (true) {
- AclItem();
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- ;
- break;
- default:
- jj_la1[3] = jj_gen;
- break label_1;
- }
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void AclItem() throws ParseException {
- /*@bgen(jjtree) AclItem */
- JDMAclItem jjtn000 = new JDMAclItem(JJTACLITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(LBRACE);
- jjtn000.com = Communities();
- jjtn000.access = Access();
- Managers();
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public JDMCommunities Communities() throws ParseException {
- /*@bgen(jjtree) Communities */
- JDMCommunities jjtn000 = new JDMCommunities(JJTCOMMUNITIES);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(COMMUNITIES);
- jj_consume_token(ASSIGN);
- Community();
- label_2:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[4] = jj_gen;
- break label_2;
- }
- jj_consume_token(COMMA);
- Community();
- }
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- {if (true) return jjtn000;}
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- throw new Error("Missing return statement in function");
- }
-
- final public void Community() throws ParseException {
- /*@bgen(jjtree) Community */
- JDMCommunity jjtn000 = new JDMCommunity(JJTCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(IDENTIFIER);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.communityString= t.image;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public JDMAccess Access() throws ParseException {
- /*@bgen(jjtree) Access */
- JDMAccess jjtn000 = new JDMAccess(JJTACCESS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(ACCESS);
- jj_consume_token(ASSIGN);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case RO:
- jj_consume_token(RO);
- jjtn000.access= RO;
- break;
- case RW:
- jj_consume_token(RW);
- jjtn000.access= RW;
- break;
- default:
- jj_la1[5] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- {if (true) return jjtn000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- throw new Error("Missing return statement in function");
- }
-
- final public void Managers() throws ParseException {
- /*@bgen(jjtree) Managers */
- JDMManagers jjtn000 = new JDMManagers(JJTMANAGERS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(MANAGERS);
- jj_consume_token(ASSIGN);
- Host();
- label_3:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[6] = jj_gen;
- break label_3;
- }
- jj_consume_token(COMMA);
- Host();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void Host() throws ParseException {
- /*@bgen(jjtree) Host */
- JDMHost jjtn000 = new JDMHost(JJTHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- HostName();
- break;
- default:
- jj_la1[7] = jj_gen;
- if (jj_2_1(2147483647)) {
- NetMask();
- } else if (jj_2_2(2147483647)) {
- NetMaskV6();
- } else if (jj_2_3(2147483647)) {
- IpAddress();
- } else {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case V6_ADDRESS:
- IpV6Address();
- break;
- case INTEGER_LITERAL:
- IpMask();
- break;
- default:
- jj_la1[8] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- }
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void HostName() throws ParseException {
- /*@bgen(jjtree) HostName */
- JDMHostName jjtn000 = new JDMHostName(JJTHOSTNAME);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(IDENTIFIER);
- jjtn000.name.append(t.image);
- label_4:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DOT:
- ;
- break;
- default:
- jj_la1[9] = jj_gen;
- break label_4;
- }
- jj_consume_token(DOT);
- t = jj_consume_token(IDENTIFIER);
- jjtn000.name.append( "." + t.image);
- }
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void IpAddress() throws ParseException {
- /*@bgen(jjtree) IpAddress */
-JDMIpAddress jjtn000 = new JDMIpAddress(JJTIPADDRESS);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append(t.image);
- label_5:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DOT:
- ;
- break;
- default:
- jj_la1[10] = jj_gen;
- break label_5;
- }
- jj_consume_token(DOT);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append( "." + t.image);
- }
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void IpV6Address() throws ParseException {
- /*@bgen(jjtree) IpV6Address */
-JDMIpV6Address jjtn000 = new JDMIpV6Address(JJTIPV6ADDRESS);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(V6_ADDRESS);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.address.append(t.image);
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void IpMask() throws ParseException {
- /*@bgen(jjtree) IpMask */
-JDMIpMask jjtn000 = new JDMIpMask(JJTIPMASK);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append(t.image);
- label_6:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case MARK:
- ;
- break;
- default:
- jj_la1[11] = jj_gen;
- break label_6;
- }
- jj_consume_token(MARK);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append( "." + t.image);
- }
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void NetMask() throws ParseException {
- /*@bgen(jjtree) NetMask */
-JDMNetMask jjtn000 = new JDMNetMask(JJTNETMASK);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append(t.image);
- label_7:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case DOT:
- ;
- break;
- default:
- jj_la1[12] = jj_gen;
- break label_7;
- }
- jj_consume_token(DOT);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.address.append( "." + t.image);
- }
- jj_consume_token(MASK);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.mask = t.image;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void NetMaskV6() throws ParseException {
- /*@bgen(jjtree) NetMaskV6 */
-JDMNetMaskV6 jjtn000 = new JDMNetMaskV6(JJTNETMASKV6);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(V6_ADDRESS);
- jjtn000.address.append(t.image);
- jj_consume_token(MASK);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.mask = t.image;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void TrapBlock() throws ParseException {
- /*@bgen(jjtree) TrapBlock */
- JDMTrapBlock jjtn000 = new JDMTrapBlock(JJTTRAPBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(TRAP);
- jj_consume_token(ASSIGN);
- jj_consume_token(LBRACE);
- label_8:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- ;
- break;
- default:
- jj_la1[13] = jj_gen;
- break label_8;
- }
- TrapItem();
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void TrapItem() throws ParseException {
- /*@bgen(jjtree) TrapItem */
- JDMTrapItem jjtn000 = new JDMTrapItem(JJTTRAPITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(LBRACE);
- jjtn000.comm = TrapCommunity();
- TrapInterestedHost();
- label_9:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- ;
- break;
- default:
- jj_la1[14] = jj_gen;
- break label_9;
- }
- Enterprise();
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public JDMTrapCommunity TrapCommunity() throws ParseException {
- /*@bgen(jjtree) TrapCommunity */
- JDMTrapCommunity jjtn000 = new JDMTrapCommunity(JJTTRAPCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- jj_consume_token(TRAPCOMMUNITY);
- jj_consume_token(ASSIGN);
- t = jj_consume_token(IDENTIFIER);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.community= t.image; {if (true) return jjtn000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- throw new Error("Missing return statement in function");
- }
-
- final public void TrapInterestedHost() throws ParseException {
- /*@bgen(jjtree) TrapInterestedHost */
- JDMTrapInterestedHost jjtn000 = new JDMTrapInterestedHost(JJTTRAPINTERESTEDHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(HOSTS);
- jj_consume_token(ASSIGN);
- HostTrap();
- label_10:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[15] = jj_gen;
- break label_10;
- }
- jj_consume_token(COMMA);
- HostTrap();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void HostTrap() throws ParseException {
- /*@bgen(jjtree) HostTrap */
- JDMHostTrap jjtn000 = new JDMHostTrap(JJTHOSTTRAP);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- HostName();
- break;
- case INTEGER_LITERAL:
- IpAddress();
- break;
- case V6_ADDRESS:
- IpV6Address();
- break;
- default:
- jj_la1[16] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void Enterprise() throws ParseException {
- /*@bgen(jjtree) Enterprise */
- JDMEnterprise jjtn000 = new JDMEnterprise(JJTENTERPRISE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- jj_consume_token(LBRACE);
- jj_consume_token(ENTERPRISE);
- jj_consume_token(ASSIGN);
- t = jj_consume_token(CSTRING);
- jjtn000.enterprise= t.image;
- jj_consume_token(TRAPNUM);
- jj_consume_token(ASSIGN);
- TrapNum();
- label_11:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[17] = jj_gen;
- break label_11;
- }
- jj_consume_token(COMMA);
- TrapNum();
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void TrapNum() throws ParseException {
- /*@bgen(jjtree) TrapNum */
- JDMTrapNum jjtn000 = new JDMTrapNum(JJTTRAPNUM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.low= Integer.parseInt(t.image);
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case RANGE:
- jj_consume_token(RANGE);
- t = jj_consume_token(INTEGER_LITERAL);
- jjtn000.high= Integer.parseInt(t.image);
- break;
- default:
- jj_la1[18] = jj_gen;
- ;
- }
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void InformBlock() throws ParseException {
- /*@bgen(jjtree) InformBlock */
- JDMInformBlock jjtn000 = new JDMInformBlock(JJTINFORMBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(INFORM);
- jj_consume_token(ASSIGN);
- jj_consume_token(LBRACE);
- label_12:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case LBRACE:
- ;
- break;
- default:
- jj_la1[19] = jj_gen;
- break label_12;
- }
- InformItem();
- }
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void InformItem() throws ParseException {
- /*@bgen(jjtree) InformItem */
- JDMInformItem jjtn000 = new JDMInformItem(JJTINFORMITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(LBRACE);
- jjtn000.comm = InformCommunity();
- InformInterestedHost();
- jj_consume_token(RBRACE);
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public JDMInformCommunity InformCommunity() throws ParseException {
- /*@bgen(jjtree) InformCommunity */
- JDMInformCommunity jjtn000 = new JDMInformCommunity(JJTINFORMCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- jj_consume_token(INFORMCOMMUNITY);
- jj_consume_token(ASSIGN);
- t = jj_consume_token(IDENTIFIER);
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- jjtn000.community= t.image; {if (true) return jjtn000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- throw new Error("Missing return statement in function");
- }
-
- final public void InformInterestedHost() throws ParseException {
- /*@bgen(jjtree) InformInterestedHost */
- JDMInformInterestedHost jjtn000 = new JDMInformInterestedHost(JJTINFORMINTERESTEDHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
- try {
- jj_consume_token(HOSTS);
- jj_consume_token(ASSIGN);
- HostInform();
- label_13:
- while (true) {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case COMMA:
- ;
- break;
- default:
- jj_la1[20] = jj_gen;
- break label_13;
- }
- jj_consume_token(COMMA);
- HostInform();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final public void HostInform() throws ParseException {
- /*@bgen(jjtree) HostInform */
- JDMHostInform jjtn000 = new JDMHostInform(JJTHOSTINFORM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);Token t;
- try {
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case IDENTIFIER:
- HostName();
- break;
- case INTEGER_LITERAL:
- IpAddress();
- break;
- case V6_ADDRESS:
- IpV6Address();
- break;
- default:
- jj_la1[21] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- {if (true) throw (RuntimeException)jjte000;}
- }
- if (jjte000 instanceof ParseException) {
- {if (true) throw (ParseException)jjte000;}
- }
- {if (true) throw (Error)jjte000;}
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
- }
-
- final private boolean jj_2_1(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- boolean retval = !jj_3_1();
- jj_save(0, xla);
- return retval;
- }
-
- final private boolean jj_2_2(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- boolean retval = !jj_3_2();
- jj_save(1, xla);
- return retval;
- }
-
- final private boolean jj_2_3(int xla) {
- jj_la = xla; jj_lastpos = jj_scanpos = token;
- boolean retval = !jj_3_3();
- jj_save(2, xla);
- return retval;
- }
-
- final private boolean jj_3_3() {
- if (jj_scan_token(INTEGER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(DOT)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3_2() {
- if (jj_scan_token(V6_ADDRESS)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(MASK)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(INTEGER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3_1() {
- if (jj_scan_token(INTEGER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- Token xsp;
- while (true) {
- xsp = jj_scanpos;
- if (jj_3R_14()) { jj_scanpos = xsp; break; }
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- }
- if (jj_scan_token(MASK)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(INTEGER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- final private boolean jj_3R_14() {
- if (jj_scan_token(DOT)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- if (jj_scan_token(INTEGER_LITERAL)) return true;
- if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
- return false;
- }
-
- public ParserTokenManager token_source;
- ASCII_CharStream jj_input_stream;
- public Token token, jj_nt;
- private int jj_ntk;
- private Token jj_scanpos, jj_lastpos;
- private int jj_la;
- public boolean lookingAhead = false;
- private boolean jj_semLA;
- private int jj_gen;
- final private int[] jj_la1 = new int[22];
- final private int[] jj_la1_0 = {0x100,0x80000,0x100000,0x2000,0x0,0x60000,0x0,0x80000000,0x11000000,0x0,0x0,0x0,0x0,0x2000,0x2000,0x0,0x91000000,0x0,0x8000,0x2000,0x0,0x91000000,};
- final private int[] jj_la1_1 = {0x0,0x0,0x0,0x0,0x10,0x0,0x10,0x0,0x0,0x20,0x20,0x40,0x20,0x0,0x0,0x10,0x0,0x10,0x0,0x0,0x10,0x0,};
- final private JJCalls[] jj_2_rtns = new JJCalls[3];
- private boolean jj_rescan = false;
- private int jj_gc = 0;
-
- public Parser(java.io.InputStream stream) {
- jj_input_stream = new ASCII_CharStream(stream, 1, 1);
- token_source = new ParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public void ReInit(java.io.InputStream stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jjtree.reset();
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public Parser(java.io.Reader stream) {
- jj_input_stream = new ASCII_CharStream(stream, 1, 1);
- token_source = new ParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public void ReInit(java.io.Reader stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jjtree.reset();
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public Parser(ParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- public void ReInit(ParserTokenManager tm) {
- token_source = tm;
- token = new Token();
- jj_ntk = -1;
- jjtree.reset();
- jj_gen = 0;
- for (int i = 0; i < 22; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- final private Token jj_consume_token(int kind) throws ParseException {
- Token oldToken;
- if ((oldToken = token).next != null) token = token.next;
- else token = token.next = token_source.getNextToken();
- jj_ntk = -1;
- if (token.kind == kind) {
- jj_gen++;
- if (++jj_gc > 100) {
- jj_gc = 0;
- for (int i = 0; i < jj_2_rtns.length; i++) {
- JJCalls c = jj_2_rtns[i];
- while (c != null) {
- if (c.gen < jj_gen) c.first = null;
- c = c.next;
- }
- }
- }
- return token;
- }
- token = oldToken;
- jj_kind = kind;
- throw generateParseException();
- }
-
- final private boolean jj_scan_token(int kind) {
- if (jj_scanpos == jj_lastpos) {
- jj_la--;
- if (jj_scanpos.next == null) {
- jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
- } else {
- jj_lastpos = jj_scanpos = jj_scanpos.next;
- }
- } else {
- jj_scanpos = jj_scanpos.next;
- }
- if (jj_rescan) {
- int i = 0; Token tok = token;
- while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
- if (tok != null) jj_add_error_token(kind, i);
- }
- return (jj_scanpos.kind != kind);
- }
-
- final public Token getNextToken() {
- if (token.next != null) token = token.next;
- else token = token.next = token_source.getNextToken();
- jj_ntk = -1;
- jj_gen++;
- return token;
- }
-
- final public Token getToken(int index) {
- Token t = lookingAhead ? jj_scanpos : token;
- for (int i = 0; i < index; i++) {
- if (t.next != null) t = t.next;
- else t = t.next = token_source.getNextToken();
- }
- return t;
- }
-
- final private int jj_ntk() {
- if ((jj_nt=token.next) == null)
- return (jj_ntk = (token.next=token_source.getNextToken()).kind);
- else
- return (jj_ntk = jj_nt.kind);
- }
-
- private java.util.Vector jj_expentries = new java.util.Vector<>();
- private int[] jj_expentry;
- private int jj_kind = -1;
- private int[] jj_lasttokens = new int[100];
- private int jj_endpos;
-
- private void jj_add_error_token(int kind, int pos) {
- if (pos >= 100) return;
- if (pos == jj_endpos + 1) {
- jj_lasttokens[jj_endpos++] = kind;
- } else if (jj_endpos != 0) {
- jj_expentry = new int[jj_endpos];
- for (int i = 0; i < jj_endpos; i++) {
- jj_expentry[i] = jj_lasttokens[i];
- }
- boolean exists = false;
- for (java.util.Enumeration enumv = jj_expentries.elements(); enumv.hasMoreElements();) {
- int[] oldentry = enumv.nextElement();
- if (oldentry.length == jj_expentry.length) {
- exists = true;
- for (int i = 0; i < jj_expentry.length; i++) {
- if (oldentry[i] != jj_expentry[i]) {
- exists = false;
- break;
- }
- }
- if (exists) break;
- }
- }
- if (!exists) jj_expentries.addElement(jj_expentry);
- if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
- }
- }
-
- final public ParseException generateParseException() {
- jj_expentries.removeAllElements();
- boolean[] la1tokens = new boolean[40];
- for (int i = 0; i < 40; i++) {
- la1tokens[i] = false;
- }
- if (jj_kind >= 0) {
- la1tokens[jj_kind] = true;
- jj_kind = -1;
- }
- for (int i = 0; i < 22; i++) {
- if (jj_la1[i] == jj_gen) {
- for (int j = 0; j < 32; j++) {
- if ((jj_la1_0[i] & (1< jj_gen) {
- jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
- switch (i) {
- case 0: jj_3_1(); break;
- case 1: jj_3_2(); break;
- case 2: jj_3_3(); break;
- }
- }
- p = p.next;
- } while (p != null);
- }
- jj_rescan = false;
- }
-
- final private void jj_save(int index, int xla) {
- JJCalls p = jj_2_rtns[index];
- while (p.gen > jj_gen) {
- if (p.next == null) { p = p.next = new JJCalls(); break; }
- p = p.next;
- }
- p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
- }
-
- static final class JJCalls {
- int gen;
- Token first;
- int arg;
- JJCalls next;
- }
-
-}
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj
deleted file mode 100644
index 002e5481538..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jj
+++ /dev/null
@@ -1,948 +0,0 @@
-/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. Parser.jj */
-/*@egen*//*
- * @(#)file Parser.jjt
- * @(#)author Sun Microsystems, Inc.
- *
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-options {
- STATIC=false;
-}
-
-
-PARSER_BEGIN(Parser)
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.io.*;
-
-public class Parser/*@bgen(jjtree)*/implements ParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
- protected JJTParserState jjtree = new JJTParserState();
-
-/*@egen*/
-}
-
-PARSER_END(Parser)
-
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"--" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"#" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-
-}
-
-
-
-/* RESERVED WORDS AND LITERALS */
-
-TOKEN :
-{
-
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-}
-
-
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* V6 LITERALS */
-{
- < V6_ADDRESS: ((( ( ( ":")+ (":")?) | "::" ) ( ":")* ( | ( "." "." "." ))) | ("::")) | ( ( ":")+ ":") >
-|
- <#H: (["0"-"9","a"-"f","A"-"F"])+ >
-|
- <#D: (["0"-"9"])+ >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER: ( (|)+ (||)* (|)+ ) | (|)+ >
-|
- < #LETTER: ["a"-"z","A"-"Z"] >
-|
- < #SEPARATOR: ["-", "_"] >
-|
- < #DIGIT: ["0"-"9"] >
-|
-
-}
-
-
-
-TOKEN: /* SEPARATOR */
-{
- < COMMA: "," >
-| < DOT: "." >
-| < MARK: "!" >
-| < MASK: "/">
-}
-
-// A file can contain several acl definitions
-//
-JDMSecurityDefs SecurityDefs() : {/*@bgen(jjtree) SecurityDefs */
- JDMSecurityDefs jjtn000 = new JDMSecurityDefs(JJTSECURITYDEFS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/}
-{/*@bgen(jjtree) SecurityDefs */
- try {
-/*@egen*/
- [AclBlock()]
- [TrapBlock()]
- [InformBlock()]
- /*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/
- { return jjtn000;}/*@bgen(jjtree)*/
- } catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
-/*@egen*/
-}
-
-void AclBlock(): {/*@bgen(jjtree) AclBlock */
- JDMAclBlock jjtn000 = new JDMAclBlock(JJTACLBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/}
-{/*@bgen(jjtree) AclBlock */
-try {
-/*@egen*/
-"acl" "=" "{" (AclItem())+ "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void AclItem(): {/*@bgen(jjtree) AclItem */
- JDMAclItem jjtn000 = new JDMAclItem(JJTACLITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/}
-{/*@bgen(jjtree) AclItem */
-try {
-/*@egen*/
-"{" jjtn000.com= Communities() jjtn000.access= Access() Managers() "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-JDMCommunities Communities(): {/*@bgen(jjtree) Communities */
- JDMCommunities jjtn000 = new JDMCommunities(JJTCOMMUNITIES);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/}
-{/*@bgen(jjtree) Communities */
-try {
-/*@egen*/
-"communities" "=" Community() ( "," Community())*/*@bgen(jjtree)*/
-{
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
-}
-/*@egen*/
-
-{return jjtn000;}/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-
-}
-
-void Community():
-{/*@bgen(jjtree) Community */
- JDMCommunity jjtn000 = new JDMCommunity(JJTCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) Community */
-try {
-/*@egen*/
-t=/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/ {jjtn000.communityString= t.image;}/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-JDMAccess Access(): {/*@bgen(jjtree) Access */
- JDMAccess jjtn000 = new JDMAccess(JJTACCESS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/}
-{/*@bgen(jjtree) Access */
-try {
-/*@egen*/
-"access" "=" ( {jjtn000.access= RO;}
- |
- {jjtn000.access= RW;}
- )/*@bgen(jjtree)*/
-{
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
-}
-/*@egen*/
-{return jjtn000;}/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-
-void Managers() : {/*@bgen(jjtree) Managers */
- JDMManagers jjtn000 = new JDMManagers(JJTMANAGERS);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) Managers */
-try {
-/*@egen*/
-"managers" "=" Host() ( "," Host())*/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void Host() :
-{/*@bgen(jjtree) Host */
- JDMHost jjtn000 = new JDMHost(JJTHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) Host */
-try {
-/*@egen*/
-HostName()
-|
-LOOKAHEAD( ( "." )* "/" )
-NetMask()
-|
-LOOKAHEAD( "/" )
-NetMaskV6()
-|
-LOOKAHEAD( ".")
-IpAddress()
-|
-IpV6Address()
-|
-IpMask()/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void HostName():
-{/*@bgen(jjtree) HostName */
- JDMHostName jjtn000 = new JDMHostName(JJTHOSTNAME);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) HostName */
- try {
-/*@egen*/
- t= { jjtn000.name.append(t.image); }
-(
-"." t=
- {jjtn000.name.append( "." + t.image); }
-)*/*@bgen(jjtree)*/
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
-/*@egen*/
-
-}
-
-void IpAddress():
-{/*@bgen(jjtree) IpAddress */
-JDMIpAddress jjtn000 = new JDMIpAddress(JJTIPADDRESS);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);
-/*@egen*/
-Token t;
-}
-{/*@bgen(jjtree) IpAddress */
-try {
-/*@egen*/
-
-t=
- {jjtn000.address.append(t.image); }
-(
-"." t=
- {jjtn000.address.append( "." + t.image); }
-)*/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-
-}
-
-void IpV6Address():
-{/*@bgen(jjtree) IpV6Address */
-JDMIpV6Address jjtn000 = new JDMIpV6Address(JJTIPV6ADDRESS);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);
-/*@egen*/
-Token t;
-}
-{/*@bgen(jjtree) IpV6Address */
-try {
-/*@egen*/
-
-t= /*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/
- {jjtn000.address.append(t.image); }/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void IpMask():
-{/*@bgen(jjtree) IpMask */
-JDMIpMask jjtn000 = new JDMIpMask(JJTIPMASK);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);
-/*@egen*/
-Token t;
-}
-{/*@bgen(jjtree) IpMask */
-try {
-/*@egen*/
-
-t=
- {jjtn000.address.append(t.image); }
-(
-"!" t=
- {jjtn000.address.append( "." + t.image); }
-)*/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void NetMask():
-{/*@bgen(jjtree) NetMask */
-JDMNetMask jjtn000 = new JDMNetMask(JJTNETMASK);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);
-/*@egen*/
-Token t;
-}
-{/*@bgen(jjtree) NetMask */
-try {
-/*@egen*/
-
-t=
- {jjtn000.address.append(t.image); }
-(
-"." t=
- {jjtn000.address.append( "." + t.image); }
-)* "/" t= /*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/ {jjtn000.mask = t.image; }/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void NetMaskV6():
-{/*@bgen(jjtree) NetMaskV6 */
-JDMNetMaskV6 jjtn000 = new JDMNetMaskV6(JJTNETMASKV6);
-boolean jjtc000 = true;
-jjtree.openNodeScope(jjtn000);
-/*@egen*/
-Token t;
-}
-{/*@bgen(jjtree) NetMaskV6 */
-try {
-/*@egen*/
-
-t=
- {jjtn000.address.append(t.image); }
-
-"/" t= /*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/ {jjtn000.mask = t.image; }/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void TrapBlock(): {/*@bgen(jjtree) TrapBlock */
- JDMTrapBlock jjtn000 = new JDMTrapBlock(JJTTRAPBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) TrapBlock */
-try {
-/*@egen*/
-"trap" "=" "{" (TrapItem())* "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void TrapItem(): {/*@bgen(jjtree) TrapItem */
- JDMTrapItem jjtn000 = new JDMTrapItem(JJTTRAPITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) TrapItem */
-try {
-/*@egen*/
-"{" jjtn000.comm= TrapCommunity() TrapInterestedHost() (Enterprise())* "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-JDMTrapCommunity TrapCommunity():
-{/*@bgen(jjtree) TrapCommunity */
- JDMTrapCommunity jjtn000 = new JDMTrapCommunity(JJTTRAPCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) TrapCommunity */
-try {
-/*@egen*/
-"trap-community" "=" t=/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/ { jjtn000.community= t.image; return jjtn000; }/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void TrapInterestedHost(): {/*@bgen(jjtree) TrapInterestedHost */
- JDMTrapInterestedHost jjtn000 = new JDMTrapInterestedHost(JJTTRAPINTERESTEDHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) TrapInterestedHost */
-try {
-/*@egen*/
-"hosts" "=" HostTrap() ("," HostTrap())*/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void HostTrap() :
-{/*@bgen(jjtree) HostTrap */
- JDMHostTrap jjtn000 = new JDMHostTrap(JJTHOSTTRAP);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) HostTrap */
-try {
-/*@egen*/
-HostName()
-|
-IpAddress()
-|
-IpV6Address()/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void Enterprise():
-{/*@bgen(jjtree) Enterprise */
- JDMEnterprise jjtn000 = new JDMEnterprise(JJTENTERPRISE);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) Enterprise */
-try {
-/*@egen*/
-"{"
-"enterprise" "=" t= {jjtn000.enterprise= t.image;}
-
-"trap-num" "=" TrapNum() ("," TrapNum())*
-
-"}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void TrapNum():
-{/*@bgen(jjtree) TrapNum */
- JDMTrapNum jjtn000 = new JDMTrapNum(JJTTRAPNUM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) TrapNum */
- try {
-/*@egen*/
- t= {jjtn000.low= Integer.parseInt(t.image);}
-[
- "-" t= {jjtn000.high= Integer.parseInt(t.image);}
-]/*@bgen(jjtree)*/
- } finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
- }
-/*@egen*/
-}
-
-
-void InformBlock(): {/*@bgen(jjtree) InformBlock */
- JDMInformBlock jjtn000 = new JDMInformBlock(JJTINFORMBLOCK);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) InformBlock */
-try {
-/*@egen*/
-"inform" "=" "{" (InformItem())* "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void InformItem(): {/*@bgen(jjtree) InformItem */
- JDMInformItem jjtn000 = new JDMInformItem(JJTINFORMITEM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) InformItem */
-try {
-/*@egen*/
-"{" jjtn000.comm= InformCommunity() InformInterestedHost() "}"/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-JDMInformCommunity InformCommunity():
-{/*@bgen(jjtree) InformCommunity */
- JDMInformCommunity jjtn000 = new JDMInformCommunity(JJTINFORMCOMMUNITY);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) InformCommunity */
-try {
-/*@egen*/
-"inform-community" "=" t=/*@bgen(jjtree)*/
- {
- jjtree.closeNodeScope(jjtn000, true);
- jjtc000 = false;
- }
-/*@egen*/ { jjtn000.community= t.image; return jjtn000; }/*@bgen(jjtree)*/
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void InformInterestedHost(): {/*@bgen(jjtree) InformInterestedHost */
- JDMInformInterestedHost jjtn000 = new JDMInformInterestedHost(JJTINFORMINTERESTEDHOST);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/ }
-{/*@bgen(jjtree) InformInterestedHost */
-try {
-/*@egen*/
-"hosts" "=" HostInform() ("," HostInform())*/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
-void HostInform() :
-{/*@bgen(jjtree) HostInform */
- JDMHostInform jjtn000 = new JDMHostInform(JJTHOSTINFORM);
- boolean jjtc000 = true;
- jjtree.openNodeScope(jjtn000);
-/*@egen*/
- Token t;
-}
-{/*@bgen(jjtree) HostInform */
-try {
-/*@egen*/
-HostName()
-|
-IpAddress()
-|
-IpV6Address()/*@bgen(jjtree)*/
-} catch (Throwable jjte000) {
- if (jjtc000) {
- jjtree.clearNodeScope(jjtn000);
- jjtc000 = false;
- } else {
- jjtree.popNode();
- }
- if (jjte000 instanceof RuntimeException) {
- throw (RuntimeException)jjte000;
- }
- if (jjte000 instanceof ParseException) {
- throw (ParseException)jjte000;
- }
- throw (Error)jjte000;
-} finally {
- if (jjtc000) {
- jjtree.closeNodeScope(jjtn000, true);
- }
-}
-/*@egen*/
-}
-
diff --git a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt b/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt
deleted file mode 100644
index 5043f9bcc97..00000000000
--- a/jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp/IPAcl/Parser.jjt
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * @(#)file Parser.jjt
- * @(#)author Sun Microsystems, Inc.
- *
- * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-options {
- MULTI=true;
- STATIC=false;
- NODE_PREFIX= "JDM";
- NODE_PACKAGE="com.sun.jmx.snmp.IPAcl";
-}
-
-
-PARSER_BEGIN(Parser)
-
-package com.sun.jmx.snmp.IPAcl;
-
-import java.io.*;
-
-public class Parser {
-}
-
-PARSER_END(Parser)
-
-
-SKIP :
-{
- " "
-| "\t"
-| "\n"
-| "\r"
-| <"--" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-| <"#" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
-
-}
-
-
-
-/* RESERVED WORDS AND LITERALS */
-
-TOKEN :
-{
-
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-}
-
-
-
-TOKEN : /* LITERALS */
-{
- < INTEGER_LITERAL:
- (["l","L"])?
- | (["l","L"])?
- | (["l","L"])?
- >
-|
- < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
-|
- < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
-|
- < #OCTAL_LITERAL: "0" (["0"-"7"])* >
-}
-
-TOKEN : /* V6 LITERALS */
-{
- < V6_ADDRESS: ((( ( ( ":")+ (":")?) | "::" ) ( ":")* ( | ( "." "." "." ))) | ("::")) | ( ( ":")+ ":") >
-|
- <#H: (["0"-"9","a"-"f","A"-"F"])+ >
-|
- <#D: (["0"-"9"])+ >
-}
-
-TOKEN : /* IDENTIFIERS */
-{
- < IDENTIFIER: ( (|)+ (||)* (|)+ ) | (|)+ >
-|
- < #LETTER: ["a"-"z","A"-"Z"] >
-|
- < #SEPARATOR: ["-", "_"] >
-|
- < #DIGIT: ["0"-"9"] >
-|
-
-}
-
-
-
-TOKEN: /* SEPARATOR */
-{
- < COMMA: "," >
-| < DOT: "." >
-| < MARK: "!" >
-| < MASK: "/">
-}
-
-// A file can contain several acl definitions
-//
-JDMSecurityDefs SecurityDefs() : {}
-{
- [AclBlock()]
- [TrapBlock()]
- [InformBlock()]
-
- { return jjtThis;}
-}
-
-void AclBlock(): {}
-{
-"acl" "=" "{" (AclItem())+ "}"
-}
-
-void AclItem(): {}
-{
-"{" jjtThis.com= Communities() jjtThis.access= Access() Managers() "}"
-}
-
-JDMCommunities Communities(): {}
-{
-"communities" "=" Community() ( "," Community())*
-
-{return jjtThis;}
-
-}
-
-void Community():
-{
- Token t;
-}
-{
-t= {jjtThis.communityString= t.image;}
-}
-
-JDMAccess Access(): {}
-{
-"access" "=" ( {jjtThis.access= RO;}
- |
- {jjtThis.access= RW;}
- )
-{return jjtThis;}
-}
-
-
-void Managers() : { }
-{
-"managers" "=" Host() ( "," Host())*
-}
-
-void Host() :
-{
- Token t;
-}
-{
-HostName()
-|
-LOOKAHEAD( ( "." )* "/" )
-NetMask()
-|
-LOOKAHEAD( "/" )
-NetMaskV6()
-|
-LOOKAHEAD(