• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ASN1Constants类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.harmony.security.asn1.ASN1Constants的典型用法代码示例。如果您正苦于以下问题:Java ASN1Constants类的具体用法?Java ASN1Constants怎么用?Java ASN1Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ASN1Constants类属于org.apache.harmony.security.asn1包,在下文中一共展示了ASN1Constants类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setEncodingContent

点赞 3

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
public void setEncodingContent(BerOutputStream out) {
    AttributeValue av = (AttributeValue) out.content;

    if (av.encoded != null) {
        out.length = av.encoded.length;
    } else {
        if (av.getTag() == ASN1Constants.TAG_UTF8STRING) {
            out.content = av.rawString;
            ASN1StringType.UTF8STRING.setEncodingContent(out);
            av.bytes = (byte[]) out.content;
            out.content = av;
        } else {
            av.bytes = av.rawString.getBytes(StandardCharsets.UTF_8);
            out.length = av.bytes.length;
        }
    }
}
 

开发者ID:Sellegit,
项目名称:j2objc,
代码行数:18,
代码来源:AttributeTypeAndValue.java

示例2: setEncodingContent

点赞 3

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
public void setEncodingContent(BerOutputStream out) {

            AttributeValue av = (AttributeValue) out.content;

            if (av.encoded != null) {
                out.length = av.encoded.length;
            } else {

                if (av.getTag() == ASN1Constants.TAG_UTF8STRING) {

                    out.content = av.rawString;

                    ASN1StringType.UTF8STRING.setEncodingContent(out);

                    av.bytes = (byte[]) out.content;
                    out.content = av;
                } else {
                    av.bytes = av.rawString.getBytes(Charsets.UTF_8);
                    out.length = av.bytes.length;
                }
            }
        }
 

开发者ID:keplersj,
项目名称:In-the-Box-Fork,
代码行数:23,
代码来源:AttributeTypeAndValue.java

示例3: setEncodingContent

点赞 3

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
public void setEncodingContent(BerOutputStream out) {
    
    AttributeValue av = (AttributeValue) out.content;

    if (av.encoded != null) {
        out.length = av.encoded.length;
    } else {

        if (av.getTag() == ASN1Constants.TAG_UTF8STRING) {

            out.content = av.rawString;

            ASN1StringType.UTF8STRING.setEncodingContent(out);

            av.bytes = (byte[]) out.content;
            out.content = av;
        } else {
            try {
                av.bytes = av.rawString.getBytes("UTF-8"); //$NON-NLS-1$
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e.getMessage());
            }
            out.length = av.bytes.length;
        }
    }
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:27,
代码来源:AttributeTypeAndValue.java

示例4: setEncodingContent

点赞 3

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
public void setEncodingContent(BerOutputStream out) {
    
    AttributeValue av = (AttributeValue) out.content;

    if (av.encoded != null) {
        out.length = av.encoded.length;
    } else {

        if (av.getTag() == ASN1Constants.TAG_UTF8STRING) {

            out.content = av.rawString;

            ASN1StringType.UTF8STRING.setEncodingContent(out);

            av.bytes = (byte[]) out.content;
            out.content = av;
        } else {
            av.bytes = av.rawString.getBytes();
            out.length = av.bytes.length;
        }
    }
}
 

开发者ID:freeVM,
项目名称:freeVM,
代码行数:23,
代码来源:AttributeTypeAndValue.java

示例5: test_Encoding

点赞 2

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
/**
 * Tests the result of encoding work on the data before and after 2050.
 */
public void test_Encoding() throws Exception {

    long march2006 = 1143115180000L;
    long march2332 = 11431151800000L;

    // verify that date before 2050 encoded as UTCTime
    byte[] enc = Time.ASN1.encode(new Date(march2006));
    assertEquals("UTCTime", ASN1Constants.TAG_UTCTIME, enc[0]);

    // verify that date after 2050 encoded as GeneralizedTime
    enc = Time.ASN1.encode(new Date(march2332));
    assertEquals("GeneralizedTime", ASN1Constants.TAG_GENERALIZEDTIME,
            enc[0]);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:18,
代码来源:TimeTest.java

示例6: decode

点赞 2

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
@Override
public Object decode(BerInputStream in) throws IOException {
    if (in.tag != ASN1Constants.TAG_NULL || in.getLength() != 0) {
        throw new IOException();
    }
    return new byte[0];
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:8,
代码来源:ASN1Null.java

示例7: ASN1Null

点赞 2

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
private ASN1Null() {
    super(ASN1Constants.TAG_NULL);
}
 

开发者ID:shannah,
项目名称:cn1,
代码行数:4,
代码来源:ASN1Null.java

示例8: test_readContent

点赞 2

import org.apache.harmony.security.asn1.ASN1Constants; //导入依赖的package包/类
/**
 * @tests org.apache.harmony.security.asn1.BerInputStream#readContent()
 */
public void test_readContent() throws IOException {

    byte[] encoding = { ASN1Constants.TAG_OCTETSTRING, 0x0F, 0x01, 0x02,
            0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
            0x0D, 0x0E, 0x0F };

    // a custom input stream that doesn't return all data at once
    ByteArrayInputStream in = new ByteArrayInputStream(encoding) {
        public int read(byte[] b, int off, int len) {
            if (len < 2) {
                return super.read(b, off, len);
            } else {
                return super.read(b, off, 4);
            }

        }
    };

    BerInputStream berIn = new BerInputStream(in);
    berIn.readContent();

    assertTrue(Arrays.equals(encoding, berIn.getEncoded()));

    //
    // negative test case: the stream returns only 4 bytes of content
    //
    in = new ByteArrayInputStream(encoding) {

        int i = 0;

        public int read(byte[] b, int off, int len) {
            if (i == 0) {
                i++;
                return super.read(b, off, 4);
            } else {
                return 0;
            }

        }
    };
    berIn = new BerInputStream(in);
    try {
        berIn.readContent();
        fail("No expected ASN1Exception");
    } catch (ASN1Exception e) {
    }
}
 

开发者ID:freeVM,
项目名称:freeVM,
代码行数:51,
代码来源:BerInputStreamTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)