libbluray | branch: master | hpi1 <h...@anonymous.org> | Wed Apr 13 12:07:04 2016 +0300| [58223b2a6513e6e780eb75780baae91bc6fa2bc0] | committer: hpi1
javax.tv.service: fix permission objects > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=58223b2a6513e6e780eb75780baae91bc6fa2bc0 --- .../bdj/java/javax/tv/service/ReadPermission.java | 32 ++++++++++------- .../tv/service/selection/SelectPermission.java | 38 ++++++++------------ .../selection/ServiceContextPermission.java | 25 ++++++------- 3 files changed, 44 insertions(+), 51 deletions(-) diff --git a/src/libbluray/bdj/java/javax/tv/service/ReadPermission.java b/src/libbluray/bdj/java/javax/tv/service/ReadPermission.java index fba3340..3066da4 100644 --- a/src/libbluray/bdj/java/javax/tv/service/ReadPermission.java +++ b/src/libbluray/bdj/java/javax/tv/service/ReadPermission.java @@ -25,35 +25,41 @@ import java.io.Serializable; public final class ReadPermission extends Permission implements Serializable { public ReadPermission(Locator locator) { - super(locator.toExternalForm()); + super(locator == null ? "*" : locator.toExternalForm()); - this.locator = locator.toExternalForm(); + if (locator == null) + this.locator = "*"; + else + this.locator = locator.toExternalForm(); } public ReadPermission(String locator, String actions) { - super(null); + super(locator == null ? "*" : locator); + + if (locator == null) + throw new NullPointerException(); this.locator = locator; } public boolean implies(Permission perm) { - return (perm instanceof ReadPermission) && (this.equals(perm) || this.equals("*")); + if (perm == null) + throw new NullPointerException(); + if (!(perm instanceof ReadPermission)) + return false; + + ReadPermission other = (ReadPermission)perm; + return locator.equals(other.locator) || locator.equals("*"); } public boolean equals(Object obj) { - if (obj == null) - return false; if (this == obj) return true; - if (getClass() != obj.getClass()) + if (!(obj instanceof ReadPermission)) return false; + ReadPermission other = (ReadPermission) obj; - if (locator == null) { - if (other.locator != null) - return false; - } else if (!locator.equals(other.locator)) - return false; - return true; + return locator.equals(other.locator); } public int hashCode() { diff --git a/src/libbluray/bdj/java/javax/tv/service/selection/SelectPermission.java b/src/libbluray/bdj/java/javax/tv/service/selection/SelectPermission.java index a6c29a9..9127a0b 100644 --- a/src/libbluray/bdj/java/javax/tv/service/selection/SelectPermission.java +++ b/src/libbluray/bdj/java/javax/tv/service/selection/SelectPermission.java @@ -25,33 +25,34 @@ import java.io.Serializable; public final class SelectPermission extends Permission implements Serializable { public SelectPermission(Locator locator, String actions) { - super(locator.toExternalForm()); + super(locator == null ? "*" : locator.toExternalForm()); - if (!actions.equals("own") && !actions.equals("*")) - throw new IllegalArgumentException(); + if (actions == null) + throw new NullPointerException(); - this.locator = locator.toExternalForm(); + this.locator = locator == null ? "*" : locator.toExternalForm(); this.actions = actions; } public SelectPermission(String locator, String actions) { - super(locator); + super(locator == null ? "*" : locator); - if (!actions.equals("own") && !actions.equals("*")) - throw new IllegalArgumentException(); + if (actions == null) + throw new NullPointerException(); - this.locator = locator; + this.locator = locator == null ? "*" : locator; this.actions = actions; } public boolean implies(Permission perm) { if (!(perm instanceof SelectPermission)) return false; - if (!perm.getActions().equals(actions) && !actions.equals("*")) - return false; SelectPermission sperm = (SelectPermission) perm; + if (!sperm.actions.equals(actions) && !actions.equals("*")) + return false; + if (!sperm.locator.equals(locator) && !locator.equals("*")) return false; @@ -59,22 +60,13 @@ public final class SelectPermission extends Permission implements Serializable { } public boolean equals(Object obj) { - if (obj == null) - return false; - if (this == obj) - return true; - if (getClass() != obj.getClass()) + if (!(obj instanceof SelectPermission)) return false; + SelectPermission other = (SelectPermission) obj; - if (actions == null) { - if (other.actions != null) - return false; - } else if (!actions.equals(other.actions)) + if (!actions.equals(other.actions)) return false; - if (locator == null) { - if (other.locator != null) - return false; - } else if (!locator.equals(other.locator)) + if (!locator.equals(other.locator)) return false; return true; } diff --git a/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextPermission.java b/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextPermission.java index 551920d..2c37eac 100644 --- a/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextPermission.java +++ b/src/libbluray/bdj/java/javax/tv/service/selection/ServiceContextPermission.java @@ -26,18 +26,23 @@ public final class ServiceContextPermission extends BasicPermission { public ServiceContextPermission(String name, String actions) { super(name); + if (name == null || actions == null) + throw new NullPointerException(); + this.name = name; this.actions = actions; } public boolean implies(Permission perm) { + if (perm == null) + throw new NullPointerException(); if (!(perm instanceof ServiceContextPermission)) return false; - if (!perm.getActions().equals(actions) && !actions.equals("*")) - return false; ServiceContextPermission scperm = (ServiceContextPermission) perm; + if (!scperm.actions.equals(actions) && !actions.equals("*")) + return false; if (!scperm.name.equals(name) && !name.equals("*")) return false; @@ -45,22 +50,12 @@ public final class ServiceContextPermission extends BasicPermission { } public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof ServiceContextPermission)) return false; ServiceContextPermission other = (ServiceContextPermission) obj; - if (actions == null) { - if (other.actions != null) - return false; - } else if (!actions.equals(other.actions)) + if (!actions.equals(other.actions)) return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) + if (!name.equals(other.name)) return false; return true; } _______________________________________________ libbluray-devel mailing list libbluray-devel@videolan.org https://mailman.videolan.org/listinfo/libbluray-devel