
javax.tv.media.MediaSelectPermission Maven / Gradle / Ivy
The newest version!
/*
* @(#)MediaSelectPermission.java 1.8 00/08/06
*
* Copyright 1998-2000 by Sun Microsystems, Inc.,
* 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information
* of Sun Microsystems, Inc. ("Confidential Information"). You
* shall not disclose such Confidential Information and shall use
* it only in accordance with the terms of the license agreement
* you entered into with Sun.
*/
package javax.tv.media;
import java.security.Permission;
import javax.tv.locator.Locator;
import java.io.Serializable;
/**
* This class represents permission to select, via a
* MediaSelectControl
, the content that a JMF Player
* presents. A caller might have permission to select content
* referenced by some locators, but not others.
*
* @version 1.8, 08/06/00
**/
public final class MediaSelectPermission extends Permission implements Serializable {
String actions = "";
/**
* Creates a new MediaSelectPermission
object for the
* specified Locator
.
*
* @param locator The locator for which to create the permission.
* A value of null
indicates permission for all
* locators.
**/
public MediaSelectPermission(Locator locator) {
super(locator == null ? "*" : locator.toExternalForm());
}
/**
* Creates a new MediaSelectPermission
object for a
* Locator
with the given external form. The actions
* string is currently unused and should be null
.
* This constructor is used by the Policy
class to
* instantiate new Permission
objects.
*
* @param locator The external form of the locator. The string
* "*" indicates all locators.
*
* @param actions Should be null
.
**/
public MediaSelectPermission(String locator, String actions) {
super(locator);
if (locator == null) {
throw new NullPointerException("Locator is Null");
}
// action string is currently unused
// this.actions = actions;
// if (actions == null) {
// throw new NullPointerException("actions is null");
}
/**
* Checks if this MediaSelectPermission
"implies" the
* specified Permission
.
*
* More specificially, this method returns true if:
*
* - p is an instanceof MediaSelectPermission, and
*
- p's locator's external form is matches this object's locator
* string, or this object's locator string is "*".
*
*
* @param p The Permission
to check against.
*
* @return true
if the specified
* Permission
is implied by this object;
* false
otherwise.
**/
public boolean implies(Permission p) {
if (p == null) {
throw new NullPointerException();
}
// Implementation is highly dependant on organization of locator
if (!(p instanceof MediaSelectPermission))
return false;
MediaSelectPermission msp = (MediaSelectPermission)p;
//TBD: Use locator.equals() in the future?
boolean isName = ( (getName().equals(msp.getName()))
|| (getName().equals("*")));
boolean isAction = ( (getActions().equals(msp.getActions()))
|| (getActions().equals("*")));
return ( isName && isAction );
}
/**
* Tests two MediaSelectPermission objects for equality. This
* method tests that other
is of type
* MediaSelectPermission
, and has the same
* Locator
as this object.
*
* @param other The object to test for equality.
*
* @return true
if other
is a
* MediaSelectPermission
, and has the same
* Locator
as this MediaSelectPermission
.
**/
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (! (other instanceof MediaSelectPermission)) {
return false;
}
MediaSelectPermission that = (MediaSelectPermission) other;
return ((getName().equals(that.getName())) &&
(getActions().equals(that.getActions())));
}
/**
* Returns the hash code value for this object.
*
* @return The hash code value for this object.
*/
public int hashCode() {
//return (getName().hashCode() ^ getAction().hashCode());
return getName().hashCode();
}
/**
* Reports the canonical string representation of the actions.
* This is currently the empty string "", since there are no
* actions for a MediaSelectPermission
.
*
* @return The empty string "". */
public String getActions()
{
return this.actions;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy