Skip to content

Commit

Permalink
update to v1.0.14 of the JAR
Browse files Browse the repository at this point in the history
  - update deserialization to use the BouncyCastle PEMParser
  - include tests of AES-encrypted and 3DES-encrypted private keys
  • Loading branch information
DinoChiesa committed Dec 20, 2017
1 parent f9f7521 commit c01770b
Show file tree
Hide file tree
Showing 20 changed files with 321 additions and 185 deletions.
4 changes: 2 additions & 2 deletions jwt_signed/Readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# JWT (signed)

This directory contains Java source code for a callout which verifies signed JWT,
as well as an example API proxy, which shows how to use the callout.
This directory contains Java source code for a callout which verifies signed JWT,
as well as an example API proxy, which shows how to use the callout.

- [Java source](callout) - Java code, as well as instructions for how to build the Java code.
- [apiproxy](apiproxy) - an example API Proxy for Apigee Edge that shows how to use the resulting Java callout
Expand Down
30 changes: 17 additions & 13 deletions jwt_signed/apiproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This is an open-source project of the Apigee Corporation. It is not covered by A

Several notes:

* use a tool like [apigeetool](https://github.com/apigee/apigeetool-node) or [pushapi](https://github.com/carloseberhardt/apiploy) to deploy the proxy
* use a tool like [importAndDeploy.js](https://github.com/DinoChiesa/apigee-edge-js/blob/master/examples/importAndDeploy.js), [apigeetool](https://github.com/apigee/apigeetool-node) or [pushapi](https://github.com/carloseberhardt/apiploy) to deploy the proxy

* the apiproxy must include the JAR, and all of its dependencies. See the [resources/java](resources/java) directory for those dependencies. Include them all in the proxy you deploy.

Expand Down Expand Up @@ -204,7 +204,7 @@ For example, this is how to configure the JWT creation with algorithm=HS256, whi
</Properties>

<ClassName>com.apigee.callout.jwt.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down Expand Up @@ -243,13 +243,12 @@ To configure JWT creation with private key signing using an RSA key:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

The pemfile need not be encrypted. If it is, obviously you need to
specify the password . Despite the name of the property, the file can
be in DER format or PEM format. The class looks for the file in the
specify the password . It should be in PEM format. The class looks for the file in the
jarfile under the /resources directory.

You can also specify the PEM-encoded private key directly in the XML
Expand Down Expand Up @@ -289,10 +288,15 @@ configuration, using the private-key Property, like this:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

You can generate a suitable DES3-encrypted public/private key pair with the command-line openssl tool, like this:
```
openssl genrsa -des3 -out private-encrypted.pem 2048
```

If you specify both pemfile and private-key, the latter will be used.
Either of these properties can also reference a context variable.

Expand All @@ -315,7 +319,7 @@ To configure JWT parsing with HS256:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down Expand Up @@ -366,7 +370,7 @@ the policy to get that behavior. Like so:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down Expand Up @@ -396,7 +400,7 @@ To configure JWT parsing with RS256:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down Expand Up @@ -447,7 +451,7 @@ public-key property, like so:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down Expand Up @@ -495,7 +499,7 @@ certificate.
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand All @@ -519,7 +523,7 @@ or, like so:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand All @@ -546,7 +550,7 @@ those values:
</Properties>

<ClassName>com.apigee.callout.jwt.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.13.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
```

Expand Down
3 changes: 1 addition & 2 deletions jwt_signed/apiproxy/policies/JWT-Create-HS256.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<JavaCallout name='JWT-Create-HS256' >
<DisplayName>JWT-Create-HS256</DisplayName>
<Properties>
Expand All @@ -18,5 +17,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
64 changes: 32 additions & 32 deletions jwt_signed/apiproxy/policies/JWT-Create-RS256-2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@

<!-- private-key and private-key-password used only for algorithm = RS256 -->
<Property name="private-key">
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,049E6103F40FBE84
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,171EA6A387A34BF7

EZVWs5v4FoRrFdK+YbpjCmW0KoHUmBAW7XLvS+vK3BdSM2Yx/hPhDO9URCVl9Oar
ApEZC1CxzsyRfvKDtiKWfQKdYKLccl8pA4Jj0sCxVgL4MBFDNDDEau4vRfXBv2EF
eGVZiG0/oaGbOUI9bgPKXmDsZQ3LHM9JONTOxaBapc06Gxcj0btkkzwB/dZQVRvb
XQFMzySgly1OOcnVkl8CDfKI4TwOERlhXjnnjN8vsDrpZXuSqniR9ARJEK41ZDAV
JpkvWnvEYl3oMozgF6NHCFXahefbP8lysMSknhtQwiJUaDZSkoBMMdMfQyfPpPME
tgJ4nkPBbSmwpWlTMPSgfth1kAkFvtmYCdV1UVglS+CE1/VDeuTeqkj5f7X/MvEx
FuWAkbZ3Gmqy04MvTOL8iy9A1wQo9E9U/6CgPqILcn49ZIOWilW6OzoGKK0F95KO
mx5r7MOkq21ltzCTmjt200YM/D5fq78ST7UzqetTFqNbgfraZxawcZf9L0xL2cwa
U9MJtPqCRLk4066+I2RkOZ8Zz1bro1nfCS99fayZ1AY/Ohw7+neviyuXIFSMTxsL
eiyPVBi6rrWjXIFITafK1oIoELimMbUHS9UOgJt7wkbKVYazcC9sQ4B1am1UQRe1
XQWtsYVySiId9iHA2UG+yc/l8GDmsKWAzlhFv5NyuCMAdfXbM1ERFaghPFx3RcZW
qtSkso/kFWrH6369ADN8fUAh6GOLrVAC06W6STzLEhoxNDyyS6RW9s/i9qhJWIX9
sMuDK2Zg+TRJ+nZbdljh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ASqREuU+qeDbx8DSqvun7YbP4Px5HzK+h+o1gV6
Ge4GFh3FIpwwKdZRxTpvKkE/0A3O1HOAUppvrERjWhdZcpDCRYP7R90k+B3FIVCT
ddUnryiJ/SmEEApn5swcJueLZgkBJluW1dg2RHYQcKu64wrKq66PmwaVOFo/T7bD
O8OPnhSgbxM+UdZPwmr7aKeoLPg9YvT2PJbKumQ68BDgrTWav/eUAElY3bNL+pf7
W6dD5I+Izacqn03jJgbDnIpdtFW3zsC1MYesfavVtRmdKlyV1fZBPDl5+F/kSCv1
-----END RSA PRIVATE KEY-----
</Property>
<!-- should store this secret in vault -->
<Property name="private-key-password">deecee123</Property>

<Property name="private-key-password">Apigee-IloveAPIs</Property>

<!-- standard claims -->
<Property name="subject">{apiproxy.name}</Property>
Expand All @@ -53,5 +53,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Create-RS256.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtCreatorCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-HS256-2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-HS256-paypal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-HS256.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-OpenIDConnect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-RS256-2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-RS256.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
2 changes: 1 addition & 1 deletion jwt_signed/apiproxy/policies/JWT-Parse-Verify-RS256-ms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ H3/bKkLSuDaKLWSqMhozdhXsIIKvJQ==
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
</Properties>

<ClassName>com.apigee.callout.jwtsigned.JwtParserCallout</ClassName>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.11.jar</ResourceURL>
<ResourceURL>java://apigee-edge-callout-jwt-signed-1.0.14.jar</ResourceURL>
</JavaCallout>
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit c01770b

Please sign in to comment.