API java : CodeSource


java.security
Class CodeSource

java.lang.Object
  extended by java.security.CodeSource
All Implemented Interfaces:
Serializable

public class CodeSource
extends Object
implements Serializable

This class extends the concept of a codebase to encapsulate not only the location (URL) but also the certificate chains that were used to verify signed code originating from that location.

See Also:
Serialized Form

Constructor Summary
CodeSource(URL url, Certificate[] certs)
          Constructs a CodeSource and associates it with the specified location and set of certificates.
CodeSource(URL url, CodeSigner[] signers)
          Constructs a CodeSource and associates it with the specified location and set of code signers.
 
Method Summary
 boolean equals(Object obj)
          Tests for equality between the specified object and this object.
 Certificate[] getCertificates()
          Returns the certificates associated with this CodeSource.
 CodeSigner[] getCodeSigners()
          Returns the code signers associated with this CodeSource.
 URL getLocation()
          Returns the location associated with this CodeSource.
 int hashCode()
          Returns the hash code value for this object.
 boolean implies(CodeSource codesource)
          Returns true if this CodeSource object "implies" the specified CodeSource.
 String toString()
          Returns a string describing this CodeSource, telling its URL and certificates.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodeSource

public CodeSource(URL url,
                  Certificate[] certs)
Constructs a CodeSource and associates it with the specified location and set of certificates.

Parameters:
url - the location (URL).
certs - the certificate(s). It may be null. The contents of the array are copied to protect against subsequent modification.

CodeSource

public CodeSource(URL url,
                  CodeSigner[] signers)
Constructs a CodeSource and associates it with the specified location and set of code signers.

Parameters:
url - the location (URL).
signers - the code signers. It may be null. The contents of the array are copied to protect against subsequent modification.
Since:
1.5
Method Detail

hashCode

public int hashCode()
Returns the hash code value for this object.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
Tests for equality between the specified object and this object. Two CodeSource objects are considered equal if their locations are of identical value and if their signer certificate chains are of identical value. It is not required that the certificate chains be in the same order.

Overrides:
equals in class Object
Parameters:
obj - the object to test for equality with this object.
Returns:
true if the objects are considered equal, false otherwise.
See Also:
Object.hashCode(), Hashtable

getLocation

public final URL getLocation()
Returns the location associated with this CodeSource.

Returns:
the location (URL).

getCertificates

public final Certificate[] getCertificates()
Returns the certificates associated with this CodeSource.

If this CodeSource object was created using the CodeSource(URL url, CodeSigner[] signers) constructor then its certificate chains are extracted and used to create an array of Certificate objects. Each signer certificate is followed by its supporting certificate chain (which may be empty). Each signer certificate and its supporting certificate chain is ordered bottom-to-top (i.e., with the signer certificate first and the (root) certificate authority last).

Returns:
A copy of the certificates array, or null if there is none.

getCodeSigners

public final CodeSigner[] getCodeSigners()
Returns the code signers associated with this CodeSource.

If this CodeSource object was created using the CodeSource(URL url, Certificate[] certs) constructor then its certificate chains are extracted and used to create an array of CodeSigner objects. Note that only X.509 certificates are examined - all other certificate types are ignored.

Returns:
A copy of the code signer array, or null if there is none.
Since:
1.5

implies

public boolean implies(CodeSource codesource)
Returns true if this CodeSource object "implies" the specified CodeSource.

More specifically, this method makes the following checks, in order. If any fail, it returns false. If they all succeed, it returns true.

  1. codesource must not be null.
  2. If this object's certificates are not null, then all of this object's certificates must be present in codesource's certificates.
  3. If this object's location (getLocation()) is not null, then the following checks are made against this object's location and codesource's:

    1. codesource's location must not be null.
    2. If this object's location equals codesource's location, then return true.
    3. This object's protocol (getLocation().getProtocol()) must be equal to codesource's protocol.
    4. If this object's host (getLocation().getHost()) is not null, then the SocketPermission constructed with this object's host must imply the SocketPermission constructed with codesource's host.
    5. If this object's port (getLocation().getPort()) is not equal to -1 (that is, if a port is specified), it must equal codesource's port.
    6. If this object's file (getLocation().getFile()) doesn't equal codesource's file, then the following checks are made: If this object's file ends with "/-", then codesource's file must start with this object's file (exclusive the trailing "-"). If this object's file ends with a "/*", then codesource's file must start with this object's file and must not have any further "/" separators. If this object's file doesn't end with a "/", then codesource's file must match this object's file with a '/' appended.
    7. If this object's reference (getLocation().getRef()) is not null, it must equal codesource's reference.

For example, the codesource objects with the following locations and null certificates all imply the codesource with the location "http://java.sun.com/classes/foo.jar" and null certificates:

     http:
     http://*.sun.com/classes/*
     http://java.sun.com/classes/-
     http://java.sun.com/classes/foo.jar
 
Note that if this CodeSource has a null location and a null certificate chain, then it implies every other CodeSource.

Parameters:
codesource - CodeSource to compare against.
Returns:
true if the specified codesource is implied by this codesource, false if not.

toString

public String toString()
Returns a string describing this CodeSource, telling its URL and certificates.

Overrides:
toString in class Object
Returns:
information about this CodeSource.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

6 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-1580
Document créé le 29/08/06 20:59, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/security/CodeSource.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,45 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Le bonheur n’est pas un gros diamant, c’est une mosaïque de petites pierres harmonieusement rangées.

Alphonse Karr
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 21:52, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)