Package org.apache.harmony.crypto.tests.support

Examples of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi$tmpKey


        Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider",
                "Provider for ExemptionMechanism testing",
                srvExemptionMechanism.concat(".").concat(defaultAlg),
                ExemptionMechanismProviderClass);

        ExemptionMechanismSpi spi = new MyExemptionMechanismSpi();

        ExemptionMechanism em = new ExemptionMechanism(spi, mProv, defaultAlg) {};
        assertEquals("Incorrect provider", em.getProvider(), mProv);
        assertEquals("Incorrect algorithm", em.getName(), defaultAlg);
        try {
View Full Code Here


                "Provider for ExemptionMechanism testing",
                srvExemptionMechanism.concat(".").concat(defaultAlg),
                ExemptionMechanismProviderClass);

        ExemptionMechanism em = new ExemptionMechanism(
                new MyExemptionMechanismSpi(), mProv, defaultAlg) {
        };

        Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);

        assertFalse(em.isCryptoAllowed(key));

        em.init(key);
        assertFalse(em.isCryptoAllowed(key));

        em.genExemptionBlob();
        assertTrue(em.isCryptoAllowed(key));

        Key key1 = new MyExemptionMechanismSpi().new tmpKey("Proba",
                new byte[] { 1 });
        assertFalse(em.isCryptoAllowed(key1));

        em.init(key1);
        assertFalse(em.isCryptoAllowed(key));
View Full Code Here

                "Provider for ExemptionMechanism testing",
                srvExemptionMechanism.concat(".").concat(defaultAlg),
                ExemptionMechanismProviderClass);

        ExemptionMechanism em = new ExemptionMechanism(
                new MyExemptionMechanismSpi(), mProv, defaultAlg) {
        };

        Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);

        em.init(key);
        // ExemptionMechanism doesn't check parameters
        // it is a responsibility of ExemptionMechanismSpi
        em.genExemptionBlob(null, 0);
View Full Code Here

    }

    private void checkResult(ExemptionMechanism exMech)
            throws ExemptionMechanismException, ShortBufferException,
            InvalidKeyException, InvalidAlgorithmParameterException {
        Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]);
        byte[] emptyA = new byte[0];
        int len = MyExemptionMechanismSpi.getLength();
        byte[] byteA = new byte[len];
        try {
            exMech.genExemptionBlob();
View Full Code Here

     */
    public void testExemptionMechanismSpi01()
            throws  ExemptionMechanismException,
            ShortBufferException, InvalidKeyException,
            InvalidAlgorithmParameterException {
        ExemptionMechanismSpi emSpi = new MyExemptionMechanismSpi();
        int len = MyExemptionMechanismSpi.getLength();
        byte [] bbRes = emSpi.engineGenExemptionBlob();
        assertEquals("Incorrect length", bbRes.length, len);
        assertEquals("Incorrect result",
                emSpi.engineGenExemptionBlob(new byte[1], len), len);
        assertEquals("Incorrect output size", 10, emSpi.engineGetOutputSize(100));
        Key key = null;
        AlgorithmParameters params = null;       
        AlgorithmParameterSpec parSpec = null;
        try {
            emSpi.engineInit(key);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        try {
            emSpi.engineInit(key, params);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        try {
            emSpi.engineInit(key, parSpec);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        key = ((MyExemptionMechanismSpi)emSpi).new tmp1Key("Proba", new byte[0]);
        try {
            emSpi.engineInit(key);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        try {
            emSpi.engineInit(key, params);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        try {
            emSpi.engineInit(key, parSpec);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        key = ((MyExemptionMechanismSpi)emSpi).new tmpKey("Proba", new byte[0]);
        emSpi.engineInit(key);
        emSpi.engineInit(key, params);
        emSpi.engineInit(key, parSpec);
       
        assertEquals("Incorrect result", 10, emSpi.engineGetOutputSize(100));
    }
View Full Code Here

     */
    public void testExemptionMechanismSpi01()
            throws  ExemptionMechanismException,
            ShortBufferException, InvalidKeyException,
            InvalidAlgorithmParameterException {
        ExemptionMechanismSpi emSpi = new MyExemptionMechanismSpi();
        int len = MyExemptionMechanismSpi.getLength();
        byte [] bbRes = emSpi.engineGenExemptionBlob();
        assertEquals("Incorrect length", bbRes.length, len);
        assertEquals("Incorrect result",
                emSpi.engineGenExemptionBlob(new byte[1], len), len);
        assertEquals("Incorrect output size", 10, emSpi.engineGetOutputSize(100));
        Key key = null;
        AlgorithmParameters params = null;       
        AlgorithmParameterSpec parSpec = null;
        try {
            emSpi.engineInit(key);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        try {
            emSpi.engineInit(key, params);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        try {
            emSpi.engineInit(key, parSpec);
            fail("InvalidKeyException must be thrown");
        } catch (InvalidKeyException e) {
        }
        key = ((MyExemptionMechanismSpi)emSpi).new tmp1Key("Proba", new byte[0]);
        try {
            emSpi.engineInit(key);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        try {
            emSpi.engineInit(key, params);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        try {
            emSpi.engineInit(key, parSpec);
            fail("ExemptionMechanismException must be thrown");
        } catch (ExemptionMechanismException e) {
        }
        key = ((MyExemptionMechanismSpi)emSpi).new tmpKey("Proba", new byte[0]);
        emSpi.engineInit(key);
        emSpi.engineInit(key, params);
        emSpi.engineInit(key, parSpec);
       
        assertEquals("Incorrect result", 10, emSpi.engineGetOutputSize(100));
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi$tmpKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.