• 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

81.82
/jsign-core/src/main/java/net/jsign/asn1/authenticode/SpcLink.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.ASN1Choice;
20
import org.bouncycastle.asn1.ASN1IA5String;
21
import org.bouncycastle.asn1.ASN1Object;
22
import org.bouncycastle.asn1.ASN1Primitive;
23
import org.bouncycastle.asn1.ASN1TaggedObject;
24
import org.bouncycastle.asn1.BERTags;
25
import org.bouncycastle.asn1.DERIA5String;
26
import org.bouncycastle.asn1.DERTaggedObject;
27

28
/**
29
 * <pre>
30
 * SpcLink ::= CHOICE {
31
 *     url                     [0] IMPLICIT IA5STRING,
32
 *     moniker                 [1] IMPLICIT SpcSerializedObject,
33
 *     file                    [2] EXPLICIT SpcString
34
 * }
35
 * </pre>
36
 * 
37
 * @author Emmanuel Bourg
38
 * @since 1.0
39
 */
40
public class SpcLink extends ASN1Object implements ASN1Choice {
41

42
    private ASN1IA5String url;
43
    private SpcSerializedObject moniker;
44
    private SpcString file = new SpcString("");
1✔
45

46
    public SpcLink() {
1✔
47
    }
1✔
48

49
    public SpcLink(String url) {
1✔
50
        this.url = new DERIA5String(url);
1✔
51
    }
1✔
52

53
    public String getUrl() {
54
        return url != null ? url.getString() : null;
1✔
55
    }
56

57
    public SpcSerializedObject getMoniker() {
58
        return moniker;
×
59
    }
60

61
    public SpcString getFile() {
62
        return file;
1✔
63
    }
64

65
    @Override
66
    public ASN1Primitive toASN1Primitive() {
67
        if (url != null) {
1✔
68
            return new DERTaggedObject(false, 0, url);
1✔
69
        } else if (moniker != null) {
1✔
70
            return new DERTaggedObject(false, 1, moniker);
×
71
        } else {
72
            return new DERTaggedObject(true, 2, file);
1✔
73
        }        
74
    }
75

76
    public static SpcLink parse(ASN1TaggedObject taggedObject) {
77
        SpcLink link = new SpcLink();
1✔
78

79
        switch (taggedObject.getTagNo()) {
1✔
80
            case 0:
81
                link.url = DERIA5String.getInstance(taggedObject.getBaseUniversal(false, BERTags.IA5_STRING));
1✔
82
                break;
1✔
83
            case 1:
84
                link.moniker = SpcSerializedObject.parse(taggedObject.getBaseUniversal(false, BERTags.SEQUENCE));
×
85
                break;
×
86
            case 2:
87
                link.file = SpcString.parse(taggedObject.getExplicitBaseTagged());
1✔
88
                break;
89
        }
90

91
        return link;
1✔
92
    }
93
}
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