-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests to verify modulus and exponent are correct with x5c values gene…
…rated by oxAuth KeyGenerator.
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
Client/src/test/java/org/xdi/oxauth/ws/rs/WebKeysTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2014, Gluu | ||
*/ | ||
|
||
package org.xdi.oxauth.ws.rs; | ||
|
||
import org.testng.ITestContext; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
import org.xdi.oxauth.BaseTest; | ||
import org.xdi.oxauth.model.util.Base64Util; | ||
import sun.security.x509.X509CertImpl; | ||
|
||
import java.math.BigInteger; | ||
import java.security.PublicKey; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.X509Certificate; | ||
import java.security.interfaces.RSAPublicKey; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
/** | ||
* @author Javier Rojas Blum | ||
* @version February 25, 2017 | ||
*/ | ||
public class WebKeysTest extends BaseTest { | ||
|
||
@Test(dataProvider = "webKeysDataProvider") | ||
public void webKeyTest(final String n, final String e, final String x5c) throws CertificateException { | ||
showTitle("webKeyTest"); | ||
|
||
byte[] nBytes = Base64Util.base64urldecode(n); | ||
BigInteger modulus = new BigInteger(1, nBytes); | ||
|
||
byte[] eBytes = Base64Util.base64urldecode(e); | ||
BigInteger exponent = new BigInteger(1, eBytes); | ||
|
||
System.out.println("n: " + n); | ||
System.out.println("n: " + modulus); | ||
|
||
System.out.println("e: " + e); | ||
System.out.println("e: " + exponent); | ||
|
||
byte[] certBytes = Base64Util.base64urldecode(x5c); | ||
X509Certificate cert = new X509CertImpl(certBytes); | ||
|
||
PublicKey publicKey = cert.getPublicKey(); | ||
RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey; | ||
assertEquals(rsaPublicKey.getModulus(), modulus); | ||
assertEquals(rsaPublicKey.getPublicExponent(), exponent); | ||
} | ||
|
||
@DataProvider(name = "webKeysDataProvider") | ||
public Object[][] dataProvider(ITestContext context) { | ||
return new Object[][]{ | ||
{ | ||
"5awKF1MZSGSAAlujSf-dRzvrK9D_vV85BMn7fZ-x5E-So580TrTxT9-vgfmTWzhDr0f240DqR6ojF_NGXh8V3QhFRM9i2p7dg7M3LO-mfYlrJ_x2Rlw-EdvMmYargk5gaM7sRQKwWnU6ajRZIDw3XbrLDvGeLWZhH1-RzV3NjlJ_0c85bXhyLg_MT9NpnGTP4CePLF0dLuQwo4ktQkkW_BwPaSUhHgPYA-M6IA9S31_vQLB4ZyN00EpdO57fEbhutkzrpb9iiXJh82DD0D5Z2eYyQdMX_7pN9frLKVhoCUelzZ887it0oIlLfpe8WUzuiDHWYThzQiepQfMBRQMJhQ", | ||
"AQAB", | ||
"MIIDAzCCAeugAwIBAgIgLuZ/WGm/NwCIWOVcrvj2QuLV6yxyWQD7GEsmM1SWgP8wDQYJKoZIhvcNAQELBQAwITEfMB0GA1UEAwwWb3hBdXRoIENBIENlcnRpZmljYXRlczAeFw0xNzAyMDgxMzM1NTJaFw0xODAyMDgxMzM2MDBaMCExHzAdBgNVBAMMFm94QXV0aCBDQSBDZXJ0aWZpY2F0ZXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDlrAoXUxlIZIACW6NJ/51HO+sr0P+9XzkEyft9n7HkT5KjnzROtPFP36+B+ZNbOEOvR/bjQOpHqiMX80ZeHxXdCEVEz2Lant2Dszcs76Z9iWsn/HZGXD4R28yZhquCTmBozuxFArBadTpqNFkgPDddussO8Z4tZmEfX5HNXc2OUn/Rzzl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dVZHtUsqX6CXWjEjZVhSshFgPMG5P29vRACWM3zgxuv4QMmzrcGc84mQrmkL+NOoohWJrOjkKchOc5gAZeLv8lqyWUJ9NJlSxKzbAgMBAAGjJzAlMCMGA1UdJQQcMBoGCCsGAQUFBwMBBggrBgEFBQcDAgYEVR0lADANBgkqhkiG9w0BAQ0FAAOCAQEAKbHMN54sX8E9p9J86wfZpkcsdyaNgk8j1cje+nq/7PgLKbxHVhVVdJWdFQC3glMPnmMMNByudcZ+cCT05Gpw016Ts9TVy5jgglbyV5FNJuaYZnLe5mVb6KuUxJZLZmJEYXlTgMW9lYwTgbKOo4lP0GNykTnYaGk6+R7pHcB+2To2uNSsNz3cXX9Pb6lDk78VJKD1DN3/LGHD/Tpavi15j8C8vSEGsZkeeSl5tEEFTXHqZQqu+pLQdH8eEvmTtt1yXk2LdlEvoQmubkELZKW7guYIU+lAZrjdDr5oPaAkefYsH50fl6KaYCtsV9mGNUvoW+LTtCgcUlvXGdGhFJmV3Q==" | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters