Пример #1
0
  private void receivedHahdshake(Handshake handshake) throws CommunicationException {
    String clientVersion = handshake.getVersion();
    this.workContext.setClientVersion(Version.getVersion(clientVersion));
    if (usingEncryption) {
      byte[] returnedPublicKey = handshake.getPublicKey();

      // ensure the key information
      if (returnedPublicKey == null) {
        throw new CommunicationException(
            RuntimePlugin.Event.TEIID40052, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40052));
      }

      try {
        this.cryptor =
            keyGen.getSymmetricCryptor(
                returnedPublicKey, "8.3".compareTo(clientVersion) > 0); // $NON-NLS-1$
        ((SymmetricCryptor) this.cryptor)
            .setClassLoader(SocketClientInstance.class.getClassLoader());
      } catch (CryptoException e) {
        throw new CommunicationException(RuntimePlugin.Event.TEIID40053, e);
      }
      this.keyGen = null;
    } else {
      this.cryptor = new NullCryptor();
    }
  }
Пример #2
0
 public void onConnection() throws CommunicationException {
   Handshake handshake = new Handshake();
   handshake.setAuthType(csr.getAuthenticationType());
   if (usingEncryption) {
     keyGen = new DhKeyGenerator();
     byte[] publicKey;
     try {
       publicKey = keyGen.createPublicKey();
     } catch (CryptoException e) {
       throw new CommunicationException(RuntimePlugin.Event.TEIID40051, e);
     }
     handshake.setPublicKey(publicKey);
   }
   this.objectSocket.write(handshake);
 }