* Copyright (c) OSGi Alliance (2004, 2013). All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
AlertPermission has a target string which controls the principal
names where alerts can be sent. A wildcard is allowed at the end of the
target string, to allow sending alerts to any principal with a name matching
the given prefix. The "*" target means that alerts can be sent to
// specifies whether the target string had a wildcard at the end
// the target string without the wildcard (if there was one)
AlertPermissionobject with its name set to the target string. Name must be non-null and non-empty.
if (target == null)
AlertPermissionobject using the 'canonical' two argument constructor. In this version this class does not define any actions, the second argument of this constructor must be "*" so that this class can later be extended in a backward compatible way.
targetthe name of the server, can end with
*to match any server identifier with the given prefix
actionsno actions defined, must be "*" for forward compatibility
nameis empty or
actionsis not "*"
if (actions == null)
objthe object to compare to this AlertPermission instance
trueif the parameter represents the same permissions as this instance
if (obj == this)
method, then calling this method on each of the two AlertPermission objects must produce the same integer result.
pthe permission to check for implication
* Returns true if the server name parameter of the given AlertPermission is
* implied by the server name of this permission, i.e. this server name is a
* prefix of the other one but ends with a *, or the two server names are
throw new IllegalArgumentException("Cannot add permission, invalid permission type: " + permission);
// only add new permission if it is not already implied by the
// permissions in the collection
// remove all permissions that are implied by the new one
// no need to synchronize because all adds are done sequentially
// before any implies() calls
// Convert Iterator into Enumeration