blob: 70ce208ef74529aad27947bf1bfd191f3d4ffb9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2009, 2011 IBM Corporation and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
******************************************************************************/
package org.eclipse.equinox.log;
import java.security.Permission;
import java.security.PermissionCollection;
/**
* Indicates a bundle's authority to log on behalf of other bundles.
*
* This permission has only a single action: LOG.
*
* @ThreadSafe
* @since 3.7
*/
public class LogPermission extends Permission {
private static final long serialVersionUID = -441193976837153362L;
private static final String ALL = "*"; //$NON-NLS-1$
/**
* The action string <code>log</code>.
*/
public static final String LOG = "log"; //$NON-NLS-1$
/**
* Create a new LogPermission.
*
* @param name Name must be "*".
* @param actions <code>log</code> or "*".
*/
public LogPermission(String name, String actions) {
super(name);
if (!name.equals(ALL))
throw new IllegalArgumentException("name must be *"); //$NON-NLS-1$
actions = actions.trim();
if (!actions.equalsIgnoreCase(LOG) && !actions.equals(ALL))
throw new IllegalArgumentException("actions must be * or log"); //$NON-NLS-1$
}
@Override
public boolean equals(Object obj) {
return obj instanceof LogPermission;
}
@Override
public String getActions() {
return LOG;
}
@Override
public int hashCode() {
return LogPermission.class.hashCode();
}
@Override
public boolean implies(Permission permission) {
return permission instanceof LogPermission;
}
@Override
public PermissionCollection newPermissionCollection() {
return new LogPermissionCollection();
}
}
|