Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions core/core-awt/src/main/java/org/icepdf/core/SystemProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.icepdf.core;

import org.icepdf.core.util.Defs;

public final class SystemProperties {
//System properties
public static final String OS_NAME = Defs.sysProperty("os.name");
public static final String JAVA_HOME = Defs.sysProperty("java.home");
public static final String USER_NAME = Defs.sysProperty("user.name");

//ICEpdf-specifics
public static final boolean PRIVATE_PROPERTY_ENABLED = Defs.booleanProperty(
"org.icepdf.core.page.annotation.privateProperty.enabled", false);
public static final boolean USE_NFONT = Defs.sysPropertyBoolean("org.icepdf.core.useNFont", true);

private SystemProperties() {
}
}
21 changes: 8 additions & 13 deletions core/core-awt/src/main/java/org/icepdf/core/pobjects/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.core.pobjects;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.events.*;
import org.icepdf.core.io.SeekableInput;
import org.icepdf.core.pobjects.annotations.Annotation;
Expand Down Expand Up @@ -76,9 +77,6 @@ public class Page extends Dictionary {
*/
public static final float SELECTION_ALPHA = 0.3f;

public static boolean PRIVATE_PROPERTY_ENABLED = Defs.booleanProperty(
"org.icepdf.core.page.annotation.privateProperty.enabled", false);

// text selection colour
public static Color selectionColor;

Expand Down Expand Up @@ -206,8 +204,6 @@ public class Page extends Dictionary {
// page has default rotation value
private float pageRotation = 0;

private String userName = System.getProperty("user.name");

private int pageIndex;
private int imageCount;
private boolean pageInitialized;
Expand Down Expand Up @@ -341,24 +337,23 @@ else if (annotObj instanceof HashMap) { // HashMap lacks "Type"->"Annot" entry
if (ref != null && a != null) {
a.setPObjectReference(ref);
a.init();
}
if (PRIVATE_PROPERTY_ENABLED && a.getFlagPrivateContents()) {
// check to make sure we don't show an annotation if the username doesn't match the creator
if (a instanceof MarkupAnnotation) {
if (SystemProperties.PRIVATE_PROPERTY_ENABLED && a instanceof MarkupAnnotation && a.getFlagPrivateContents()) {
// check to make sure we don't show an annotation if the username doesn't match the creator
MarkupAnnotation markupAnnotation = (MarkupAnnotation) a;
String creator = markupAnnotation.getTitleText();
if (creator.equals(userName)) {
if (creator.equals(SystemProperties.USER_NAME)) {
annotations.add(a);
} else {
// other wise we skip it all together but make sure the popup is hidden.
if (markupAnnotation.getPopupAnnotation() != null) {
markupAnnotation.getPopupAnnotation().setOpen(false);
}
}

} else {
// add any found annotations to the vector.
annotations.add(a);
}
} else {
// add any found annotations to the vector.
annotations.add(a);
}
} catch (IllegalStateException e) {
logger.warning("Malformed annotation could not be initialized. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.tsp.TimeStampToken;
import org.icepdf.core.SystemProperties;
import org.icepdf.core.io.SeekableInput;
import org.icepdf.core.pobjects.Name;
import org.icepdf.core.pobjects.acroform.SignatureDictionary;
Expand Down Expand Up @@ -55,8 +56,8 @@ public abstract class AbstractPkcsValidator implements SignatureValidator {
private static String caCertLocation = "/lib/security/cacerts";

static {
String javaHome = Defs.sysProperty("java.home");
caCertLocation = Defs.sysProperty("org.icepdf.core.signatures.caCertPath", javaHome + caCertLocation);
caCertLocation = Defs.sysProperty("org.icepdf.core.signatures.caCertPath",
SystemProperties.JAVA_HOME + caCertLocation);
}

// data object descriptor codes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.core.pobjects.fonts;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Stream;
import org.icepdf.core.pobjects.fonts.ofont.OFont;
import org.icepdf.core.util.Defs;
Expand Down Expand Up @@ -42,14 +43,12 @@ public class FontFactory {

// dynamic property to switch between font engine and awt font substitution.
private static boolean awtFontSubstitution;
private static boolean useNFontIfAvailable;

static {
// turn on font file loading using awt, can cause the jvm to crash
// if the font file is corrupt.
awtFontLoading =
Defs.sysPropertyBoolean("org.icepdf.core.awtFontLoading", true);
useNFontIfAvailable = Defs.sysPropertyBoolean("org.icepdf.core.useNFont", true);
}

public static final int FONT_OPEN_TYPE = 5;
Expand Down Expand Up @@ -313,7 +312,7 @@ public static boolean foundFontEngine() {
// keep quiet
}

return foundNFont && !awtFontSubstitution && useNFontIfAvailable;
return foundNFont && !awtFontSubstitution && SystemProperties.USE_NFONT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.core.pobjects.fonts;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.util.Defs;
import org.icepdf.core.util.FontUtil;

Expand Down Expand Up @@ -136,7 +137,7 @@ public class FontManager {
* Java base font class, generally ${java.home}\lib\fonts. This is the base font directory that is used
* for searching for system fonts. If all else fails this should be the fall back directory.
*/
public static String JAVA_FONT_PATH = Defs.sysProperty("java.home") + "/lib/fonts";
public static String JAVA_FONT_PATH = SystemProperties.JAVA_HOME + "/lib/fonts";

/**
* Default search path for fonts on windows systems.
Expand Down Expand Up @@ -364,7 +365,7 @@ private synchronized void readSystemFonts(String[] extraFontPaths, boolean skipS
ArrayList<String> fontDirectories = new ArrayList<>();
// load the appropriate font set for the OS.
if (!skipSystemFonts) {
String operationSystem = System.getProperty("os.name");
String operationSystem = SystemProperties.OS_NAME;
if (operationSystem != null) {
operationSystem = operationSystem.toLowerCase();
if (operationSystem.contains("win")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.core.util.content;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Resources;
import org.icepdf.core.util.Defs;
import org.icepdf.core.util.Library;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class ContentParserFactory {
// check class bath for NFont library, and declare results.
try {
Class.forName(N_CONTENT_PARSER);
foundPro = Defs.sysPropertyBoolean("org.icepdf.core.useNFont", true);
foundPro = SystemProperties.USE_NFONT;
} catch (ClassNotFoundException e) {
logger.log(Level.FINE, "ICEpdf PRO was not found on the class path");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.icepdf.ri.common;

import org.icepdf.core.SecurityCallback;
import org.icepdf.core.SystemProperties;
import org.icepdf.core.exceptions.PDFException;
import org.icepdf.core.exceptions.PDFSecurityException;
import org.icepdf.core.io.SizeInputStream;
Expand Down Expand Up @@ -1876,11 +1877,12 @@ private void setAnnotationPrivacy(boolean isPublic) {
private void reflectAnnotationDefaultPrivacy() {
// check properties to get last state.
Preferences preferences = ViewerPropertiesManager.getInstance().getPreferences();
boolean annotationPrivacy = preferences.getBoolean(
ViewerPropertiesManager.PROPERTY_ANNOTATION_LAST_USED_PUBLIC_FLAG, true);
boolean annotationPrivacy = !SystemProperties.PRIVATE_PROPERTY_ENABLED ||
preferences.getBoolean(ViewerPropertiesManager.PROPERTY_ANNOTATION_LAST_USED_PUBLIC_FLAG, true);


// store the current state in the model and annotation tool handlers will pull from the current state.
viewModel.setAnnotationPrivacy(annotationPrivacy);
setAnnotationPrivacy(annotationPrivacy);

// set the default value of the combo box.
if (annotationPrivacyComboBox != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.pobjects.graphics.images.references.ImageReference;
import org.icepdf.core.pobjects.graphics.images.references.ImageReferenceFactory;
Expand Down Expand Up @@ -308,7 +309,7 @@ public class SwingViewBuilder {
private static boolean isDemo;

static {
isMacOs = Defs.sysProperty("os.name").contains("OS X");
isMacOs = SystemProperties.OS_NAME.contains("OS X");
// check for demo system property
isDemo = Defs.sysPropertyBoolean("org.icepdf.ri.viewer.demo", false);
}
Expand Down Expand Up @@ -1609,7 +1610,7 @@ public JToolBar buildAnnotationlToolBar() {
ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION_TEXT)) {
addToToolBar(toolbar, buildTextAnnotationToolButton(iconSize));
}
if (propertiesManager.checkAndStoreBooleanProperty(
if (SystemProperties.PRIVATE_PROPERTY_ENABLED && propertiesManager.checkAndStoreBooleanProperty(
ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION_PERMISSION)) {
addToToolBar(toolbar, buildAnnotationPermissionCombBox());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.AnnotationFactory;
Expand Down Expand Up @@ -188,7 +189,7 @@ public void mouseReleased(MouseEvent e) {

checkAndApplyPreferences();
annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);
annotation.setColor(lineColor);
annotation.setOpacity(defaultOpacity);
if (annotation.isFillColor() || useInternalColor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.AnnotationFactory;
Expand Down Expand Up @@ -124,7 +125,7 @@ public void createFreeTextAnnotation(int x, int y, boolean setSelectionTool) {
annotation.setFlag(Annotation.FLAG_PRIVATE_CONTENTS, !viewModel.getAnnotationPrivacy());

annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);
annotation.setContents("");

// apply store settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Name;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.Page;
Expand Down Expand Up @@ -176,7 +177,7 @@ public void createTextMarkupAnnotation(ArrayList<Shape> highlightBounds) {
// before assigning the default colour check to see if there is an entry in the properties manager
checkAndApplyPreferences();
annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);
annotation.setMarkupBounds(highlightBounds);
annotation.setMarkupPath(highlightPath);
annotation.setBBox(tBbox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.AnnotationFactory;
Expand Down Expand Up @@ -167,7 +168,7 @@ public void mouseReleased(MouseEvent e) {

checkAndApplyPreferences();
annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);
annotation.setColor(inkColor);
annotation.setBorderStyle(borderStyle);
annotation.setInkPath(tInkPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Name;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.annotations.Annotation;
Expand Down Expand Up @@ -200,7 +201,7 @@ public void mouseReleased(MouseEvent e) {
// setup the markup properties.
annotation.setContents(annotation.getSubType().toString());
annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);

// pass outline shapes and bounds to create the highlight shapes
annotation.setBBox(tBbox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.AnnotationFactory;
Expand Down Expand Up @@ -194,7 +195,7 @@ public void mouseReleased(MouseEvent e) {
ViewModel viewModel = documentViewController.getParentController().getViewModel();
annotation.setFlag(Annotation.FLAG_PRIVATE_CONTENTS, !viewModel.getAnnotationPrivacy());
annotation.setCreationDate(PDate.formatDateTime(new Date()));
annotation.setTitleText(System.getProperty("user.name"));
annotation.setTitleText(SystemProperties.USER_NAME);

annotation.setColor(lineColor);
annotation.setOpacity(defaultOpacity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.tools;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Name;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.PObject;
Expand Down Expand Up @@ -117,7 +118,7 @@ public static TextAnnotation createTextAnnotation(Library library, Rectangle bbo
Annotation.SUBTYPE_TEXT,
bbox);
textAnnotation.setCreationDate(PDate.formatDateTime(new Date()));
textAnnotation.setTitleText(System.getProperty("user.name"));
textAnnotation.setTitleText(SystemProperties.USER_NAME);
textAnnotation.setContents("");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;

import static org.icepdf.core.SystemProperties.PRIVATE_PROPERTY_ENABLED;

/**
* AnnotationCellRender takes care of building a tree node's appearance for annotation nodes. If an annotation type
* is not supported by the editing tools an icon for the note is set to null.
Expand Down Expand Up @@ -247,7 +249,7 @@ public Component getTreeCellRendererComponent(
setClosedIcon(new ImageIcon(Images.get("page.gif")));
setLeafIcon(new ImageIcon(Images.get("page.gif")));
}
if (MarkupAnnotationPanel.PRIVATE_PROPERTY_ENABLED && annotation != null) {
if (PRIVATE_PROPERTY_ENABLED && annotation != null) {
final ImageIcon privateIcon;
privateIcon = annotation.getFlagPrivateContents() ?
new ImageIcon(Images.get("lock_16.png")) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.ri.common.utility.annotation.markup;

import org.icepdf.core.SystemProperties;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.PDate;
import org.icepdf.core.pobjects.Page;
Expand All @@ -38,6 +39,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.icepdf.core.SystemProperties.PRIVATE_PROPERTY_ENABLED;

public class FindMarkupAnnotationTask extends AbstractTask<Void, Object> {

private static final Logger logger =
Expand Down Expand Up @@ -131,7 +134,7 @@ protected Void doInBackground() {
}
taskStatusMessage = loadingMessage.format(new Object[]{i + 1, pageCount});
taskProgress = i;
String userName = System.getProperty("user.name");
String userName = SystemProperties.USER_NAME;
Page page = currentDocument.getPageTree().getPage(i);
if (page != null) {
ArrayList<Reference> annotationReferences = page.getAnnotationReferences();
Expand Down Expand Up @@ -178,7 +181,7 @@ protected Void doInBackground() {
filter = true;
}
}
if (MarkupAnnotationPanel.PRIVATE_PROPERTY_ENABLED &&
if (PRIVATE_PROPERTY_ENABLED &&
filterVisibility != MarkupAnnotationPanel.FilterVisibilityColumn.ALL) {
if ((markupAnnotation.getFlagPrivateContents()
&& filterVisibility == MarkupAnnotationPanel.FilterVisibilityColumn.PUBLIC)
Expand Down
Loading