001/** 002 * Copyright 2019 Björn Kautler 003 * Copyright 2019 Emmanuel Bourg 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.jsign.script; 019 020import java.io.File; 021import java.io.IOException; 022import java.nio.charset.Charset; 023 024import org.bouncycastle.asn1.ASN1Object; 025 026import net.jsign.asn1.authenticode.SpcSipInfo; 027import net.jsign.asn1.authenticode.SpcUuid; 028 029/** 030 * A PowerShell script. 031 * 032 * @author Björn Kautler 033 * @since 3.0 034 */ 035public class PowerShellScript extends SignableScript { 036 037 /** 038 * Create a PowerShell script. 039 * The encoding is assumed to be UTF-8. 040 */ 041 public PowerShellScript() { 042 super(); 043 } 044 045 /** 046 * Create a PowerShell script from the specified file and load its content. 047 * If the file has no byte order mark the encoding is assumed to be UTF-8. 048 * 049 * @param file the PowerShell script 050 * @throws IOException if an I/O error occurs 051 */ 052 public PowerShellScript(File file) throws IOException { 053 super(file); 054 } 055 056 /** 057 * Create a PowerShell script from the specified file and load its content. 058 * 059 * @param file the PowerShell script 060 * @param encoding the encoding of the script if there is no byte order mark (if null UTF-8 is used by default) 061 * @throws IOException if an I/O error occurs 062 */ 063 public PowerShellScript(File file, Charset encoding) throws IOException { 064 super(file, encoding); 065 } 066 067 @Override 068 boolean isByteOrderMarkSigned() { 069 return true; 070 } 071 072 @Override 073 String getSignatureStart() { 074 return "# SIG # Begin signature block"; 075 } 076 077 @Override 078 String getSignatureEnd() { 079 return "# SIG # End signature block"; 080 } 081 082 @Override 083 String getLineCommentStart() { 084 return "# "; 085 } 086 087 @Override 088 String getLineCommentEnd() { 089 return ""; 090 } 091 092 @Override 093 ASN1Object getSpcSipInfo() { 094 return new SpcSipInfo(65536, new SpcUuid("1FCC3B60-594B-084E-B724-D2C6297EF351")); 095 } 096}