当前位置: 首页>>代码示例>>Java>>正文


Java DERApplicationSpecific.getContents方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.DERApplicationSpecific.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java DERApplicationSpecific.getContents方法的具体用法?Java DERApplicationSpecific.getContents怎么用?Java DERApplicationSpecific.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.DERApplicationSpecific的用法示例。


在下文中一共展示了DERApplicationSpecific.getContents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initCertBody

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
private void initCertBody(DERApplicationSpecific request)
    throws IOException
{
    if (request.getApplicationTag() == EACTags.CARDHOLDER_CERTIFICATE)
    {
        ASN1Sequence seq = ASN1Sequence.getInstance(request.getObject(BERTags.SEQUENCE));
        for (Enumeration en = seq.getObjects(); en.hasMoreElements();)
        {
            DERApplicationSpecific obj = DERApplicationSpecific.getInstance(en.nextElement());
            switch (obj.getApplicationTag())
            {
            case EACTags.CERTIFICATE_CONTENT_TEMPLATE:
                certificateBody = CertificateBody.getInstance(obj);
                valid |= bodyValid;
                break;
            case EACTags.STATIC_INTERNAL_AUTHENTIFICATION_ONE_STEP:
                innerSignature = obj.getContents();
                valid |= signValid;
                break;
            default:
                throw new IOException("Invalid tag, not an CV Certificate Request element:" + obj.getApplicationTag());
            }
        }
    }
    else
    {
        throw new IOException("not a CARDHOLDER_CERTIFICATE in request:" + request.getApplicationTag());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:CVCertificateRequest.java

示例2: CallDetailRecord

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public CallDetailRecord(ASN1Sequence inSeq) throws UnsupportedEncodingException {
	cdr = inSeq;
	
	for (@SuppressWarnings("unchecked")
	Enumeration<ASN1Encodable> en = cdr.getObjects(); en.hasMoreElements();) {
		ASN1Encodable em = en.nextElement();
		ASN1Primitive emp = em.toASN1Primitive();
		DERApplicationSpecific emt = (DERApplicationSpecific)emp;
		
		//System.out.println("emt.getApplicationTag(): "+emt.getApplicationTag());
		
		switch (emt.getApplicationTag()) {
			case 2: recordNumber = emt.getContents()[0];
				break;
			case 8: callingNumber = new String(emt.getContents(), "UTF-8");
				break;
			case 9: calledNumber = new String(emt.getContents(), "UTF-8");
				break;
			case 16: startDate = new String(emt.getContents(), "UTF-8");
				break;
			case 18: startTime = new String(emt.getContents(), "UTF-8");
				break;
			case 19: duration = emt.getContents()[0];
				break;
			default:
				//Unknown application number. In production would either log or error.
				break;
		}
	}

}
 
开发者ID:awcoleman,项目名称:BouncyCastleGenericCDRHadoop,代码行数:32,代码来源:CallDetailRecord.java

示例3: CallDetailRecord

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public CallDetailRecord(ASN1Sequence inSeq) throws UnsupportedEncodingException {
	cdr = inSeq;
	
	for (Enumeration<ASN1Encodable> en = cdr.getObjects(); en.hasMoreElements();) {
		ASN1Encodable em = en.nextElement();
		ASN1Primitive emp = em.toASN1Primitive();
		DERApplicationSpecific emt = (DERApplicationSpecific)emp;
		
		//System.out.println("emt.getApplicationTag(): "+emt.getApplicationTag());
		
		switch (emt.getApplicationTag()) {
			case 2: recordNumber = emt.getContents()[0];
				break;
			case 8: callingNumber = new String(emt.getContents(), "UTF-8");
				break;
			case 9: calledNumber = new String(emt.getContents(), "UTF-8");
				break;
			case 16: startDate = new String(emt.getContents(), "UTF-8");
				break;
			case 18: startTime = new String(emt.getContents(), "UTF-8");
				break;
			case 19: duration = emt.getContents()[0];
				break;
			default:
				//Unknown application number. In production would either log or error.
				break;
		}
	}

}
 
开发者ID:awcoleman,项目名称:BouncyCastleGenericCDRHadoop,代码行数:31,代码来源:CallDetailRecord.java

示例4: parse

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
@Override
protected void parse ( byte[] token ) throws IOException {

    try ( ASN1InputStream is = new ASN1InputStream(token) ) {
        DERApplicationSpecific constructed = (DERApplicationSpecific) is.readObject();
        if ( constructed == null || !constructed.isConstructed() )
            throw new IOException(
                "Malformed SPNEGO token " + constructed
                        + ( constructed != null ? " " + constructed.isConstructed() + " " + constructed.getApplicationTag() : "" ));

        try ( ASN1InputStream der = new ASN1InputStream(constructed.getContents()) ) {
            ASN1ObjectIdentifier spnego = (ASN1ObjectIdentifier) der.readObject();
            if ( !SPNEGO_OID.equals(spnego) ) {
                throw new IOException("Malformed SPNEGO token, OID " + spnego);
            }
            ASN1TaggedObject tagged = (ASN1TaggedObject) der.readObject();
            if ( tagged.getTagNo() != 0 ) {
                throw new IOException("Malformed SPNEGO token: tag " + tagged.getTagNo() + " " + tagged);
            }
            ASN1Sequence sequence = ASN1Sequence.getInstance(tagged, true);
            Enumeration<ASN1Object> fields = sequence.getObjects();
            while ( fields.hasMoreElements() ) {
                tagged = (ASN1TaggedObject) fields.nextElement();
                switch ( tagged.getTagNo() ) {
                case 0:
                    sequence = ASN1Sequence.getInstance(tagged, true);
                    ASN1ObjectIdentifier[] mechs = new ASN1ObjectIdentifier[sequence.size()];
                    for ( int i = mechs.length - 1; i >= 0; i-- ) {
                        mechs[ i ] = (ASN1ObjectIdentifier) sequence.getObjectAt(i);
                    }
                    setMechanisms(mechs);
                    break;
                case 1:
                    DERBitString ctxFlags = DERBitString.getInstance(tagged, true);
                    setContextFlags(ctxFlags.getBytes()[ 0 ] & 0xff);
                    break;
                case 2:
                    ASN1OctetString mechanismToken = ASN1OctetString.getInstance(tagged, true);
                    setMechanismToken(mechanismToken.getOctets());
                    break;

                case 3:
                    if ( ! ( tagged.getObject() instanceof DEROctetString ) ) {
                        break;
                    }
                case 4:
                    ASN1OctetString mechanismListMIC = ASN1OctetString.getInstance(tagged, true);
                    setMechanismListMIC(mechanismListMIC.getOctets());
                    break;
                default:
                    throw new IOException("Malformed token field.");
                }
            }
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:57,代码来源:NegTokenInit.java

示例5: KerberosApRequest

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public KerberosApRequest ( byte[] token, KerberosKey[] keys ) throws PACDecodingException {
    if ( token.length <= 0 )
        throw new PACDecodingException("Empty kerberos ApReq");

    DLSequence sequence;
    try {
        try ( ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(token)) ) {
            sequence = ASN1Util.as(DLSequence.class, stream);
        }
    }
    catch ( IOException e ) {
        throw new PACDecodingException("Malformed Kerberos Ticket", e);
    }

    Enumeration<?> fields = sequence.getObjects();
    while ( fields.hasMoreElements() ) {
        ASN1TaggedObject tagged = ASN1Util.as(ASN1TaggedObject.class, fields.nextElement());
        switch ( tagged.getTagNo() ) {
        case 0:
            ASN1Integer pvno = ASN1Util.as(ASN1Integer.class, tagged);
            if ( !pvno.getValue().equals(new BigInteger(KerberosConstants.KERBEROS_VERSION)) ) {
                throw new PACDecodingException("Invalid kerberos version");
            }
            break;
        case 1:
            ASN1Integer msgType = ASN1Util.as(ASN1Integer.class, tagged);
            if ( !msgType.getValue().equals(new BigInteger(KerberosConstants.KERBEROS_AP_REQ)) )
                throw new PACDecodingException("Invalid kerberos request");
            break;
        case 2:
            DERBitString bitString = ASN1Util.as(DERBitString.class, tagged);
            this.apOptions = bitString.getBytes()[ 0 ];
            break;
        case 3:
            DERApplicationSpecific derTicket = ASN1Util.as(DERApplicationSpecific.class, tagged);
            if ( !derTicket.isConstructed() )
                throw new PACDecodingException("Malformed Kerberos Ticket");
            this.ticket = new KerberosTicket(derTicket.getContents(), this.apOptions, keys);
            break;
        case 4:
            // Let's ignore this for now
            break;
        default:
            throw new PACDecodingException("Invalid field in kerberos ticket");
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:48,代码来源:KerberosApRequest.java

示例6: CVCertificate

import org.bouncycastle.asn1.DERApplicationSpecific; //导入方法依赖的package包/类
public CVCertificate(byte[] in) throws IllegalArgumentException, IOException {
	ASN1StreamParser asn1Parser = new ASN1StreamParser(in);
	
	DERApplicationSpecific cvcert = (DERApplicationSpecific) asn1Parser.readObject();
	if (cvcert.getApplicationTag()!=0x21) throw new IllegalArgumentException("Can't find a CV Certificate");
	
	ASN1Sequence derCert= (ASN1Sequence)cvcert.getObject(BERTags.SEQUENCE); // Das CV Cerificate ist eine Sequence
	
	DERApplicationSpecific body = (DERApplicationSpecific) derCert.getObjectAt(0); //Das erste Objekt des Certificates ist der Cert-Body
	if (body.getApplicationTag()!=0x4E) throw new IllegalArgumentException("Can't find a Body in the CV Certificate");
	
	certBody = new CVCertBody(body);
	
	DERApplicationSpecific signature = (DERApplicationSpecific) derCert.getObjectAt(1); //Das zweite Objekt des Certificates ist die Signatur
	if (signature.getApplicationTag()!=0x37) throw new IllegalArgumentException("Can't find a Signature in the CV Certificate");

	certSignature = new CVCertSignature(signature.getContents());
	
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:20,代码来源:CVCertificate.java


注:本文中的org.bouncycastle.asn1.DERApplicationSpecific.getContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。