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 Windows script file (<code>.wsf</code>). 030 * 031 * @author Emmanuel Bourg 032 * @since 3.0 033 */ 034public class WindowsScript extends WSHScript { 035 036 /** 037 * Create a Windows script. 038 * The encoding is assumed to be UTF-8. 039 */ 040 public WindowsScript() { 041 super(); 042 } 043 044 /** 045 * Create a Windows 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 Windows script 049 * @throws IOException if an I/O error occurs 050 */ 051 public WindowsScript(File file) throws IOException { 052 super(file); 053 } 054 055 /** 056 * Create a Windows script from the specified file and load its content. 057 * 058 * @param file the Windows 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 WindowsScript(File file, Charset encoding) throws IOException { 063 super(file, encoding); 064 } 065 066 @Override 067 String getSignatureStart() { 068 return "<signature>"; 069 } 070 071 @Override 072 String getSignatureEnd() { 073 return "</signature>"; 074 } 075 076 @Override 077 String getLineCommentStart() { 078 return "** SIG ** "; 079 } 080 081 @Override 082 String getLineCommentEnd() { 083 return ""; 084 } 085 086 @Override 087 protected int getSignatureInsertionPoint(String content) { 088 return content.lastIndexOf("</job>"); 089 } 090 091 @Override 092 ASN1Object getSpcSipInfo() { 093 return new SpcSipInfo(1, new SpcUuid("7005611A-CE38-D411-A2A3-00104BD35090")); 094 } 095}