Skip to content

Commit

Permalink
remove unnecessary dependencies
Browse files Browse the repository at this point in the history
make it easier for downstream projects to consume
  • Loading branch information
ahgittin committed Aug 23, 2021
1 parent a4fb41c commit 0f000c4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
5 changes: 3 additions & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- not needed, and too many unwanted deps
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
Expand All @@ -64,6 +65,7 @@
<artifactId>cxf-rt-rs-security-xml</artifactId>
<version>${cxf.version}</version>
</dependency>
-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>winrm4j-service</artifactId>
Expand Down Expand Up @@ -96,8 +98,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<!-- <version>${httpcomponents.httpclient.version}</version>-->
<version>${httpcomponents.httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package io.cloudsoft.winrm4j.client;

import io.cloudsoft.winrm4j.client.retry.RetryDecision;
import io.cloudsoft.winrm4j.client.retry.RetryPolicy;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.SOAPFaultException;

import org.apache.cxf.jaxrs.utils.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.cloudsoft.winrm4j.client.retry.RetryDecision;
import io.cloudsoft.winrm4j.client.retry.RetryPolicy;

class RetryingProxyHandler implements InvocationHandler {
private static final Logger LOG = LoggerFactory.getLogger(RetryingProxyHandler.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package io.cloudsoft.winrm4j.client.encryption;

import java.io.ByteArrayOutputStream;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.crypto.engines.RC4Engine;
import org.bouncycastle.crypto.io.CipherOutputStream;
import org.bouncycastle.crypto.params.KeyParameter;

public class WinrmEncryptionUtils {

Expand All @@ -33,23 +30,44 @@ public static CryptoHandler decryptorArc4(byte[] key) {

public static CryptoHandler cryptorArc4(boolean forEncryption, byte[] key) {
// engine needs to be stateful
RC4Engine engine = new RC4Engine();
engine.init(forEncryption, new KeyParameter(key));
try {
final Cipher rc4 = Cipher.getInstance("RC4");
rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "RC4"));

return new CryptoHandler() {
@Override
public byte[] update(byte[] input) {
try {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
CipherOutputStream cos = new CipherOutputStream(outBytes, engine);
cos.write(input);
return new CryptoHandler() {
@Override
public byte[] update(byte[] input) {
try {
return rc4.update(input);

return outBytes.toByteArray();
} catch (Exception e) {
throw new IllegalStateException(e);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
};
};

} catch (Exception e) {
throw new IllegalStateException(e);
}

// using bouncycastle - but brings in unnecessary deps
// RC4Engine engine = new RC4Engine();
// engine.init(forEncryption, new KeyParameter(key));
//
// return new CryptoHandler() {
// @Override
// public byte[] update(byte[] input) {
// try {
// ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
// CipherOutputStream cos = new CipherOutputStream(outBytes, engine);
// cos.write(input);
//
// return outBytes.toByteArray();
// } catch (Exception e) {
// throw new IllegalStateException(e);
// }
// }
// };
}

public static byte[] hmacMd5(byte[] key, byte[] body) {
Expand Down

0 comments on commit 0f000c4

Please sign in to comment.