Search in sources :

Example 6 with Permission

use of org.onosproject.security.Permission in project onos by opennetworkinglab.

the class DistributedSecurityModeStoreTest method setUp.

@Before
public void setUp() throws Exception {
    appId = new DefaultApplicationId(1, "test");
    testPermissions = new HashSet<Permission>();
    testPermission = new Permission("testClass", "testName");
    testPermissions.add(testPermission);
    testFeatures = new ArrayList<String>();
    testFeatures.add("testFeature");
    testRequiredApps = new ArrayList<String>();
    testRequiredApps.add("testRequiredApp");
    app = DefaultApplication.builder().withAppId(appId).withVersion(Version.version(1, 1, "patch", "build")).withTitle("testTitle").withDescription("testDes").withOrigin("testOri").withCategory("testCT").withUrl("testurl").withReadme("test").withIcon(null).withRole(ApplicationRole.ADMIN).withPermissions(testPermissions).withFeaturesRepo(Optional.ofNullable(null)).withFeatures(testFeatures).withRequiredApps(testRequiredApps).build();
    testLocations = new HashSet<String>();
    testLocations.add("locationA");
    testLocations.add("locationB");
    Set<ApplicationId> appIdSet = new HashSet<ApplicationId>();
    appIdSet.add(appId);
    localBundleAppDirectory = new ConcurrentHashMap<>();
    localBundleAppDirectory.put("testLocation", appIdSet);
    localAppBundleDirectory = new ConcurrentHashMap<>();
    localAppBundleDirectory.put(appId, testLocations);
    violations = new ConcurrentHashMap<ApplicationId, Set<Permission>>();
    violations.put(appId, testPermissions);
    testSecInfo = new SecurityInfo(testPermissions, SECURED);
    states = new ConcurrentHashMap<ApplicationId, SecurityInfo>();
    states.put(appId, testSecInfo);
}
Also used : HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) Permission(org.onosproject.security.Permission) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 7 with Permission

use of org.onosproject.security.Permission in project onos by opennetworkinglab.

the class ApplicationArchive method loadAppDescription.

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 DefaultApplicationDescription.builder().withName(name).withVersion(version).withTitle(title).withDescription(desc).withOrigin(origin).withCategory(category).withUrl(url).withReadme(readme).withIcon(icon).withRole(role).withPermissions(perms).withFeaturesRepo(featuresRepo).withFeatures(features).withRequiredApps(requiredApps).build();
}
Also used : Version(org.onosproject.core.Version) Permission(org.onosproject.security.Permission) AppPermission(org.onosproject.security.AppPermission) ApplicationRole(org.onosproject.core.ApplicationRole) URI(java.net.URI)

Aggregations

Permission (org.onosproject.security.Permission)7 AppPermission (org.onosproject.security.AppPermission)3 Before (org.junit.Before)2 Test (org.junit.Test)2 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)1 Application (org.onosproject.core.Application)1 ApplicationId (org.onosproject.core.ApplicationId)1 ApplicationRole (org.onosproject.core.ApplicationRole)1 Version (org.onosproject.core.Version)1 SecurityModeStoreAdapter (org.onosproject.security.store.SecurityModeStoreAdapter)1