Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make PreEnforcerProvider load all PreEnforcer via config
Signed-off-by: David Schwilk <david.schwilk@bosch.io>
- Loading branch information
1 parent
17d9ecd
commit ab05043
Showing
24 changed files
with
229 additions
and
113 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# this file contains sample users and their hashed password | ||
ditto:A6BgmB8IEtPTs | ||
david:xpe1zRdjOlAhE |
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
35 changes: 35 additions & 0 deletions
35
...ent/src/main/java/org/eclipse/ditto/policies/enforcement/BlockedNamespacePreEnforcer.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,35 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.policies.enforcement; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
|
||
import org.eclipse.ditto.base.model.headers.DittoHeadersSettable; | ||
import org.eclipse.ditto.internal.utils.namespaces.BlockNamespaceBehavior; | ||
import org.eclipse.ditto.internal.utils.namespaces.BlockedNamespaces; | ||
|
||
import akka.actor.ActorSystem; | ||
|
||
public final class BlockedNamespacePreEnforcer implements PreEnforcer{ | ||
|
||
final BlockNamespaceBehavior blockNamespaceBehavior; | ||
|
||
public BlockedNamespacePreEnforcer(final ActorSystem actorSystem) { | ||
blockNamespaceBehavior = BlockNamespaceBehavior.of(BlockedNamespaces.of(actorSystem)); | ||
} | ||
|
||
@Override | ||
public CompletionStage<DittoHeadersSettable<?>> apply(final DittoHeadersSettable<?> t) { | ||
return blockNamespaceBehavior.block(t); | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
...ment/src/main/java/org/eclipse/ditto/policies/enforcement/DefaultPreEnforcerProvider.java
This file was deleted.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
...rcement/src/main/java/org/eclipse/ditto/policies/enforcement/PreEnforcerExtensionIds.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,46 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.ditto.policies.enforcement; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.ditto.internal.utils.akka.AkkaClassLoader; | ||
|
||
import akka.actor.AbstractExtensionId; | ||
import akka.actor.ExtendedActorSystem; | ||
import akka.actor.Extension; | ||
|
||
final class PreEnforcerExtensionIds implements Extension { | ||
|
||
static final ExtensionId INSTANCE = new ExtensionId(); | ||
private final Map<String, PreEnforcer.ExtensionId> extensionIds = new HashMap<>(); | ||
|
||
PreEnforcer.ExtensionId get(final String implementation) { | ||
return extensionIds.computeIfAbsent(implementation, PreEnforcer.ExtensionId::new); | ||
} | ||
|
||
static final class ExtensionId extends AbstractExtensionId<PreEnforcerExtensionIds> { | ||
|
||
@Override | ||
public PreEnforcerExtensionIds createExtension(final ExtendedActorSystem system) { | ||
|
||
return AkkaClassLoader.instantiate(system, PreEnforcerExtensionIds.class, | ||
PreEnforcerExtensionIds.class.getCanonicalName(), | ||
List.of(), | ||
List.of()); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.