View Javadoc

1   /*
2    * Copyright 2017 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.internal.tcnative;
17  
18  /**
19   * This class is necessary to break the following cyclic dependency:
20   * <ol>
21   * <li>JNI_OnLoad</li>
22   * <li>JNI Calls FindClass because RegisterNatives (used to register JNI methods) requires a class</li>
23   * <li>FindClass loads the class, but static members variables of that class attempt to call a JNI method which has not
24   * yet been registered.</li>
25   * <li>{@link java.lang.UnsatisfiedLinkError} is thrown because native method has not yet been registered.</li>
26   * </ol>
27   * <strong>Static members which call JNI methods must not be declared in this class!</strong>
28   */
29  final class NativeStaticallyReferencedJniMethods {
30      private NativeStaticallyReferencedJniMethods() {
31      }
32  
33      /**
34       * Options that may impact security and may be set by default as defined in:
35       * <a href="https://www.openssl.org/docs/man1.0.1/ssl/SSL_CTX_set_options.html">SSL Docs</a>.
36       */
37      static native int sslOpCipherServerPreference();
38      static native int sslOpNoSSLv2();
39      static native int sslOpNoSSLv3();
40      static native int sslOpNoTLSv1();
41      static native int sslOpNoTLSv11();
42      static native int sslOpNoTLSv12();
43      static native int sslOpNoTicket();
44  
45      /**
46       * Options not defined in the OpenSSL docs but may impact security.
47       */
48      static native int sslOpNoCompression();
49  
50      /* Only support OFF and SERVER for now */
51      static native int sslSessCacheOff();
52      static native int sslSessCacheServer();
53  
54      static native int sslStConnect();
55      static native int sslStAccept();
56  
57      static native int sslModeEnablePartialWrite();
58      static native int sslModeAcceptMovingWriteBuffer();
59      static native int sslModeReleaseBuffers();
60  
61      static native int sslSendShutdown();
62      static native int sslReceivedShutdown();
63      static native int sslErrorNone();
64      static native int sslErrorSSL();
65      static native int sslErrorWantRead();
66      static native int sslErrorWantWrite();
67      static native int sslErrorWantX509Lookup();
68      static native int sslErrorSyscall();
69      static native int sslErrorZeroReturn();
70      static native int sslErrorWantConnect();
71      static native int sslErrorWantAccept();
72  
73      static native int sslMaxPlaintextLength();
74      static native int sslMaxRecordLength();
75  
76      static native int x509CheckFlagAlwaysCheckSubject();
77      static native int x509CheckFlagDisableWildCards();
78      static native int x509CheckFlagNoPartialWildCards();
79      static native int x509CheckFlagMultiLabelWildCards();
80  
81      /* x509 certificate verification errors */
82      static native int x509vOK();
83      static native int x509vErrUnspecified();
84      static native int x509vErrUnableToGetIssuerCert();
85      static native int x509vErrUnableToGetCrl();
86      static native int x509vErrUnableToDecryptCertSignature();
87      static native int x509vErrUnableToDecryptCrlSignature();
88      static native int x509vErrUnableToDecodeIssuerPublicKey();
89      static native int x509vErrCertSignatureFailure();
90      static native int x509vErrCrlSignatureFailure();
91      static native int x509vErrCertNotYetValid();
92      static native int x509vErrCertHasExpired();
93      static native int x509vErrCrlNotYetValid();
94      static native int x509vErrCrlHasExpired();
95      static native int x509vErrErrorInCertNotBeforeField();
96      static native int x509vErrErrorInCertNotAfterField();
97      static native int x509vErrErrorInCrlLastUpdateField();
98      static native int x509vErrErrorInCrlNextUpdateField();
99      static native int x509vErrOutOfMem();
100     static native int x509vErrDepthZeroSelfSignedCert();
101     static native int x509vErrSelfSignedCertInChain();
102     static native int x509vErrUnableToGetIssuerCertLocally();
103     static native int x509vErrUnableToVerifyLeafSignature();
104     static native int x509vErrCertChainTooLong();
105     static native int x509vErrCertRevoked();
106     static native int x509vErrInvalidCa();
107     static native int x509vErrPathLengthExceeded();
108     static native int x509vErrInvalidPurpose();
109     static native int x509vErrCertUntrusted();
110     static native int x509vErrCertRejected();
111     static native int x509vErrSubjectIssuerMismatch();
112     static native int x509vErrAkidSkidMismatch();
113     static native int x509vErrAkidIssuerSerialMismatch();
114     static native int x509vErrKeyUsageNoCertSign();
115     static native int x509vErrUnableToGetCrlIssuer();
116     static native int x509vErrUnhandledCriticalExtension();
117     static native int x509vErrKeyUsageNoCrlSign();
118     static native int x509vErrUnhandledCriticalCrlExtension();
119     static native int x509vErrInvalidNonCa();
120     static native int x509vErrProxyPathLengthExceeded();
121     static native int x509vErrKeyUsageNoDigitalSignature();
122     static native int x509vErrProxyCertificatesNotAllowed();
123     static native int x509vErrInvalidExtension();
124     static native int x509vErrInvalidPolicyExtension();
125     static native int x509vErrNoExplicitPolicy();
126     static native int x509vErrDifferntCrlScope();
127     static native int x509vErrUnsupportedExtensionFeature();
128     static native int x509vErrUnnestedResource();
129     static native int x509vErrPermittedViolation();
130     static native int x509vErrExcludedViolation();
131     static native int x509vErrSubtreeMinMax();
132     static native int x509vErrApplicationVerification();
133     static native int x509vErrUnsupportedConstraintType();
134     static native int x509vErrUnsupportedConstraintSyntax();
135     static native int x509vErrUnsupportedNameSyntax();
136     static native int x509vErrCrlPathValidationError();
137     static native int x509vErrPathLoop();
138     static native int x509vErrSuiteBInvalidVersion();
139     static native int x509vErrSuiteBInvalidAlgorithm();
140     static native int x509vErrSuiteBInvalidCurve();
141     static native int x509vErrSuiteBInvalidSignatureAlgorithm();
142     static native int x509vErrSuiteBLosNotAllowed();
143     static native int x509vErrSuiteBCannotSignP384WithP256();
144     static native int x509vErrHostnameMismatch();
145     static native int x509vErrEmailMismatch();
146     static native int x509vErrIpAddressMismatch();
147     static native int x509vErrDaneNoMatch();
148 }