package at.gv.egiz.eaaf.modules.auth.sl20.utils; import java.security.Security; import org.apache.commons.lang3.RandomStringUtils; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SL20Exception; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/spring/test_eaaf_sl20_hsm.beans.xml") public class JsonSecurityUtilsHsmKeyTest { @Autowired private IJoseTools joseTools; @BeforeClass public static void classInitializer() { Security.addProvider(new BouncyCastleProvider()); } @Test public void simpleSigningTest() throws SL20Exception { String payLoad = "{\"aac\":\"" + RandomStringUtils.randomAlphanumeric(100) + "\"}"; String jws = joseTools.createSignature(payLoad); Assert.assertNotNull("Signed msg", jws); //VerificationResult verify = joseTools.validateSignature(jws); //Assert.assertTrue("wrong verify state", verify.isValidSigned()); } }