Skip to content

Commit cc78aec

Browse files
committed
Added sslcontextfactory example components
1 parent 3809971 commit cc78aec

11 files changed

+136
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>org.eclipse.ecf.examples.sslcontextfactory</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.pde.ds.core.builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.pde.PluginNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=windows-1252
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
3+
org.eclipse.jdt.core.compiler.compliance=17
4+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
5+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
8+
org.eclipse.jdt.core.compiler.release=enabled
9+
org.eclipse.jdt.core.compiler.source=17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
pluginProject.extensions=false
3+
resolve.requirebundle=false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Sslcontextfactory
4+
Bundle-SymbolicName: org.eclipse.ecf.examples.sslcontextfactory
5+
Bundle-Version: 1.0.0.qualifier
6+
Automatic-Module-Name: org.eclipse.ecf.examples.sslcontextfactory
7+
Bundle-ActivationPolicy: lazy
8+
Bundle-RequiredExecutionEnvironment: JavaSE-17
9+
Import-Package: org.eclipse.ecf.core.security;version="[3.2.0,4.0.0)",
10+
org.osgi.service.component.annotations;version="[1.3.0,2.0.0)";resolution:=optional
11+
Service-Component: OSGI-INF/org.eclipse.ecf.examples.sslcontextfactory.ContextFactoryConsumer.xml,
12+
OSGI-INF/org.eclipse.ecf.examples.sslcontextfactory.ExampleProvider.xml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.ecf.examples.sslcontextfactory.ContextFactoryConsumer">
3+
<reference bind="bindSSLContextFactory" interface="org.eclipse.ecf.core.security.SSLContextFactory" name="SSLContextFactory" unbind="unbindSSLContextFactory"/>
4+
<implementation class="org.eclipse.ecf.examples.sslcontextfactory.ContextFactoryConsumer"/>
5+
</scr:component>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.ecf.examples.sslcontextfactory.ExampleProvider">
3+
<service>
4+
<provide interface="java.security.Provider"/>
5+
</service>
6+
<implementation class="org.eclipse.ecf.examples.sslcontextfactory.ExampleProvider"/>
7+
</scr:component>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = META-INF/,\
4+
.,\
5+
OSGI-INF/org.eclipse.ecf.examples.sslcontextfactory.ContextFactoryConsumer.xml,\
6+
OSGI-INF/org.eclipse.ecf.examples.sslcontextfactory.ExampleProvider.xml,\
7+
OSGI-INF/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.eclipse.ecf.examples.sslcontextfactory;
2+
3+
import java.security.NoSuchAlgorithmException;
4+
import java.security.NoSuchProviderException;
5+
6+
import javax.net.ssl.SSLContext;
7+
8+
import org.eclipse.ecf.core.security.SSLContextFactory;
9+
import org.osgi.service.component.annotations.Component;
10+
import org.osgi.service.component.annotations.Reference;
11+
12+
@Component(immediate=true)
13+
public class ContextFactoryConsumer {
14+
15+
@Reference
16+
void bindSSLContextFactory(SSLContextFactory sslContextFactory) {
17+
System.out.println("Got it "+ sslContextFactory);
18+
// Now get PKIJoe SSLContext
19+
try {
20+
SSLContext sslContext = sslContextFactory.getInstance("TLS", "PKIJoe");
21+
// # do stuff with sslContext here!
22+
System.out.println("sslContext="+sslContext);
23+
} catch (NoSuchAlgorithmException e) {
24+
// TODO Auto-generated catch block
25+
e.printStackTrace();
26+
} catch (NoSuchProviderException e) {
27+
// TODO Auto-generated catch block
28+
e.printStackTrace();
29+
}
30+
}
31+
32+
void unbindSSLContextFactory(SSLContextFactory sslContextFactory) {
33+
System.out.println("Ungot it "+ sslContextFactory);
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.eclipse.ecf.examples.sslcontextfactory;
2+
3+
import java.security.Provider;
4+
5+
import org.osgi.service.component.annotations.Component;
6+
7+
@Component(service=Provider.class,immediate=true)
8+
public class ExampleProvider extends Provider {
9+
10+
private static final long serialVersionUID = 4387195962639458953L;
11+
12+
public ExampleProvider() {
13+
super("PKIJoe", "1.0", null);
14+
}
15+
16+
}

0 commit comments

Comments
 (0)