private void writeClientAuthentication(StatePlaintext statePlaintext) { byte clientAuthenticationType = statePlaintext.getClientAuthenticationType().getValue(); if (clientAuthenticationType == ClientAuthenticationType.ANONYMOUS.getValue()) { appendByte(clientAuthenticationType); LOGGER.debug("ClientAuthenticationType: " + ClientAuthenticationType.getClientAuthenticationType(clientAuthenticationType).name()); } else if (clientAuthenticationType == ClientAuthenticationType.CERTIFICATE_BASED.getValue()) { appendByte(clientAuthenticationType); appendBytes(statePlaintext.getClientAuthenticationDataLength().getByteArray( appendBytes(statePlaintext.getClientAuthenticationData().getValue()); LOGGER.debug("ClientAuthenticationType: " + ClientAuthenticationType.getClientAuthenticationType(clientAuthenticationType).name()); LOGGER.debug("ClientAuthenticationDataLength: " + statePlaintext.getClientAuthenticationDataLength().getValue()); + ArrayConverter.bytesToHexString(statePlaintext.getClientAuthenticationData().getValue(), true, true)); } else if (clientAuthenticationType == ClientAuthenticationType.PSK.getValue()) { appendByte(clientAuthenticationType); appendBytes(statePlaintext.getClientAuthenticationDataLength().getByteArray( appendBytes(statePlaintext.getClientAuthenticationData().getValue()); LOGGER.debug("ClientAuthenticationType: " + ClientAuthenticationType.getClientAuthenticationType(clientAuthenticationType).name()); LOGGER.debug("ClientAuthenticationDataLength: " + statePlaintext.getClientAuthenticationDataLength().getValue());
/** * Generates the StatePlaintext for the SessionTicket, mayby put this as * static function in the StatePlaintext class for better testing/debugging * * @return A struct with Stateinformation defined in * https://tools.ietf.org/html/rfc5077#section-4 */ private StatePlaintext generateStatePlaintext() { StatePlaintext plainstate = new StatePlaintext(); plainstate.setCipherSuite(chooser.getSelectedCipherSuite().getValue()); plainstate.setCompressionMethod(chooser.getSelectedCompressionMethod().getValue()); plainstate.setMasterSecret(chooser.getMasterSecret()); plainstate.setProtocolVersion(chooser.getSelectedProtocolVersion().getValue()); long timestamp = TimeHelper.getTime() / 1000; plainstate.setTimestamp(timestamp); switch (chooser.getConfig().getClientAuthenticationType()) { case ANONYMOUS: plainstate.setClientAuthenticationType(ClientAuthenticationType.ANONYMOUS.getValue()); plainstate.setClientAuthenticationData(new byte[0]); plainstate.setClientAuthenticationDataLength(0); break; case CERTIFICATE_BASED: throw new UnsupportedOperationException("Certificate based ClientAuthentication is not supported"); case PSK: throw new UnsupportedOperationException("PSK ClientAuthentication is not supported"); default: throw new UnsupportedOperationException("Unknown ClientAuthenticationType"); } return plainstate; }