Skip to content

Commit

Permalink
GH-79 revert PdfSecurityException change
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Corless committed Feb 3, 2023
1 parent 9829529 commit 6b64e7d
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* @since 1.0
*/
@SuppressWarnings("serial")
public class PdfSecurityException extends Exception {
public class PDFSecurityException extends Exception {
/**
* Constructs an instance of PDFException with the specified detail message.
*
* @param msg the detail message
*/
public PdfSecurityException(String msg) {
public PDFSecurityException(String msg) {
super(msg);
}
}
24 changes: 12 additions & 12 deletions core/core-awt/src/main/java/org/icepdf/core/pobjects/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import org.icepdf.core.SecurityCallback;
import org.icepdf.core.application.ProductInfo;
import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.acroform.FieldDictionary;
import org.icepdf.core.pobjects.acroform.InteractiveForm;
import org.icepdf.core.pobjects.annotations.AbstractWidgetAnnotation;
Expand Down Expand Up @@ -181,12 +181,12 @@ private String getDocumentCachedFilePath() {
* Load a PDF file from the given path and initiates the document's Catalog.
*
* @param filepath path of PDF document.
* @throws PdfSecurityException if a security provider cannot be found
* @throws PDFSecurityException if a security provider cannot be found
* or there is an error decrypting the file.
* @throws IOException if a problem setting up, or parsing the file.
*/
public void setFile(String filepath)
throws PdfSecurityException, IOException {
throws PDFSecurityException, IOException {
setDocumentOrigin(filepath);

File file = new File(filepath);
Expand All @@ -208,12 +208,12 @@ public void setFile(String filepath)
* be stored in memory.
*
* @param url location of file.
* @throws PdfSecurityException if a security provider can not be found
* @throws PDFSecurityException if a security provider can not be found
* or there is an error decrypting the file.
* @throws IOException if a problem downloading, setting up, or parsing the file.
*/
public void setUrl(URL url)
throws PdfSecurityException, IOException {
throws PDFSecurityException, IOException {
InputStream in = null;
try {
// make a connection
Expand All @@ -240,12 +240,12 @@ public void setUrl(URL url)
*
* @param inputStream input stream containing PDF data
* @param pathOrURL value assigned to document origin
* @throws PdfSecurityException if a security provider can not be found
* @throws PDFSecurityException if a security provider can not be found
* or there is an error decrypting the file.
* @throws IOException if a problem setting up, or parsing the SeekableInput.
*/
public void setInputStream(InputStream inputStream, String pathOrURL)
throws PdfSecurityException, IOException {
throws PDFSecurityException, IOException {
setDocumentOrigin(pathOrURL);

if (!isCachingEnabled) {
Expand Down Expand Up @@ -290,12 +290,12 @@ public void setInputStream(InputStream inputStream, String pathOrURL)
* @param offset the index into the byte array where the PDF data begins
* @param length the number of bytes in the byte array belonging to the PDF data
* @param pathOrURL value assigned to document origin
* @throws PdfSecurityException if a security provider can not be found
* @throws PDFSecurityException if a security provider can not be found
* or there is an error decrypting the file.
* @throws IOException if a problem setting up, or parsing the SeekableInput.
*/
public void setByteArray(byte[] data, int offset, int length, String pathOrURL)
throws PdfSecurityException, IOException { // security, state, io?
throws PDFSecurityException, IOException { // security, state, io?
setDocumentOrigin(pathOrURL);

if (!isCachingEnabled) {
Expand Down Expand Up @@ -336,11 +336,11 @@ public void setByteArray(byte[] data, int offset, int length, String pathOrURL)
* Sets the input stream of the PDF file to be rendered.
*
* @param input ByteBuffer containing PDF data stream
* @throws PdfSecurityException security error
* @throws PDFSecurityException security error
* @throws IOException io error during stream handling
*/
private void setInputStream(ByteBuffer input)
throws PdfSecurityException, IOException, IllegalStateException {
throws PDFSecurityException, IOException, IllegalStateException {
try {
// load the head
header = new Header();
Expand Down Expand Up @@ -394,7 +394,7 @@ private void setInputStream(ByteBuffer input)
// create new instance of state manager and add it to the library
stateManager = new StateManager(crossReferenceRoot);
library.setStateManager(stateManager);
} catch (PdfSecurityException | IOException e) {
} catch (PDFSecurityException | IOException e) {
dispose();
logger.log(Level.SEVERE, "Failed to load PDF Document.", e);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.icepdf.core.pobjects.security;

import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.DictionaryEntries;
import org.icepdf.core.pobjects.Reference;
import org.icepdf.core.util.Defs;
Expand Down Expand Up @@ -120,17 +120,17 @@ public void dispose() {
* @param library library of documents PDF objects
* @param encryptionDictionary encryption dictionary key values
* @param fileID fileID of PDF document
* @throws PdfSecurityException if the security provider could not be found
* @throws PDFSecurityException if the security provider could not be found
*/
public SecurityManager(Library library, DictionaryEntries encryptionDictionary,
List fileID)
throws PdfSecurityException {
throws PDFSecurityException {

// Check to make sure that if run under JDK 1.3 that the JCE libraries
// are installed as extra packages
if (!foundJCE) {
logger.log(Level.SEVERE, "Sun JCE support was not found on classpath");
throw new PdfSecurityException("Sun JCE Support Not Found");
throw new PDFSecurityException("Sun JCE Support Not Found");
}

// create dictionary for document
Expand All @@ -144,7 +144,7 @@ public SecurityManager(Library library, DictionaryEntries encryptionDictionary,
// initiate the handler
securityHandler.init();
} else {
throw new PdfSecurityException("Security Provider Not Found.");
throw new PDFSecurityException("Security Provider Not Found.");
}
}

Expand Down
16 changes: 8 additions & 8 deletions core/core-awt/src/main/java/org/icepdf/core/util/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.icepdf.core.util;

import org.icepdf.core.SecurityCallback;
import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.*;
import org.icepdf.core.pobjects.acroform.InteractiveForm;
import org.icepdf.core.pobjects.acroform.SignatureHandler;
Expand Down Expand Up @@ -216,9 +216,9 @@ public CrossReferenceRoot getCrossReferenceRoot() {
*
* @param documentTrailer document trailer
* @return true if created, false otherwise
* @throws PdfSecurityException if there is an issue finding encryption libraries.
* @throws PDFSecurityException if there is an issue finding encryption libraries.
*/
public boolean makeSecurityManager(PTrailer documentTrailer) throws PdfSecurityException {
public boolean makeSecurityManager(PTrailer documentTrailer) throws PDFSecurityException {
/*
Before a security manager can be created or needs to be created
we need the following
Expand Down Expand Up @@ -270,9 +270,9 @@ public boolean configurePermissions() {
* following method is used with the SecurityCallback to prompt a user for
* a password if needed.
*
* @throws PdfSecurityException error during authorization manager setup
* @throws PDFSecurityException error during authorization manager setup
*/
public void attemptAuthorizeSecurityManager(Document document, SecurityCallback securityCallback) throws PdfSecurityException {
public void attemptAuthorizeSecurityManager(Document document, SecurityCallback securityCallback) throws PDFSecurityException {
// check if pdf is password protected, by passing in black
// password
if (!securityManager.isAuthorized("")) {
Expand All @@ -289,10 +289,10 @@ public void attemptAuthorizeSecurityManager(Document document, SecurityCallback
if (securityCallback != null) {
password = securityCallback.requestPassword(document);
if (password == null) {
throw new PdfSecurityException("Encryption error");
throw new PDFSecurityException("Encryption error");
}
} else {
throw new PdfSecurityException("Encryption error");
throw new PDFSecurityException("Encryption error");
}

// Verify new password, proceed if authorized,
Expand All @@ -303,7 +303,7 @@ public void attemptAuthorizeSecurityManager(Document document, SecurityCallback
count++;
// after 3 tries throw an error.
if (count > 3) {
throw new PdfSecurityException("Encryption error");
throw new PDFSecurityException("Encryption error");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/


import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.PDimension;
import org.icepdf.core.pobjects.Page;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void capturePages(String filePath) {
System.out.println("Error parsing PDF document " + e);
} catch (ExecutionException e) {
System.out.println("Error parsing PDF document " + e);
} catch (PdfSecurityException ex) {
} catch (PDFSecurityException ex) {
System.out.println("Error encryption not supported " + ex);
} catch (FileNotFoundException ex) {
System.out.println("Error file not found " + ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.multi.GenericMultipleBarcodeReader;
import com.google.zxing.multi.MultipleBarcodeReader;
import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.util.GraphicsRenderingHints;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static void main(String[] args) {
}
}

public void findBarcodes(String filePath) throws IOException, PdfSecurityException,
public void findBarcodes(String filePath) throws IOException, PDFSecurityException,
InterruptedException, NotFoundException {

// open the document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.multi.GenericMultipleBarcodeReader;
import com.google.zxing.multi.MultipleBarcodeReader;
import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.util.GraphicsRenderingHints;
Expand Down Expand Up @@ -96,7 +96,7 @@ public static void main(String[] args) {
}
}

public void findBarcodes(String filePath) throws IOException, PdfSecurityException,
public void findBarcodes(String filePath) throws IOException, PDFSecurityException,
InterruptedException, NotFoundException {

// open the document.
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.pcorless.icepdf</groupId>
<artifactId>icepdf</artifactId>
<version>7.0.0</version>
<version>7.1.0-SNAPSHOT</version>
</parent>
<groupId>org.icepdf.examples</groupId>
<artifactId>examples</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* governing permissions and limitations under the License.
*/

import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.util.Defs;
import org.icepdf.ri.common.print.PrintHelper;
Expand Down Expand Up @@ -181,7 +181,7 @@ public static void main(String[] args) {
logger.log(Level.WARNING, "PDF file not found.", e);
} catch (IOException e) {
logger.log(Level.WARNING, "Error loading PDF file", e);
} catch (PdfSecurityException e) {
} catch (PDFSecurityException e) {
logger.log(Level.WARNING,
"PDF security exception, unspported encryption type.", e);
} catch (PrintException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.icepdf.ri.common;

import org.icepdf.core.SecurityCallback;
import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.io.SizeInputStream;
import org.icepdf.core.pobjects.*;
import org.icepdf.core.pobjects.actions.Action;
Expand Down Expand Up @@ -2469,10 +2469,10 @@ protected void refreshRecentFileMenuItem() {
*
* @param document document to set securityCallback on .
* @param securityCallback security callback for prompting users or owner passwords.
* @throws PdfSecurityException security exception likely incorrect user or owner password.
* @throws PDFSecurityException security exception likely incorrect user or owner password.
*/
protected void setupSecurityHandler(Document document, SecurityCallback securityCallback) throws
PdfSecurityException {
PDFSecurityException {
// create default security callback is user has not created one
if (securityCallback == null) {
document.setSecurityCallback(
Expand Down Expand Up @@ -2531,7 +2531,7 @@ public void openDocument(String pathname) {
setupSecurityHandler(document, documentViewController.getSecurityCallback());
document.setFile(pathname);
commonNewDocumentHandling(pathname);
} catch (PdfSecurityException e) {
} catch (PDFSecurityException e) {
org.icepdf.ri.util.Resources.showMessageDialog(
viewer,
JOptionPane.INFORMATION_MESSAGE,
Expand Down Expand Up @@ -2683,7 +2683,7 @@ protected void done() {
}
closeDocument();
document = null;
} catch (PdfSecurityException e) {
} catch (PDFSecurityException e) {
org.icepdf.ri.util.Resources.showMessageDialog(
viewer,
JOptionPane.INFORMATION_MESSAGE,
Expand Down Expand Up @@ -2771,7 +2771,7 @@ public void openDocument(InputStream inputStream, String description, String pat
document.setInputStream(inputStream, pathOrURL);

commonNewDocumentHandling(description);
} catch (PdfSecurityException e) {
} catch (PDFSecurityException e) {
org.icepdf.ri.util.Resources.showMessageDialog(
viewer,
JOptionPane.INFORMATION_MESSAGE,
Expand Down Expand Up @@ -2863,7 +2863,7 @@ public void openDocument(byte[] data, int offset, int length, String description
document.setByteArray(data, offset, length, pathOrURL);

commonNewDocumentHandling(description);
} catch (PdfSecurityException e) {
} catch (PDFSecurityException e) {
org.icepdf.ri.util.Resources.showMessageDialog(
viewer,
JOptionPane.INFORMATION_MESSAGE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.icepdf.ri.common.utility.attachment;

import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.*;
import org.icepdf.core.util.Library;
import org.icepdf.core.util.Utils;
Expand Down Expand Up @@ -193,7 +193,7 @@ public void mouseClicked(MouseEvent mouseEvent) {
WindowManager.getInstance().newWindow(embeddedDocument, fileName);
} catch (IOException e) {
logger.log(Level.WARNING, "Error opening PDF file stream " + fileName, e);
} catch( PdfSecurityException e) {
} catch( PDFSecurityException e) {
logger.log(Level.WARNING, "Error opening PDF security exception " + fileName, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.icepdf.ri.util.qa;

import org.icepdf.core.exceptions.PdfSecurityException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.pobjects.Document;
import org.icepdf.ri.util.FontPropertiesManager;

Expand All @@ -37,7 +37,7 @@ public int load(Path filePath) {
document = new Document();
document.setFile(filePath.toAbsolutePath().toString());
return document.getNumberOfPages();
} catch (PdfSecurityException | IOException e) {
} catch (PDFSecurityException | IOException e) {
e.printStackTrace();
}
return 0;
Expand Down

0 comments on commit 6b64e7d

Please sign in to comment.