use of org.onosproject.security.AppPermission in project onos by opennetworkinglab.
the class DefaultPolicyBuilderTest method testConvertToOnosPermissions.
@Test
public void testConvertToOnosPermissions() {
Permission testJavaPerm = new AppPermission("testName");
List<org.onosproject.security.Permission> result = Lists.newArrayList();
org.onosproject.security.Permission onosPerm = new org.onosproject.security.Permission(AppPermission.class.getName(), testJavaPerm.getName(), "");
result.add(onosPerm);
assertTrue(!result.isEmpty());
assertEquals("TESTNAME", result.get(0).getName());
}
use of org.onosproject.security.AppPermission in project onos by opennetworkinglab.
the class DefaultPolicyBuilder method getAdminApplicationPermissions.
public static List<Permission> getAdminApplicationPermissions(Set<org.onosproject.security.Permission> permissions) {
List<Permission> perms = Lists.newArrayList();
perms.addAll(defaultPermissions);
perms.addAll(adminServicePermissions);
for (AppPermission.Type perm : serviceDirectory.keySet()) {
perms.add(new AppPermission(perm));
}
perms.addAll(convertToJavaPermissions(permissions));
return optimizePermissions(perms);
}
use of org.onosproject.security.AppPermission in project onos by opennetworkinglab.
the class DefaultPolicyBuilder method getPermission.
private static Permission getPermission(org.onosproject.security.Permission permission) {
String classname = permission.getClassName();
String name = permission.getName();
String actions = permission.getActions();
if (classname == null || name == null) {
return null;
}
classname = classname.trim();
name = name.trim();
actions = actions.trim();
if (AppPermission.class.getName().equals(classname)) {
return new AppPermission(name);
} else if (FilePermission.class.getName().equals(classname)) {
return new FilePermission(name, actions);
} else if (SerializablePermission.class.getName().equals(classname)) {
return new SerializablePermission(name, actions);
} else if (NetPermission.class.getName().equals(classname)) {
return new NetPermission(name, actions);
} else if (RuntimePermission.class.getName().equals(classname)) {
return new RuntimePermission(name, actions);
} else if (SocketPermission.class.getName().equals(classname)) {
return new SocketPermission(name, actions);
} else if (SQLPermission.class.getName().equals(classname)) {
return new SQLPermission(name, actions);
} else if (PropertyPermission.class.getName().equals(classname)) {
return new PropertyPermission(name, actions);
} else if (LoggingPermission.class.getName().equals(classname)) {
return new LoggingPermission(name, actions);
} else if (SSLPermission.class.getName().equals(classname)) {
return new SSLPermission(name, actions);
} else if (AuthPermission.class.getName().equals(classname)) {
return new AuthPermission(name, actions);
} else if (PrivateCredentialPermission.class.getName().equals(classname)) {
return new PrivateCredentialPermission(name, actions);
} else if (DelegationPermission.class.getName().equals(classname)) {
return new DelegationPermission(name, actions);
} else if (javax.security.auth.kerberos.ServicePermission.class.getName().equals(classname)) {
return new javax.security.auth.kerberos.ServicePermission(name, actions);
} else if (AudioPermission.class.getName().equals(classname)) {
return new AudioPermission(name, actions);
} else if (AdaptPermission.class.getName().equals(classname)) {
return new AdaptPermission(name, actions);
} else if (BundlePermission.class.getName().equals(classname)) {
return new BundlePermission(name, actions);
} else if (CapabilityPermission.class.getName().equals(classname)) {
return new CapabilityPermission(name, actions);
} else if (PackagePermission.class.getName().equals(classname)) {
return new PackagePermission(name, actions);
} else if (ServicePermission.class.getName().equals(classname)) {
return new ServicePermission(name, actions);
} else if (AdminPermission.class.getName().equals(classname)) {
return new AdminPermission(name, actions);
// } else if (ConfigurationPermission.class.getName().equals(classname)) {
// return new ConfigurationPermission(name, actions);
} else if (ReflectPermission.class.getName().equals(classname)) {
return new ReflectPermission(name, actions);
}
// AWTPermission, ReflectPermission not allowed
return null;
}
use of org.onosproject.security.AppPermission in project onos by opennetworkinglab.
the class DefaultPolicyBuilderTest method setUp.
@Before
public void setUp() throws Exception {
List<Permission> permSet = Lists.newArrayList();
permSet.add(new PackagePermission("*", PackagePermission.EXPORTONLY));
permSet.add(new PackagePermission("*", PackagePermission.IMPORT));
permSet.add(new AdaptPermission("*", AdaptPermission.ADAPT));
permSet.add(new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE));
permSet.add(new AdminPermission("*", AdminPermission.METADATA));
defaultPermissions = permSet;
List<Permission> adminPermSet = Lists.newArrayList();
adminPermSet.add(new ServicePermission(ApplicationAdminService.class.getName(), ServicePermission.GET));
adminServicePermissions = adminPermSet;
testPermission = new org.onosproject.security.Permission("testClass", "APP_READ", "testActions");
testPermissions = new HashSet<org.onosproject.security.Permission>();
testPermissions.add(testPermission);
testJavaPerm = new AppPermission("testName");
testJavaPerms = new HashSet<Permission>();
testJavaPerms.add(testJavaPerm);
}
use of org.onosproject.security.AppPermission in project onos by opennetworkinglab.
the class DefaultPolicyBuilderTest method testConvertToJavaPermissions.
@Test
public void testConvertToJavaPermissions() {
List<Permission> result = Lists.newArrayList();
for (org.onosproject.security.Permission perm : testPermissions) {
Permission javaPerm = new AppPermission(perm.getName());
if (javaPerm != null) {
if (javaPerm instanceof AppPermission) {
if (((AppPermission) javaPerm).getType() != null) {
AppPermission ap = (AppPermission) javaPerm;
result.add(ap);
}
} else if (javaPerm instanceof ServicePermission) {
if (!javaPerm.getName().contains(SecurityAdminService.class.getName())) {
result.add(javaPerm);
}
} else {
result.add(javaPerm);
}
}
}
assertTrue(!result.isEmpty());
assertEquals("APP_READ", result.get(0).getName());
}
Aggregations