GithubHelp home page GithubHelp logo

dinochiesa / apigee-custompolicy-aescrypto Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 7.0 4.15 MB

a configurable custom policy for Apigee, which performs AES encryption or decryption.

License: Apache License 2.0

Shell 1.06% Java 98.94%
aes apigee cryptography encryption java

apigee-custompolicy-aescrypto's Introduction

apigee-custompolicy-aescrypto's People

Contributors

dinochiesa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

apigee-custompolicy-aescrypto's Issues

Failed with Error Missing Source

I am facing an issue which is it gives me error 500 missing source

Screen Shot 1443-06-06 at 9 14 53 PM

Javacallout body:

<JavaCallout async="false" continueOnError="false" enabled="true" name="Java-Callout-1">
    <DisplayName>Java Callout-1</DisplayName>
    <Properties>
        <Property name="action">decrypt</Property>
        <Property name="debug">true</Property>
        <Property name="mode">GCM</Property>
        <Property name="padding">NoPadding</Property>
        <Property name="key">385f9fd4cba017c159956276036545b0</Property>
        <Property name="decode-key">base16</Property>
        <Property name="iv">mRqogt0pxtPdgyjt</Property>
        <Property name="decode-iv">base64url</Property>
        <Property name="source">73XlhsvhcsaIFJUrqZFyf0Hjgxx9A-rbPWoIdsup-ScsXuqO6RevhNdjBg</Property>
        <Property name="decode-source">base64url</Property>
        <Property name="aad">eyJ0eXAiOiJKV1QiLCJoZHIxIjoxMjMsImVuYyI6IkExMjhHQ00iLCJoZHIyIjp0cnVlLCJhbGciOiJSU0EtT0FFUC0yNTYifQ</Property>
        <Property name="tag">ESdhCa_eqd2FaI5e5IH2xQ</Property>
        <Property name="decode-tag">base64url</Property>
        <Property name="utf8-decode-result">true</Property>
    </Properties>
    <ClassName>com.google.apigee.callouts.AesCryptoCallout</ClassName>
    <ResourceURL>java://apigee-callout-aes-crypto-20211122a.jar</ResourceURL>
</JavaCallout>

Any help please ?

Corresponding Example for Decryption

Is it possible to have corresponding decryption example policy definitions for the sample encryption policies in the README.md please?

I've got encryption with CFB working, but can't work out the corresponding policy to do the decryption

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JavaCallout name="Java-e">
  <Properties>
    <Property name="action">encrypt</Property>
    <Property name="debug">true</Property>
    <Property name="source">request.queryparam.text</Property>
    <Property name="key-strength">256</Property>
    <Property name="mode">CFB</Property>
    <Property name="encode-result">base64</Property>
    <Property name="passphrase">{request.queryparam.passphrase}</Property>
  </Properties>
  <ClassName>com.google.apigee.callouts.AesCryptoCallout</ClassName>
  <ResourceURL>java://apigee-callout-aes-crypto-20211122a.jar</ResourceURL>
</JavaCallout>

What I have at the moment for decryption

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JavaCallout continueOnError="false" enabled="true" name="Java-d">
  <DisplayName>Java-d</DisplayName>
  <Properties>
    <Property name="action">decrypt</Property>
    <Property name="debug">true</Property>
    <Property name="source">request.queryparam.text</Property>
    <Property name="key-strength">256</Property>
    <Property name="mode">CFB</Property>
    <Property name="decode-source">base64</Property>
    <Property name="passphrase">{request.queryparam.passphrase}</Property>
    <Property name="utf8-decode-result">true</Property>
  </Properties>
  <ClassName>com.google.apigee.callouts.AesCryptoCallout</ClassName>
  <ResourceURL>java://apigee-callout-aes-crypto-20211122a.jar</ResourceURL>
</JavaCallout>

It throws an error, but it doesn't tell me what is wrong.

{
    "fault": {
        "faultstring": "Execution returned an error result",
        "detail": {
            "errorcode": "flow.execution.ExecutionReturnedFailure"
        }
    }
}

javax.crypto.IllegalBlockSizeException:Input length must be multiple of 16 when decrypting with padded cipher

Hello Dino,

We are facing the below error while performing encryption/decryption using key,IV

can you please help to resolve issue.

Below is the code snippet


Encrypt encrypt true 256 {SHA256Hashing} 2121helloraesaes CBC PKCS5Padding base64 com.google.apigee.callouts.AesCryptoCallout java://apigee-callout-aes-crypto-20210409.jar
Decrypt decrypt true 256 {SHA256Hashing} 2121helloraesaes CBC PKCS5Padding true com.google.apigee.callouts.AesCryptoCallout java://apigee-callout-aes-crypto-20210409.jar

Error:

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:936) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:847) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446) at javax.crypto.Cipher.doFinal(Cipher.java:2165) at com.google.apigee.callouts.AesCryptoCallout.aesDecrypt(AesCryptoCallout.java:367) at com.google.apigee.callouts.AesCryptoCallout.execute(AesCryptoCallout.java:528) at com.apigee.steps.javacallout.JavaCalloutStepDefinition$ClassLoadWrappedExecution.execute(JavaCalloutStepDefinition.java:235) at com.apigee.steps.javacallout.JavaCalloutStepDefinition$SecurityWrappedExecution$1.run(JavaCalloutStepDefinition.java:302) at com.apigee.steps.javacallout.JavaCalloutStepDefinition$SecurityWrappedExecution$1.run(JavaCalloutStepDefinition.java:300) at java.security.AccessController.doPrivileged(Native Method) at com.apigee.steps.javacallout.JavaCalloutStepDefinition$SecurityWrappedExecution.execute(JavaCalloutStepDefinition.java:300) at com.apigee.steps.javacallout.JavaCalloutStepDefinition$CallOutWrapper.execute(JavaCalloutStepDefinition.java:169) at com.apigee.messaging.runtime.steps.StepExecution.execute(StepExecution.java:157) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:82) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:48) at com.apigee.threadpool.CallableWrapperForMDCPreservation.call(CallableWrapperForMDCPreservation.java:26) at com.apigee.threadpool.ThreadPoolManager$QueueAwareCallableTask.call(ThreadPoolManager.java:546) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

Regards,
Mani Teja

Doesn't build on Java 11

The Google fork of jMockit doesn't work on Java 11. The source code link for the Google fork of jMockit links to jmockit.org which is a site selling drugs.

The code doesn't compile using the standard 'org.jmockit' dependency which has been upgraded to work on Java 11

$ mvn --version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec Java version: 11.0.9.1, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home Default locale: en_CA, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.google.apigee.edgecalluts.testng.tests.TestAesCryptoCallout
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@3327bd23
java.lang.IllegalStateException: JMockit requires a Java 5+ VM
	at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:31)
	at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:239)
	at mockit.integration.testng.Initializer.<init>(Initializer.java:27)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
	at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:961)
	at org.testng.TestNG.initializeConfiguration(TestNG.java:896)
	at org.testng.TestNG.run(TestNG.java:1031)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.util.ServiceConfigurationError: org.testng.ITestNGListener: Provider mockit.integration.testng.Initializer could not be instantiated
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:581)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:803)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
	at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:961)
	at org.testng.TestNG.initializeConfiguration(TestNG.java:896)
	at org.testng.TestNG.run(TestNG.java:1031)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
	... 9 more
Caused by: java.lang.IllegalStateException: JMockit requires a Java 5+ VM
	at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:31)
	at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:239)
	at mockit.integration.testng.Initializer.<init>(Initializer.java:27)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
	... 17 more

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.