} catch (IllegalStateException e) {
}
}
public void testGetPublicKey() {
PublicKeyRecord pkr = new PublicKeyRecordImpl(
"k=rsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
pkr.validate();
PublicKey pk = pkr.getPublicKey();
assertEquals("RSA", pk.getAlgorithm());
// On older jvm this is X509
// assertEquals("X.509", pk.getFormat());
assertEquals(
new BigInteger(
"140815480285950232210124449496973988135931539914762288985377502488754711434253259186192434865594456027796377309280714060984552676169392598862819043219650259702261370701494928576447797673342985377518637829874968725582762257956980427968667812066816497848410406856165942400151628259779523949079651036806330485849"),
((RSAKey) pk).getModulus());
try {
pkr = new PublicKeyRecordImpl(
"k=dsa; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
pkr.validate();
pk = pkr.getPublicKey();
fail("Expected invalid key spec. DSA is not supported");
} catch (IllegalStateException e) {
}
try {
pkr = new PublicKeyRecordImpl(
"k=unknown; t=y; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIhyR3oItOy22ZOaBrIVe9m/iME3RqOJeasANSpg2YTHTYV+Xtp4xwf5gTjCmHQEMOs0qYu0FYiNQPQogJ2t0Mfx9zNu06rfRBDjiIU9tpx2T+NGlWZ8qhbiLo5By8apJavLyqTLavyPSrvsx0B3YzC63T4Age2CDqZYA+OwSMWQIDAQAB");
pkr.validate();
pk = pkr.getPublicKey();
fail("Expected invalid algorythm. 'unknown' is not supported");
} catch (IllegalStateException e) {
}
}