java.security

Class CodeSource

Implemented Interfaces:
Serializable

public class CodeSource
extends Object
implements Serializable

This class represents a location from which code is loaded (as represented by a URL), and the list of certificates that are used to check the signatures of signed code loaded from this source.
Since:
1.1
See Also:
Serialized Form

Constructor Summary

CodeSource(URL location, Certificate[] certs)
This creates a new instance of CodeSource that loads code from the specified URL location and which uses the specified certificates for verifying signatures.

Method Summary

boolean
equals(Object obj)
This method tests the specified Object for equality with this object.
Certificate[]
getCertificates()
This method returns the list of digital certificates that can be used to verify the signatures of code loaded under this CodeSource.
URL
getLocation()
This method returns the URL specifying the location from which code will be loaded under this CodeSource.
int
hashCode()
This method returns a hash value for this object.
boolean
implies(CodeSource cs)
This method tests to see if a specified CodeSource is implied by this object.
String
toString()
This method returns a String that represents this object.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

CodeSource

public CodeSource(URL location,
                  Certificate[] certs)
This creates a new instance of CodeSource that loads code from the specified URL location and which uses the specified certificates for verifying signatures.
Parameters:
location - the location from which code will be loaded
certs - the list of certificates

Method Details

equals

public boolean equals(Object obj)
This method tests the specified Object for equality with this object. This will be true if and only if the locations are equal and the certificate sets are identical (ignoring order).
Overrides:
equals in interface Object
Parameters:
obj - the Object to test against
Returns:
true if the specified object is equal to this one

getCertificates

public final Certificate[] getCertificates()
This method returns the list of digital certificates that can be used to verify the signatures of code loaded under this CodeSource.
Returns:
the certifcate list for this CodeSource

getLocation

public final URL getLocation()
This method returns the URL specifying the location from which code will be loaded under this CodeSource.
Returns:
the code location for this CodeSource

hashCode

public int hashCode()
This method returns a hash value for this object.
Overrides:
hashCode in interface Object
Returns:
a hash value for this object

implies

public boolean implies(CodeSource cs)
This method tests to see if a specified CodeSource is implied by this object. Effectively, to meet this test, the specified object must have all the certifcates this object has (but may have more), and must have a location that is a subset of this object's. In order for this object to imply the specified object, the following must be true:
  1. codesource must not be null.
  2. If codesource has a certificate list, all of it's certificates must be present in the certificate list of this code source.
  3. If this object does not have a null location, then the following addtional tests must be passed.
    1. codesource must not have a null location.
    2. codesource's location must be equal to this object's location, or
      • codesource's location protocol, port, and ref (aka, anchor) must equal this objects
      • codesource's location host must imply this object's location host, as determined by contructing SocketPermission objects from each with no action list and using that classes's implies method
      • If this object's location file ends with a '/', then the specified object's location file must start with this object's location file. Otherwise, the specified object's location file must start with this object's location file with the '/' character appended to it.

      For example, each of these locations imply the location "http://java.sun.com/classes/foo.jar":

       http:
       http://*.sun.com/classes/*
       http://java.sun.com/classes/-
       http://java.sun.com/classes/foo.jar
       

      Note that the code source with null location and null certificates implies all other code sources.

      Parameters:
      cs - the CodeSource to test against this object
      Returns:
      true if this specified CodeSource is implied

      toString

      public String toString()
      This method returns a String that represents this object. The result is in the format "(" + getLocation() followed by a space separated list of certificates (or "<no certificates>"), followed by ")".
      Overrides:
      toString in interface Object
      Returns:
      a String for this object

      CodeSource.java -- Code location and certifcates Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.