-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Service Provider Interface for the Signable implementations
- Loading branch information
Showing
16 changed files
with
607 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
jsign-core/src/main/java/net/jsign/spi/APPXSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.appx.APPXFile; | ||
|
||
/** | ||
* {@link SignableProvider} for APPX files. | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices(SignableProvider.class) | ||
public class APPXSignableProvider extends ExtensionBasedSignableProvider { | ||
|
||
public APPXSignableProvider() { | ||
super("msix", "msixbundle", "appx", "appxbundle"); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new APPXFile(file); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jsign-core/src/main/java/net/jsign/spi/CatalogSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.cat.CatalogFile; | ||
|
||
/** | ||
* {@link SignableProvider} for Catalog files. | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices | ||
public class CatalogSignableProvider implements SignableProvider { | ||
|
||
@Override | ||
public boolean isSupported(File file) { | ||
return CatalogFile.isCatalogFile(file); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new CatalogFile(file); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
jsign-core/src/main/java/net/jsign/spi/ExtensionBasedSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* {@link SignableProvider} for files matching a specific extension. | ||
* | ||
* @since 6.1 | ||
*/ | ||
public abstract class ExtensionBasedSignableProvider implements SignableProvider { | ||
|
||
private final Set<String> extensions; | ||
|
||
public ExtensionBasedSignableProvider(String... extensions) { | ||
this.extensions = new HashSet<>(Arrays.asList(extensions)); | ||
} | ||
|
||
@Override | ||
public boolean isSupported(File file) { | ||
String extension = file.getName().substring(file.getName().lastIndexOf('.') + 1); | ||
return extensions.contains(extension.toLowerCase()); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
jsign-core/src/main/java/net/jsign/spi/JScriptSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.script.JScript; | ||
|
||
/** | ||
* {@link SignableProvider} for JScript files. | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices(SignableProvider.class) | ||
public class JScriptSignableProvider extends ExtensionBasedSignableProvider { | ||
|
||
public JScriptSignableProvider() { | ||
super("js", "jse"); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new JScript(file, encoding); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jsign-core/src/main/java/net/jsign/spi/MSCabinetSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.mscab.MSCabinetFile; | ||
|
||
/** | ||
* {@link SignableProvider} for Microsoft Cabinet files | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices | ||
public class MSCabinetSignableProvider implements SignableProvider { | ||
|
||
@Override | ||
public boolean isSupported(File file) throws IOException { | ||
return MSCabinetFile.isMSCabinetFile(file); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new MSCabinetFile(file); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jsign-core/src/main/java/net/jsign/spi/MSISignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.msi.MSIFile; | ||
|
||
/** | ||
* {@link SignableProvider} for MSI files. | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices | ||
public class MSISignableProvider implements SignableProvider { | ||
|
||
@Override | ||
public boolean isSupported(File file) throws IOException { | ||
return MSIFile.isMSIFile(file); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new MSIFile(file); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jsign-core/src/main/java/net/jsign/spi/NAVXSignableProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2024 Emmanuel Bourg | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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 net.jsign.spi; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
import org.kohsuke.MetaInfServices; | ||
|
||
import net.jsign.Signable; | ||
import net.jsign.navx.NAVXFile; | ||
|
||
/** | ||
* {@link SignableProvider} for NAVX files. | ||
* | ||
* @since 6.1 | ||
*/ | ||
@MetaInfServices | ||
public class NAVXSignableProvider implements SignableProvider { | ||
|
||
@Override | ||
public boolean isSupported(File file) throws IOException { | ||
return NAVXFile.isNAVXFile(file); | ||
} | ||
|
||
@Override | ||
public Signable create(File file, Charset encoding) throws IOException { | ||
return new NAVXFile(file); | ||
} | ||
} |
Oops, something went wrong.