|
| 1 | +/* BEGIN COPYRIGHT BLOCK |
| 2 | + * This library is free software; you can redistribute it and/or |
| 3 | + * modify it under the terms of the GNU Lesser General Public |
| 4 | + * License as published by the Free Software Foundation; either |
| 5 | + * version 2.1 of the License, or (at your option) any later version. |
| 6 | + * |
| 7 | + * This library is distributed in the hope that it will be useful, |
| 8 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 10 | + * Lesser General Public License for more details. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU Lesser General Public |
| 13 | + * License along with this library; if not, write to the Free Software |
| 14 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | + * |
| 16 | + * Copyright (C) 2017 Red Hat, Inc. |
| 17 | + * All rights reserved. |
| 18 | + * END COPYRIGHT BLOCK */ |
| 19 | +package org.dogtagpki.jss.tomcat; |
| 20 | + |
| 21 | +import java.io.IOException; |
| 22 | +import java.nio.file.Files; |
| 23 | +import java.nio.file.Path; |
| 24 | +import java.nio.file.Paths; |
| 25 | + |
| 26 | +import org.apache.coyote.http11.AbstractHttp11JsseProtocol; |
| 27 | +import org.apache.juli.logging.Log; |
| 28 | +import org.apache.juli.logging.LogFactory; |
| 29 | +import org.apache.tomcat.util.net.NioChannel; |
| 30 | +import org.slf4j.Logger; |
| 31 | +import org.slf4j.LoggerFactory; |
| 32 | + |
| 33 | +public class Http11NioProtocol extends AbstractHttp11JsseProtocol<NioChannel> { |
| 34 | + |
| 35 | + public static Logger logger = LoggerFactory.getLogger(Http11NioProtocol.class); |
| 36 | + private static final Log log = LogFactory.getLog(Http11NioProtocol.class); |
| 37 | + |
| 38 | + TomcatJSS tomcatjss = TomcatJSS.getInstance(); |
| 39 | + |
| 40 | + public Http11NioProtocol() { |
| 41 | + super(new JSSNioEndpoint()); |
| 42 | + } |
| 43 | + |
| 44 | + public String getCertdbDir() { |
| 45 | + return tomcatjss.getCertdbDir(); |
| 46 | + } |
| 47 | + |
| 48 | + public void setCertdbDir(String certdbDir) { |
| 49 | + tomcatjss.setCertdbDir(certdbDir); |
| 50 | + } |
| 51 | + |
| 52 | + public String getPasswordClass() { |
| 53 | + return tomcatjss.getPasswordClass(); |
| 54 | + } |
| 55 | + |
| 56 | + public void setPasswordClass(String passwordClass) { |
| 57 | + tomcatjss.setPasswordClass(passwordClass); |
| 58 | + } |
| 59 | + |
| 60 | + public String getPasswordFile() { |
| 61 | + return tomcatjss.getPasswordFile(); |
| 62 | + } |
| 63 | + |
| 64 | + public void setPasswordFile(String passwordFile) { |
| 65 | + tomcatjss.setPasswordFile(passwordFile); |
| 66 | + } |
| 67 | + |
| 68 | + public String getServerCertNickFile() { |
| 69 | + return tomcatjss.getServerCertNickFile(); |
| 70 | + } |
| 71 | + |
| 72 | + public void setServerCertNickFile(String serverCertNickFile) { |
| 73 | + tomcatjss.setServerCertNickFile(serverCertNickFile); |
| 74 | + } |
| 75 | + |
| 76 | + public boolean getEnableOCSP() { |
| 77 | + return tomcatjss.getEnableRevocationCheck(); |
| 78 | + } |
| 79 | + |
| 80 | + public void setEnableOCSP(boolean enableOCSP) { |
| 81 | + tomcatjss.setEnableRevocationCheck(enableOCSP); |
| 82 | + } |
| 83 | + |
| 84 | + public boolean getEnableRevocationCheck() { |
| 85 | + return tomcatjss.getEnableRevocationCheck(); |
| 86 | + } |
| 87 | + |
| 88 | + public void setEnableRevocationCheck(boolean enableRevocationCheck) { |
| 89 | + tomcatjss.setEnableRevocationCheck(enableRevocationCheck); |
| 90 | + } |
| 91 | + |
| 92 | + public String getOcspResponderURL() { |
| 93 | + return tomcatjss.getOcspResponderURL(); |
| 94 | + } |
| 95 | + |
| 96 | + public void setOcspResponderURL(String ocspResponderURL) { |
| 97 | + tomcatjss.setOcspResponderURL(ocspResponderURL); |
| 98 | + } |
| 99 | + |
| 100 | + public String getOcspResponderCertNickname() { |
| 101 | + return tomcatjss.getOcspResponderCertNickname(); |
| 102 | + } |
| 103 | + |
| 104 | + public void setOcspResponderCertNickname(String ocspResponderCertNickname) { |
| 105 | + tomcatjss.setOcspResponderCertNickname(ocspResponderCertNickname); |
| 106 | + } |
| 107 | + |
| 108 | + public int getOcspCacheSize() { |
| 109 | + return tomcatjss.getOcspCacheSize(); |
| 110 | + } |
| 111 | + |
| 112 | + public void setOcspCacheSize(int ocspCacheSize) { |
| 113 | + tomcatjss.setOcspCacheSize(ocspCacheSize); |
| 114 | + } |
| 115 | + |
| 116 | + public int getOcspMinCacheEntryDuration() { |
| 117 | + return tomcatjss.getOcspMinCacheEntryDuration(); |
| 118 | + } |
| 119 | + |
| 120 | + public void setOcspMinCacheEntryDuration(int ocspMinCacheEntryDuration) { |
| 121 | + tomcatjss.setOcspMinCacheEntryDuration(ocspMinCacheEntryDuration); |
| 122 | + } |
| 123 | + |
| 124 | + public int getOcspMaxCacheEntryDuration() { |
| 125 | + return tomcatjss.getOcspMaxCacheEntryDuration(); |
| 126 | + } |
| 127 | + |
| 128 | + public void setOcspMaxCacheEntryDuration(int ocspMaxCacheEntryDuration) { |
| 129 | + tomcatjss.setOcspMaxCacheEntryDuration(ocspMaxCacheEntryDuration); |
| 130 | + } |
| 131 | + |
| 132 | + public int getOcspTimeout() { |
| 133 | + return tomcatjss.getOcspTimeout(); |
| 134 | + } |
| 135 | + |
| 136 | + public void setOcspTimeout(int ocspTimeout) { |
| 137 | + tomcatjss.setOcspTimeout(ocspTimeout); |
| 138 | + } |
| 139 | + |
| 140 | +/* public void setKeystorePassFile(String keystorePassFile) { |
| 141 | + try { |
| 142 | + Path path = Paths.get(keystorePassFile); |
| 143 | + String password = new String(Files.readAllBytes(path)).trim(); |
| 144 | + setKeystorePass(password); |
| 145 | +
|
| 146 | + } catch (IOException e) { |
| 147 | + throw new RuntimeException(e); |
| 148 | + } |
| 149 | + } |
| 150 | +
|
| 151 | + public void setTruststorePassFile(String truststorePassFile) { |
| 152 | + try { |
| 153 | + Path path = Paths.get(truststorePassFile); |
| 154 | + String password = new String(Files.readAllBytes(path)).trim(); |
| 155 | + setTruststorePass(password); |
| 156 | +
|
| 157 | + } catch (IOException e) { |
| 158 | + throw new RuntimeException(e); |
| 159 | + } |
| 160 | + } |
| 161 | +*/ |
| 162 | + @Override |
| 163 | + protected Log getLog() { |
| 164 | + return log; |
| 165 | + } |
| 166 | + |
| 167 | + @Override |
| 168 | + protected String getNamePrefix() { |
| 169 | + if (isSSLEnabled()) { |
| 170 | + return "https-" + getSslImplementationShortName()+ "-jss-nio"; |
| 171 | + } |
| 172 | + return "http-jss-nio"; |
| 173 | + } |
| 174 | + |
| 175 | + // These methods are temporarly present to replicate the default behaviour provided by tomcat |
| 176 | + public void setSelectorTimeout(long timeout) { |
| 177 | + ((JSSNioEndpoint)getEndpoint()).setSelectorTimeout(timeout); |
| 178 | + } |
| 179 | + |
| 180 | + public long getSelectorTimeout() { |
| 181 | + return ((JSSNioEndpoint)getEndpoint()).getSelectorTimeout(); |
| 182 | + } |
| 183 | + |
| 184 | + public void setPollerThreadPriority(int threadPriority) { |
| 185 | + ((JSSNioEndpoint)getEndpoint()).setPollerThreadPriority(threadPriority); |
| 186 | + } |
| 187 | + |
| 188 | + public int getPollerThreadPriority() { |
| 189 | + return ((JSSNioEndpoint)getEndpoint()).getPollerThreadPriority(); |
| 190 | + } |
| 191 | +} |
0 commit comments