• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ebourg / jsign / #418

23 Jul 2026 12:50PM UTC coverage: 81.28% (+0.5%) from 80.829%
#418

push

ebourg
CodeQL workflow

5397 of 6640 relevant lines covered (81.28%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/jsign-core/src/main/java/net/jsign/asn1/authenticode/SpcAttributeTypeAndOptionalValue.java
1
/*
2
 * Copyright 2012 Emmanuel Bourg
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package net.jsign.asn1.authenticode;
18

19
import org.bouncycastle.asn1.ASN1Encodable;
20
import org.bouncycastle.asn1.ASN1EncodableVector;
21
import org.bouncycastle.asn1.ASN1Object;
22
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
23
import org.bouncycastle.asn1.ASN1Primitive;
24
import org.bouncycastle.asn1.ASN1Sequence;
25
import org.bouncycastle.asn1.BERSequence;
26

27
/**
28
 * <pre>
29
 * SpcAttributeTypeAndOptionalValue ::= SEQUENCE {
30
 *     type                    OBJECT IDENTIFIER,
31
 *     value                   ANY DEFINED BY type OPTIONAL
32
 * }
33
 * </pre>
34
 * 
35
 * @author Emmanuel Bourg
36
 * @since 1.0
37
 */
38
public class SpcAttributeTypeAndOptionalValue extends ASN1Object {
39

40
    private final ASN1ObjectIdentifier type;
41
    private final ASN1Encodable value;
42

43
    public SpcAttributeTypeAndOptionalValue(ASN1ObjectIdentifier type, ASN1Encodable value) {
1✔
44
        this.type = type;
1✔
45
        this.value = value;
1✔
46
    }
1✔
47

48
    public ASN1ObjectIdentifier getType() {
49
        return type;
1✔
50
    }
51

52
    public ASN1Encodable getValue() {
53
        return value;
1✔
54
    }
55

56
    public ASN1Primitive toASN1Primitive() {
57
        ASN1EncodableVector v = new ASN1EncodableVector();
1✔
58
        v.add(type);
1✔
59
        if (value != null) {
1✔
60
            v.add(value);
1✔
61
        }
62
        
63
        return new BERSequence(v);
1✔
64
    }
65

66
    public static SpcAttributeTypeAndOptionalValue parse(ASN1Sequence sequence) {
67
        ASN1ObjectIdentifier type = ASN1ObjectIdentifier.getInstance(sequence.getObjectAt(0));
1✔
68
        ASN1Encodable value = null;
1✔
69
        if (sequence.size() > 1) {
1✔
70
            if (type.equals(AuthenticodeObjectIdentifiers.SPC_SIPINFO_OBJID)) {
1✔
71
                value = SpcSipInfo.parse(sequence.getObjectAt(1));
1✔
72
            } else if (type.equals(AuthenticodeObjectIdentifiers.SPC_CAB_DATA_OBJID)
1✔
73
                    || type.equals(AuthenticodeObjectIdentifiers.SPC_PE_IMAGE_DATA_OBJID)) {
1✔
74
                value = SpcPeImageData.parse(sequence.getObjectAt(1));
1✔
75
            } else {
76
                value = sequence.getObjectAt(1);
×
77
            }
78
        }
79
        
80
        return new SpcAttributeTypeAndOptionalValue(type, value);
1✔
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc