|
|
||||||||||||||||
Interface IEncodablePermissionpublic interface IEncodablePermission { // Methods boolean decode(String tag, InputStream data); boolean encode(String tag, OutputStream data); String mapFormat(String format); String[] supportedFormats(); } This interface provides methods that allow permissions to represent their internal state in any desired format. For example, a permission can encode itself into an arbitrary binary format or a textual format. The contract with the caller of the IEncodablePermission interface can be described in the following way.
The tag is defined by a class that implements the IEncodablePermission interface and is meaningful only to that class. It is not meaningful to any other IEncodablePermission class. The tag allows the object to do version control and to handle multiple types of encodings. The tag is an arbitrary string that the permission class decides on. It is likely that the string will contain some type of version information; its form is determined by the permission class. This interface is useful for developers who write Java packages that are digitally signed. When the package is installed on a client's computer, the user gets a dialog box asking for permission to access certain resources. The permission needs to be attached to the digital signature so that the security system can determine what permissions are needed. The developer should create a permission class that implements IEncodablePermission. The signcode tool takes the name of the permission class, creates an instance of it, and then calls the encode method of the permission class to cause the instance to encode itself. This encoding is stored inside the digital signature, which is then attached to a package. The security system within the Microsoft Win32 VM for Java gets the encoding from the signature and creates an instance of the permission class. It then calls the class's decode method, passing in the tag that was used at the time of signing (the tag is part of the signature's encoding). Because signatures are static, and because the permission class can be located in any package, the current implementation of the permission class can determine what version of the IEncodablePermission class was encoded with the tag. For example, suppose you created a package of classes that manipulate SQL databases. This package might contain applets that access portions of the database, based on a table name. You could create a database permission class called DBPermission that stores the name of an SQL table. Then you would sign each applet with the DBPermission, asking for a specific table. The DBPermission class would then be distributed with your package, and the applets are sent to Web sites that are accessed by users. You might, at some point, enhance your package by adding the ability to restrict access to particular rows and columns of a database. You would then update your permission class to keep track of the rows and columns that can be accessed. New applets would be signed with the new permission. However, the old applets might still be in use on the Internet, signed with the old permission. The tag provides a way to identify the version used to encode a permission class. If permissions that implement the IEncodablePermission interface are inserted into a PermissionDataSet object so that they can be used in digital signatures, the signing tool will find out whether the permissions support ASN1 format. If ASN1 is not supported, the class's default encoding will be used. Methodsdecodeboolean decode(String tag, InputStream data); encodeboolean encode(String tag, OutputStream data); mapFormatString mapFormat(String format); supportedFormatsString[] supportedFormats();
|
© 1998 Microsoft Corporation. All rights reserved. Terms of use. |