use of org.eclipse.osgi.util.ManifestElement in project rt.equinox.framework by eclipse.
the class OSGiManifestBuilderFactory method validateHeaders.
private static void validateHeaders(Map<String, String> manifest) throws BundleException {
for (int i = 0; i < DEFINED_OSGI_VALIDATE_HEADERS.length; i++) {
String header = manifest.get(DEFINED_OSGI_VALIDATE_HEADERS[i]);
if (header != null) {
ManifestElement[] elements = ManifestElement.parseHeader(DEFINED_OSGI_VALIDATE_HEADERS[i], header);
checkForDuplicateDirectivesAttributes(DEFINED_OSGI_VALIDATE_HEADERS[i], elements);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.IMPORT_PACKAGE)
checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, false, false);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.DYNAMICIMPORT_PACKAGE)
checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, false, true);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.EXPORT_PACKAGE)
checkImportExportSyntax(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, true, false);
if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.FRAGMENT_HOST)
checkExtensionBundle(DEFINED_OSGI_VALIDATE_HEADERS[i], elements, manifest);
} else if (DEFINED_OSGI_VALIDATE_HEADERS[i] == Constants.BUNDLE_SYMBOLICNAME) {
// $NON-NLS-1$
throw new BundleException(Constants.BUNDLE_SYMBOLICNAME + " header is required.", BundleException.MANIFEST_ERROR);
}
}
}
use of org.eclipse.osgi.util.ManifestElement in project rt.equinox.framework by eclipse.
the class DynamicImportList method validateSyntaxAndCheckPackagePermission.
private void validateSyntaxAndCheckPackagePermission(String dynamicImportPackageDescription) {
ManifestElement[] clauses;
// Validate the syntax of imports that are added.
try {
clauses = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, dynamicImportPackageDescription);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return;
// for each dynamic import added.
for (ManifestElement clause : clauses) for (String pkg : clause.getValueComponents()) sm.checkPermission(new PackagePermission(pkg, PackagePermission.IMPORT));
}
use of org.eclipse.osgi.util.ManifestElement in project rt.equinox.framework by eclipse.
the class StateObjectFactoryImpl method createImportPackageSpecifications.
public List<ImportPackageSpecification> createImportPackageSpecifications(String declaration) {
try {
ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration);
if (elements == null)
return Collections.<ImportPackageSpecification>emptyList();
List<ImportPackageSpecification> result = new ArrayList<>(elements.length);
for (ManifestElement element : elements) StateBuilder.addImportPackages(element, result, 2, false);
return result;
} catch (BundleException e) {
// $NON-NLS-1$
throw new IllegalArgumentException("Declaration is invalid: " + declaration, e);
}
}
use of org.eclipse.osgi.util.ManifestElement in project rt.equinox.framework by eclipse.
the class StateObjectFactoryImpl method createBundleSpecifications.
public List<BundleSpecification> createBundleSpecifications(String declaration) {
try {
ManifestElement[] elements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, declaration);
if (elements == null)
return Collections.<BundleSpecification>emptyList();
List<BundleSpecification> result = new ArrayList<>(elements.length);
for (ManifestElement element : elements) result.add(StateBuilder.createRequiredBundle(element));
return result;
} catch (BundleException e) {
// $NON-NLS-1$
throw new IllegalArgumentException("Declaration is invalid: " + declaration, e);
}
}
use of org.eclipse.osgi.util.ManifestElement in project rt.equinox.framework by eclipse.
the class StateObjectFactoryImpl method createExportPackageDescriptions.
public List<ExportPackageDescription> createExportPackageDescriptions(String declaration) {
try {
ManifestElement[] elements = ManifestElement.parseHeader(Constants.IMPORT_PACKAGE, declaration);
if (elements == null)
return Collections.<ExportPackageDescription>emptyList();
List<ExportPackageDescription> result = new ArrayList<>(elements.length);
for (ManifestElement element : elements) StateBuilder.addExportPackages(element, result, false);
return result;
} catch (BundleException e) {
// $NON-NLS-1$
throw new IllegalArgumentException("Declaration is invalid: " + declaration, e);
}
}
Aggregations