|
jPod PDF library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.intarsys.pdf.crypt.AbstractSecurityHandler
de.intarsys.pdf.crypt.StandardSecurityHandler
public abstract class StandardSecurityHandler
The standard security handler as specified in the PDF reference.
Be aware that there is no internal check for permissions. The reason is simply that on the API level there's nothing that really keeps you from manipulating a PDF document.
On one hand, changing simply the security relevant parameters won't work as the crypt key is cached. It is necessary to create and associate a new security handler. Here we could check and abandon the request if no owner permissions are set. But this is no real problem, as you could read the complete document with user permissions and as such simply copy the root.
So we didn't even care as this would pollute the implementation while providing only superficial benefits.
Field Summary | |
---|---|
static int |
DEFAULT_ACCESS_PERMISSIONS
The default value for the access permission flags. |
static COSName |
DK_EncryptMetadata
|
static COSName |
DK_O
|
static COSName |
DK_P
|
static COSName |
DK_R
|
static COSName |
DK_U
|
Constructor Summary | |
---|---|
StandardSecurityHandler()
|
Method Summary | |
---|---|
void |
apply()
|
void |
attach(STDocument doc)
Associate this ISecurityHandler with a STDocument . |
void |
authenticate()
Perform an authentication. |
abstract boolean |
authenticateOwner(byte[] owner)
|
abstract boolean |
authenticateUser(byte[] user)
|
int |
basicGetPermissionFlags()
|
void |
basicSetPermissionFlags(int newValue)
|
byte[] |
decrypt(COSObjectKey key,
byte[] bytes)
Decrypt any bytes in the context of COSObject referenced by the provided key. |
void |
detach(STDocument doc)
Disassociate this ISecurityHandler from STDocument . |
byte[] |
encrypt(COSObjectKey key,
byte[] bytes)
Encrypt any bytes in the context of COSObject referenced by the provided key. |
IAccessPermissions |
getAccessPermissions()
The access permissions active for the document. |
IAuthenticationHandler |
getAuthenticationHandler()
|
byte[] |
getCryptKey()
The crypt key created by this ISecurityHandler . |
PermissionFlags |
getPermissionFlags()
|
abstract int |
getRevision()
|
void |
initialize(STDocument doc)
Initialize this ISecurityHandler with a STDocument . |
boolean |
isEncryptMetadata()
|
void |
setAuthenticationHandler(IAuthenticationHandler authenticationHandler)
|
void |
setEncryptMetadata(boolean value)
|
void |
setOwnerPassword(byte[] pOwner)
Set new owner password for the ISecurityHandler . |
void |
setUserPassword(byte[] pUser)
Set new user password for the ISecurityHandler . |
Methods inherited from class de.intarsys.pdf.crypt.AbstractSecurityHandler |
---|
cosGetEncryption, getEncryption, stGetDoc |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_ACCESS_PERMISSIONS
Everything is allowed, only the reserved flags are zero.
public static final COSName DK_EncryptMetadata
public static final COSName DK_O
public static final COSName DK_P
public static final COSName DK_R
public static final COSName DK_U
Constructor Detail |
---|
public StandardSecurityHandler()
Method Detail |
---|
public void apply() throws COSSecurityException
COSSecurityException
public void attach(STDocument doc)
ISecurityHandler
ISecurityHandler
with a STDocument
.
The ISecurityHandler
should add all its private information to
the document structure, in particular to the /Encrypt dictionary.
attach
in interface ISecurityHandler
attach
in class AbstractSecurityHandler
public final void authenticate() throws COSSecurityException
ISecurityHandler
authenticate
in interface ISecurityHandler
COSSecurityException
public abstract boolean authenticateOwner(byte[] owner) throws COSSecurityException
COSSecurityException
public abstract boolean authenticateUser(byte[] user) throws COSSecurityException
COSSecurityException
public int basicGetPermissionFlags()
public void basicSetPermissionFlags(int newValue) throws COSSecurityException
COSSecurityException
public byte[] decrypt(COSObjectKey key, byte[] bytes) throws COSSecurityException
ICryptHandler
decrypt
in interface ICryptHandler
key
- of the object which provides the contextbytes
- to decrypt
COSSecurityException
public void detach(STDocument doc) throws COSSecurityException
ISecurityHandler
ISecurityHandler
from STDocument
.
The ISecurityHandler
should remove all its private information
from the document structure, in particular from the /Encrypt dictionary.
detach
in interface ISecurityHandler
detach
in class AbstractSecurityHandler
COSSecurityException
public byte[] encrypt(COSObjectKey key, byte[] bytes) throws COSSecurityException
ICryptHandler
encrypt
in interface ICryptHandler
key
- of the object which provides the contextbytes
- to decrypt
COSSecurityException
public final IAccessPermissions getAccessPermissions()
IAccessPermissionsSupport
The return value of this method not only depends on the permissions
encoded by the ISecurityHandler
, but also on the outcome of the
authentication.
A negative authentication should result in no permissions, a positive authentication should result either in the encoded permissions for a user authentication or in all permissions for a successful owner authentication.
getAccessPermissions
in interface IAccessPermissionsSupport
public IAuthenticationHandler getAuthenticationHandler()
public byte[] getCryptKey()
ISecurityHandler
ISecurityHandler
. The crypt key is
used by the ISystemSecurityHandler
(or the ICryptHandler
to initialize its cryptographic functions.
The crypt key is valid after the authentication.
getCryptKey
in interface ISecurityHandler
ISecurityHandler
.public PermissionFlags getPermissionFlags()
public abstract int getRevision()
public void initialize(STDocument doc)
ISecurityHandler
ISecurityHandler
with a STDocument
.
The ISecurityHandler
should initialize its state from the
information in the document structure, in particular from the /Encrypt
dictionary.
initialize
in interface ISecurityHandler
initialize
in class AbstractSecurityHandler
public boolean isEncryptMetadata()
public void setAuthenticationHandler(IAuthenticationHandler authenticationHandler)
public void setEncryptMetadata(boolean value)
public void setOwnerPassword(byte[] pOwner) throws COSSecurityException
ISecurityHandler
.
owner
- The new owner password.
COSSecurityException
public void setUserPassword(byte[] pUser) throws COSSecurityException
ISecurityHandler
.
user
- The new user password
COSSecurityException
|
jPod PDF library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |