summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java/org/onap/cvc/csar/cc/sol004/r130206/Error.java
blob: 72b036f054de7e2e798be1df01ea064e2d6f8142 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
  Copyright 2020 Nokia
  <p>
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  <p>
  http://www.apache.org/licenses/LICENSE-2.0
  <p>
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 */

package org.onap.cvc.csar.cc.sol004.r130206;

import org.onap.cvc.csar.CSARArchive;

public class Error {

    private static final String EMPTY_STRING = "";

    public static class CSARErrorUnableToFindCertificate extends CSARArchive.CSARError {

        public CSARErrorUnableToFindCertificate() {
            super("0x4001");
            this.message = "Unable to find cert file!";
        }
    }

    public static class CSARErrorUnableToFindCms extends CSARArchive.CSARError {

        public CSARErrorUnableToFindCms() {
            super("0x4002");
            this.message = "Unable to find cms signature!";
        }
    }

    public static class CSARErrorUnableToLoadCms extends CSARArchive.CSARError {
        public CSARErrorUnableToLoadCms() {
            super("0x4002");
            this.message = "Unable to load cms signature!";
        }
    }

    public static class CSARErrorUnableToFindCsarContent extends CSARArchive.CSARError {

        public CSARErrorUnableToFindCsarContent() {
            super("0x4003");
            this.message = "Unable to find csar content!";
        }
    }

    public static class CSARErrorWrongHashCode extends CSARArchive.CSARError {

        public CSARErrorWrongHashCode(String path) {
            super("0x4004");
            this.message = String.format("Source '%s' has wrong hash!", path);
        }
    }

    public static class CSARErrorUnableToFindAlgorithm extends CSARArchive.CSARError {

        public CSARErrorUnableToFindAlgorithm(String path) {
            super("0x4005");
            this.message = String.format("Source '%s' has hash, but unable to find algorithm tag!", path);
        }
    }

    public static class CSARErrorUnableToFindSource extends CSARArchive.CSARError {

        public CSARErrorUnableToFindSource(String path) {
            super("0x4006");
            this.message = String.format("Unable to calculate digest - file missing: %s", path);
        }
    }

    public static class CSARErrorInvalidSignature extends CSARArchive.CSARError {

        public CSARErrorInvalidSignature() {
            super("0x4007");
            this.message = "Manifest file has invalid signature!";
            this.file = "";
        }
    }

    public static class CSARErrorContentMismatch extends CSARArchive.CSARError {

        public CSARErrorContentMismatch() {
            super("0x4008");
            this.message = "Mismatch between contents of non-mano-artifact-sets and source files of the package";
        }
    }

    public static class CSARErrorUnableToFindEntryCertificate extends CSARArchive.CSARError {

        public CSARErrorUnableToFindEntryCertificate() {
            super("0x4009");
            this.message = "Unable to find cert file defined by ETSI-Entry-Certificate!";
        }
    }

    public static class CSARErrorEntryCertificateIsDefinedDespiteTheCms extends CSARArchive.CSARError {

        public CSARErrorEntryCertificateIsDefinedDespiteTheCms() {
            super("0x4011");
            this.message = "ETSI-Entry-Certificate entry in Tosca.meta is defined despite the certificate is included in the signature container";
        }
    }

    public static class CSARErrorEntryCertificateIsPresentDespiteTheCms extends CSARArchive.CSARError {

        public CSARErrorEntryCertificateIsPresentDespiteTheCms() {
            super("0x4012");
            this.message = "ETSI-Entry-Certificate certificate present despite the certificate is included in the signature container";
        }
    }

    public static class CSARErrorRootCertificateIsPresentDespiteTheCms extends CSARArchive.CSARError {

        public CSARErrorRootCertificateIsPresentDespiteTheCms() {
            super("0x4013");
            this.message = "Certificate present in root catalog despite the certificate is included in the signature container";
        }
    }

    public static class CSARErrorRootCertificateIsPresentDespiteTheEtsiEntryCertificate extends CSARArchive.CSARError {

        public CSARErrorRootCertificateIsPresentDespiteTheEtsiEntryCertificate() {
            super("0x4013");
            this.message = "Certificate present in root catalog despite the TOSCA.meta file";
        }
    }

    public static class CSARErrorUnableToFindCertificateEntryInTosca extends CSARArchive.CSARError {

        public CSARErrorUnableToFindCertificateEntryInTosca() {
            super("0x4014");
            this.message = "Unable to find ETSI-Entry-Certificate in Tosca file";
        }
    }

    public static class CSARErrorUnableToFindArtifactCertificateTag extends CSARArchive.CSARError {

        public CSARErrorUnableToFindArtifactCertificateTag(String path) {
            super("0x4015");
            this.message = String.format("Source '%s' has signature tag, but unable to find certificate tag!", path);
        }
    }

    public static class CSARErrorUnableToFindArtifactSignatureTag extends CSARArchive.CSARError {

        public CSARErrorUnableToFindArtifactSignatureTag(String path) {
            super("0x4017");
            this.message = String.format("Source '%s' has certificate tag, but unable to find signature tag!", path);
        }
    }

    public static class CSARErrorUnableToFindArtifactSecurityFile extends CSARArchive.CSARError {
        public CSARErrorUnableToFindArtifactSecurityFile(String path, String signatureFile, String type) {
            super("0x4018");
            this.message = String.format(
                "Source '%s' has '%s' tag, pointing to non existing file!. Pointed file '%s'",
                path, type, signatureFile);
        }

    }

    public static class CSARErrorFailToLoadArtifactSignature extends CSARArchive.CSARError {

        public CSARErrorFailToLoadArtifactSignature(String path, String cms) {
            super("0x4019");
            this.message = String.format("Fail to load signature '%s', for source '%s'!", path, cms);
        }
    }

    public static class CSARErrorIncorrectArtifactSignature extends CSARArchive.CSARError {

        public CSARErrorIncorrectArtifactSignature(String path) {
            super("0x4020");
            this.message = String.format("Source '%s' has incorrect signature!", path);
        }
    }

    public static class CSARErrorWrongSecurityFileExtension extends CSARArchive.CSARError {

        public CSARErrorWrongSecurityFileExtension(String path, String[] expectedExtension, String type) {
            super("0x4021");
            this.message = String.format(
                "Source '%s' has '%s' file with wrong extension, expected extension: '%s'!",
                path, type, String.join(", ", expectedExtension)
            );
        }
    }

    public static class CSARErrorWrongSecurityFileLocation extends CSARArchive.CSARError {

        public CSARErrorWrongSecurityFileLocation(String path, String filePath, String type) {
            super("0x4022");
            this.message = String.format(
                "Source '%s' has '%s' file located in wrong directory, directory: '%s'." +
                    "Signature should be in same directory as source file!",
                path, type, filePath);
        }
    }

    public static class CSARErrorWrongSecurityFileName extends CSARArchive.CSARError {

        public CSARErrorWrongSecurityFileName(String path, String fileName, String type) {
            super("0x4023");
            this.message = String.format(
                "Source '%s' has '%s' file with wrong name, signature name: '%s'." +
                    "Signature should have same name as source file!",
                path, type, fileName);
        }
    }

    public static class CSARWarningNoSecurity extends CSARArchive.CSARErrorWarning {
        public CSARWarningNoSecurity() {
            super(EMPTY_STRING, EMPTY_STRING, -1, EMPTY_STRING);
            this.message = "Warning. Consider adding package integrity and authenticity assurance according to ETSI NFV-SOL 004 Security Option 1";
        }
    }
}