本文整理汇总了Java中org.onosproject.security.Permission类的典型用法代码示例。如果您正苦于以下问题:Java Permission类的具体用法?Java Permission怎么用?Java Permission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Permission类属于org.onosproject.security包,在下文中一共展示了Permission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.onosproject.security.Permission; //导入依赖的package包/类
@Activate
public void activate() {
states = storageService.<ApplicationId, SecurityInfo>consistentMapBuilder()
.withName("smonos-sdata")
.withSerializer(STATE_SERIALIZER)
.build();
states.addListener(new SecurityStateListener());
violations = storageService.<ApplicationId, Set<Permission>>eventuallyConsistentMapBuilder()
.withName("smonos-rperms")
.withSerializer(VIOLATION_SERIALIZER)
.withTimestampProvider((k, v) -> clockService.getTimestamp())
.build();
localBundleAppDirectory = new ConcurrentHashMap<>();
localAppBundleDirectory = new ConcurrentHashMap<>();
log.info("Started");
}
示例2: DefaultApplicationDescription
import org.onosproject.security.Permission; //导入依赖的package包/类
/**
* Creates a new application descriptor using the supplied data.
*
* @param name application name
* @param version application version
* @param title application title
* @param description application description
* @param origin origin company
* @param category application category
* @param url application URL
* @param readme application readme
* @param icon application icon
* @param role application role
* @param permissions requested permissions
* @param featuresRepo optional features repo URI
* @param features application features
* @param requiredApps list of required application names
*/
public DefaultApplicationDescription(String name, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
URI featuresRepo, List<String> features,
List<String> requiredApps) {
this.name = checkNotNull(name, "Name cannot be null");
this.version = checkNotNull(version, "Version cannot be null");
this.title = checkNotNull(title, "Title cannot be null");
this.description = checkNotNull(description, "Description cannot be null");
this.origin = checkNotNull(origin, "Origin cannot be null");
this.category = checkNotNull(category, "Category cannot be null");
this.url = url;
this.readme = checkNotNull(readme, "Readme cannot be null");
this.icon = icon;
this.role = checkNotNull(role, "Role cannot be null");
this.permissions = checkNotNull(permissions, "Permissions cannot be null");
this.featuresRepo = Optional.ofNullable(featuresRepo);
this.features = checkNotNull(features, "Features cannot be null");
this.requiredApps = checkNotNull(requiredApps, "Required apps cannot be null");
checkArgument(!features.isEmpty(), "There must be at least one feature");
}
示例3: translate
import org.onosproject.security.Permission; //导入依赖的package包/类
/**
* Translates gRPC Application to {@link Application}.
*
* @param app gRPC message
* @return {@link Application}
*/
public static Application translate(ApplicationProto app) {
Set<Permission> permissions = Sets.newHashSet();
app.getPermissionsList().forEach(p ->
permissions.add(PermissionProtoTranslator.translate(p)));
return DefaultApplication.builder()
.withAppId(ApplicationIdProtoTranslator.translate(app.getAppId()))
.withVersion(VersionProtoTranslator.translate(app.getVersion()))
.withTitle(app.getTitle())
.withDescription(app.getDescription())
.withOrigin(app.getOrigin())
.withCategory(app.getCategory())
.withUrl(app.getUrl())
.withReadme(app.getReadme())
.withIcon(app.toByteArray())
.withRole((ApplicationRole) ApplicationEnumsProtoTranslator.translate(app.getRole()).get())
.withPermissions(permissions)
.withFeatures(app.getFeaturesList())
.withFeaturesRepo(Optional.empty()) // TODO: need to add features repo
.withRequiredApps(app.getRequiredAppsList())
.build();
}
示例4: activate
import org.onosproject.security.Permission; //导入依赖的package包/类
@Activate
public void activate() {
eventHandler = newSingleThreadExecutor(groupedThreads("onos/security/store", "event-handler", log));
states = storageService.<ApplicationId, SecurityInfo>consistentMapBuilder()
.withName("smonos-sdata")
.withSerializer(STATE_SERIALIZER)
.build();
states.addListener(statesListener, eventHandler);
violations = storageService.<ApplicationId, Set<Permission>>eventuallyConsistentMapBuilder()
.withName("smonos-rperms")
.withSerializer(VIOLATION_SERIALIZER)
.withTimestampProvider((k, v) -> clockService.getTimestamp())
.build();
localBundleAppDirectory = new ConcurrentHashMap<>();
localAppBundleDirectory = new ConcurrentHashMap<>();
log.info("Started");
}
示例5: getPrintablePermissionMap
import org.onosproject.security.Permission; //导入依赖的package包/类
private Map<Integer, List<Permission>> getPrintablePermissionMap(Set<Permission> perms) {
ConcurrentHashMap<Integer, List<Permission>> sortedMap = new ConcurrentHashMap<>();
sortedMap.put(0, new ArrayList());
sortedMap.put(1, new ArrayList());
sortedMap.put(2, new ArrayList());
sortedMap.put(3, new ArrayList());
sortedMap.put(4, new ArrayList());
for (Permission perm : perms) {
if (perm.getName().contains("Admin")) {
sortedMap.get(1).add(perm);
} else {
sortedMap.get(2).add(perm);
}
}
return sortedMap;
}
示例6: getMaximumPermissions
import org.onosproject.security.Permission; //导入依赖的package包/类
private Set<Permission> getMaximumPermissions(ApplicationId appId) {
if (app == null) {
return null;
}
Set<Permission> appPerms;
switch (app.role()) {
case ADMIN:
appPerms = app.permissions();
break;
case USER:
appPerms = app.permissions();
break;
case UNSPECIFIED:
default:
appPerms = new HashSet<Permission>();
break;
}
return appPerms;
}
示例7: acceptPolicy
import org.onosproject.security.Permission; //导入依赖的package包/类
@Override
public void acceptPolicy(ApplicationId appId, Set<Permission> permissionSet) {
states.compute(appId,
(id, securityInfo) -> {
switch (securityInfo.getState()) {
case POLICY_VIOLATED:
return new SecurityInfo(securityInfo.getPermissions(), SECURED);
case SECURED:
return new SecurityInfo(securityInfo.getPermissions(), POLICY_VIOLATED);
case INSTALLED:
return new SecurityInfo(securityInfo.getPermissions(), REVIEWED);
case REVIEWED:
return new SecurityInfo(securityInfo.getPermissions(), INSTALLED);
default:
return securityInfo;
}
});
}
示例8: DefaultApplicationDescription
import org.onosproject.security.Permission; //导入依赖的package包/类
/**
* Creates a new application descriptor using the supplied data.
*
* @param name application name
* @param version application version
* @param title application title
* @param description application description
* @param origin origin company
* @param category application category
* @param url application URL
* @param readme application readme
* @param icon application icon
* @param role application role
* @param permissions requested permissions
* @param featuresRepo optional features repo URI
* @param features application features
* @param requiredApps list of required application names
*/
private DefaultApplicationDescription(String name, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
URI featuresRepo, List<String> features,
List<String> requiredApps) {
this.name = name;
this.version = version;
this.title = title;
this.description = description;
this.origin = origin;
this.category = category;
this.url = url;
this.readme = readme;
this.icon = icon;
this.role = role;
this.permissions = permissions;
this.featuresRepo = Optional.ofNullable(featuresRepo);
this.features = ImmutableList.copyOf(features);
this.requiredApps = ImmutableList.copyOf(requiredApps);
}
示例9: DefaultApplication
import org.onosproject.security.Permission; //导入依赖的package包/类
/**
* Creates a new application descriptor using the supplied data.
*
* @param appId application identifier
* @param version application version
* @param title application title
* @param description application description
* @param origin origin company
* @param category application category
* @param url application URL
* @param readme application readme
* @param icon application icon
* @param role application role
* @param permissions requested permissions
* @param featuresRepo optional features repo URI
* @param features application features
* @param requiredApps list of required application names
*/
private DefaultApplication(ApplicationId appId, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
Optional<URI> featuresRepo, List<String> features,
List<String> requiredApps) {
this.appId = appId;
this.version = version;
this.title = title;
this.description = description;
this.origin = origin;
this.category = category;
this.url = url;
this.readme = readme;
this.icon = icon == null ? new byte[0] : icon.clone();
this.role = role;
this.permissions = ImmutableSet.copyOf(permissions);
this.featuresRepo = featuresRepo;
this.features = ImmutableList.copyOf(features);
this.requiredApps = ImmutableList.copyOf(requiredApps);
}
示例10: requestPermission
import org.onosproject.security.Permission; //导入依赖的package包/类
@Override
public void requestPermission(ApplicationId appId, Permission permission) {
states.computeIf(appId, securityInfo -> (securityInfo == null || securityInfo.getState() != POLICY_VIOLATED),
(id, securityInfo) -> new SecurityInfo(securityInfo.getPermissions(), POLICY_VIOLATED));
violations.compute(appId, (k, v) -> v == null ? Sets.newHashSet(permission) : addAndGet(v, permission));
}
示例11: acceptPolicy
import org.onosproject.security.Permission; //导入依赖的package包/类
@Override
public void acceptPolicy(ApplicationId appId, Set<Permission> permissionSet) {
Application app = applicationAdminService.getApplication(appId);
if (app == null) {
log.warn("Unknown Application");
return;
}
states.computeIf(appId,
Objects::nonNull,
(id, securityInfo) -> {
switch (securityInfo.getState()) {
case POLICY_VIOLATED:
System.out.println(
"This application has violated the security policy. Please uninstall.");
return securityInfo;
case SECURED:
System.out.println(
"The policy has been accepted already. To review policy, review [app.name]");
return securityInfo;
case INSTALLED:
System.out.println("Please review the security policy prior to accept them");
log.warn("Application has not been reviewed");
return securityInfo;
case REVIEWED:
return new SecurityInfo(permissionSet, SECURED);
default:
return securityInfo;
}
});
}
示例12: DefaultApplication
import org.onosproject.security.Permission; //导入依赖的package包/类
/**
* Creates a new application descriptor using the supplied data.
*
* @param appId application identifier
* @param version application version
* @param title application title
* @param description application description
* @param origin origin company
* @param category application category
* @param url application URL
* @param readme application readme
* @param icon application icon
* @param role application role
* @param permissions requested permissions
* @param featuresRepo optional features repo URI
* @param features application features
* @param requiredApps list of required application names
*/
public DefaultApplication(ApplicationId appId, Version version, String title,
String description, String origin, String category,
String url, String readme, byte[] icon,
ApplicationRole role, Set<Permission> permissions,
Optional<URI> featuresRepo, List<String> features,
List<String> requiredApps) {
this.appId = checkNotNull(appId, "ID cannot be null");
this.version = checkNotNull(version, "Version cannot be null");
this.title = checkNotNull(title, "Title cannot be null");
this.description = checkNotNull(description, "Description cannot be null");
this.origin = checkNotNull(origin, "Origin cannot be null");
this.category = checkNotNull(category, "Category cannot be null");
this.url = url;
this.readme = checkNotNull(readme, "Readme cannot be null");
this.icon = icon == null ? new byte[0] : icon.clone();
this.role = checkNotNull(role, "Role cannot be null");
this.permissions = ImmutableSet.copyOf(
checkNotNull(permissions, "Permissions cannot be null")
);
this.featuresRepo = checkNotNull(featuresRepo, "Features repo cannot be null");
this.features = ImmutableList.copyOf(
checkNotNull(features, "Features cannot be null")
);
this.requiredApps = ImmutableList.copyOf(
checkNotNull(requiredApps, "Required apps cannot be null")
);
checkArgument(!features.isEmpty(), "There must be at least one feature");
}
示例13: immutablePermissions
import org.onosproject.security.Permission; //导入依赖的package包/类
@Test
public void immutablePermissions() {
// Set<Permission> p = PERMS_ORIG;
Set<Permission> p = PERMS_UNSAFE;
Application app = new DefaultApplication(APP_ID, VER, TITLE, DESC, ORIGIN,
CATEGORY, URL, README, ICON, ROLE,
p, Optional.of(FURL), FEATURES, APPS);
Set<Permission> perms = app.permissions();
try {
perms.add(JUNK_PERM);
} catch (UnsupportedOperationException e) {
// set is immutable
}
assertTrue("no write perm", app.permissions().contains(PERM_W));
assertTrue("no read perm", app.permissions().contains(PERM_R));
assertEquals("extra perms", 2, app.permissions().size());
// DONE: review - is it sufficient to expect caller to pass in ImmutableSet ?
// Issue Resolved with Immutable collections used during construction.
// If we just pass in a HashSet, the contents would be modifiable by
// an external party. (Making the field final just means that the
// reference to the set can never change; the contents may still...)
// Similar reasoning can be applied to these two fields also:
// List<String> features
// List<String> requiredApps
}
示例14: loadAppDescription
import org.onosproject.security.Permission; //导入依赖的package包/类
private ApplicationDescription loadAppDescription(XMLConfiguration cfg) {
String name = cfg.getString(NAME);
Version version = Version.version(cfg.getString(VERSION));
String origin = cfg.getString(ORIGIN);
String title = cfg.getString(TITLE);
// FIXME: title should be set as attribute to APP, but fallback for now...
title = title == null ? name : title;
String category = cfg.getString(CATEGORY, UTILITY);
String url = cfg.getString(URL);
byte[] icon = getApplicationIcon(name);
ApplicationRole role = getRole(cfg.getString(ROLE));
Set<Permission> perms = getPermissions(cfg);
String featRepo = cfg.getString(FEATURES_REPO);
URI featuresRepo = featRepo != null ? URI.create(featRepo) : null;
List<String> features = ImmutableList.copyOf(cfg.getString(FEATURES).split(","));
String apps = cfg.getString(APPS, "");
List<String> requiredApps = apps.isEmpty() ?
ImmutableList.of() : ImmutableList.copyOf(apps.split(","));
// put full description to readme field
String readme = cfg.getString(DESCRIPTION);
// put short description to description field
String desc = compactDescription(readme);
return new DefaultApplicationDescription(name, version, title, desc, origin,
category, url, readme, icon,
role, perms, featuresRepo,
features, requiredApps);
}
示例15: setPermissions
import org.onosproject.security.Permission; //导入依赖的package包/类
@Override
public void setPermissions(ApplicationId appId, Set<Permission> permissions) {
Application app = getApplication(appId);
if (app != null) {
this.permissions.put(appId, permissions);
delegate.notify(new ApplicationEvent(APP_PERMISSIONS_CHANGED, app));
}
}