1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package com.ohos.hapsigntool.hap.entity; 17 18 /** 19 * Define class of hap signature block types 20 */ 21 public class SignatureBlockTypes { 22 /** 23 * type-value of hap signature block 24 */ 25 public static final char SIGNATURE_BLOCK = 0; 26 27 /** 28 * type-value of unsigned profile 29 */ 30 public static final char PROFILE_NOSIGNED_BLOCK = 1; 31 32 /** 33 * type-value of signed profile 34 */ 35 public static final char PROFILE_SIGNED_BLOCK = 2; 36 37 /** 38 * type-value of key rotation block 39 */ 40 public static final char KEY_ROTATION_BLOCK = 3; 41 42 /** 43 * Constructor of Method 44 */ SignatureBlockTypes()45 private SignatureBlockTypes() { 46 } 47 48 /** 49 * get profile block type by the flag of isSigned 50 * 51 * @param isSigned the flag whether profile is signed 52 * @return profile block type value 53 */ getProfileBlockTypes(String isSigned)54 public static char getProfileBlockTypes(String isSigned) { 55 if (isSigned != null && "0".equals(isSigned)) { 56 return PROFILE_NOSIGNED_BLOCK; 57 } 58 if (isSigned != null && "1".equals(isSigned)) { 59 return PROFILE_SIGNED_BLOCK; 60 } 61 return PROFILE_NOSIGNED_BLOCK; 62 } 63 }