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