Forum Discussion

p_nevilleuk's avatar
p_nevilleuk
New Contributor
17 years ago

Groovy and encryption over http (not https)

Hello,

I am trying to modify the XML prior to sending by encrypting it using my own Cryptography classes (usign AES 256 bit). However, I can only see methods that take Strings when updating the request. For example,

def request = testRunner.testCase.getTestStepByName( "NewOperation - Request 1" );
def property = request.getProperty( "request" );
property.setValue(new String("xyz")); // I need this to take a byte[]

The next problem would be that I may get this error:
org.apache.xmlbeans.XmlException: error: Illegal XML

Can this be overcome?

Is there a way that SOAP-UI and groovy can send an encypted SOAP body but with plain http headers?

Thanks

2 Replies

  • Can groovy obtain the request property and set it to byte[] rather than String. If not now, can this be incorporated?

    Thanks
  • Hi p_nevilleuk,


    Why don't you instantiate a new string from a byte array?
    You can then use the resulting string to set a property or pass it to whatever soapUI API method that expects a string object:

    byte[] aesBytes = [0x41, 0x45, 0x53, 0x20, 0x72, 0x75, 0x6c, 0x65, 0x5a]
    log.info "AES bytes: $aesBytes"

    String aesString = new String(aesBytes)
    log.info "AES string: $aesString"

    Groovy behaves pretty much as Java which means you can use in Groovy whatever classes and methods are available in Java. That's why you can use in Groovy the String(byte[]) constructor that comes with the Java SDK.

    The main differences between the two lie are the fact Groovy is a dynamic language and that it has optional typing. Both features just give you more freedom.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla