-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #697 from eclipse-passage/572366-2
Bug 572366 verify product's public key on hc-fls interaction
- Loading branch information
Showing
8 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/Gear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.api; | ||
|
||
/** | ||
* Marker interface for a product based on Passage infrastructure to supply all | ||
* necessary services | ||
*/ | ||
public interface Gear { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...es/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/GearSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.api; | ||
|
||
public interface GearSupplier<G extends Gear> { | ||
|
||
G gear(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...g.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/GearAware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.equinox; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.passage.lic.internal.api.Gear; | ||
import org.eclipse.passage.lic.internal.api.GearSupplier; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.framework.FrameworkUtil; | ||
import org.osgi.framework.InvalidSyntaxException; | ||
import org.osgi.framework.ServiceReference; | ||
|
||
public abstract class GearAware<G extends Gear, S extends GearSupplier<G>> { | ||
|
||
public final <T> Optional<T> withGear(Function<G, Optional<T>> with) { | ||
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); | ||
Collection<ServiceReference<S>> references = Collections.emptyList(); | ||
try { | ||
references = context.getServiceReferences(supplier(), null); | ||
} catch (InvalidSyntaxException e) { | ||
return Optional.empty(); | ||
} | ||
if (references.isEmpty()) { | ||
return Optional.empty(); | ||
} | ||
ServiceReference<S> any = references.iterator().next(); | ||
try { | ||
return with.apply(context.getService(any).gear()); | ||
} finally { | ||
context.ungetService(any); | ||
} | ||
} | ||
|
||
protected abstract Class<S> supplier(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters