⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typeofbiometricdataunittest.java

📁 J2ME加密算法的代码!里面包括常用的算法
💻 JAVA
字号:
package org.bouncycastle.asn1.test;import java.io.IOException;import org.bouncycastle.asn1.ASN1InputStream;import org.bouncycastle.asn1.DERObject;import org.bouncycastle.asn1.DERObjectIdentifier;import org.bouncycastle.asn1.x509.qualified.TypeOfBiometricData;import org.bouncycastle.util.test.SimpleTest;public class TypeOfBiometricDataUnitTest     extends SimpleTest{    public String getName()    {        return "TypeOfBiometricData";    }    public void performTest()         throws Exception    {        //        // predefined        //        checkPredefinedType(TypeOfBiometricData.PICTURE);                checkPredefinedType(TypeOfBiometricData.HANDWRITTEN_SIGNATURE);                //        // non-predefined        //        DERObjectIdentifier localType = new DERObjectIdentifier("1.1");                TypeOfBiometricData type = new TypeOfBiometricData(localType);        checkNonPredefined(type, localType);                type = TypeOfBiometricData.getInstance(type);                checkNonPredefined(type, localType);                DERObject obj = type.toASN1Object();                type = TypeOfBiometricData.getInstance(obj);                checkNonPredefined(type, localType);                type = TypeOfBiometricData.getInstance(null);                if (type != null)        {            fail("null getInstance() failed.");        }                try        {            TypeOfBiometricData.getInstance(new Object());                        fail("getInstance() failed to detect bad object.");        }        catch (IllegalArgumentException e)        {            // expected        }                try        {            new TypeOfBiometricData(100);                        fail("constructor failed to detect bad predefined type.");        }        catch (IllegalArgumentException e)        {            // expected        }                if (TypeOfBiometricData.PICTURE != 0)        {            fail("predefined picture should be 0");        }                if (TypeOfBiometricData.HANDWRITTEN_SIGNATURE != 1)        {            fail("predefined handwritten signature should be 1");        }    }    private void checkPredefinedType(        int predefinedType)        throws IOException    {        TypeOfBiometricData type = new TypeOfBiometricData(predefinedType);        checkPredefined(type, predefinedType);                type = TypeOfBiometricData.getInstance(type);                checkPredefined(type, predefinedType);                ASN1InputStream aIn = new ASN1InputStream(type.toASN1Object().getEncoded());        DERObject obj = aIn.readObject();        type = TypeOfBiometricData.getInstance(obj);                checkPredefined(type, predefinedType);    }    private void checkPredefined(        TypeOfBiometricData type,        int                 value)    {        if (!type.isPredefined())        {            fail("predefined type expected but not found.");        }                if (type.getPredefinedBiometricType() != value)        {            fail("predefined type does not match.");        }    }        private void checkNonPredefined(        TypeOfBiometricData type,        DERObjectIdentifier value)    {        if (type.isPredefined())        {            fail("predefined type found when not expected.");        }                if (!type.getBiometricDataOid().equals(value))        {            fail("data oid does not match.");        }    }        public static void main(        String[]    args)    {        runTest(new TypeOfBiometricDataUnitTest());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -