<relativePath>../../parent</relativePath>
</parent>
- <groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-shiro</artifactId>
- <version>0.17.5-SNAPSHOT</version>
<name>ODL :: aaa :: ${project.artifactId}</name>
<packaging>bundle</packaging>
!javax.annotation,
*
</Import-Package>
+
+ <!-- FIXME: AAA-205: remove this block -->
+ <Provide-Capability>
+ osgi.service;objectClass:List<String>="javax.servlet.Servlet";uses:="javax.servlet",
+ osgi.service;objectClass:List<String>="org.jolokia.osgi.security.Authenticator";uses:="org.jolokia.osgi.security",
+ osgi.service;objectClass:List<String>="org.opendaylight.aaa.api.ClaimCache,org.opendaylight.aaa.api.CredentialAuth,org.opendaylight.aaa.api.IdMService,org.opendaylight.aaa.api.PasswordCredentialAuth";uses:="org.opendaylight.aaa.api,org.opendaylight.aaa.api,org.opendaylight.aaa.api,org.opendaylight.aaa.api",
+ osgi.service;objectClass:List<String>="org.opendaylight.aaa.web.WebContextSecurer";uses:="org.opendaylight.aaa.web"
+ osgi.service;objectClass:List<String>="org.opendaylight.aaa.shiro.web.env.AAAShiroWebEnvironment";uses:="org.opendaylight.aaa.shiro.web.env",
+ </Provide-Capability>
</instructions>
</configuration>
</plugin>
import org.apache.shiro.session.Session;
import org.apache.shiro.session.UnknownSessionException;
import org.apache.shiro.subject.Subject;
-import org.apache.shiro.web.env.WebEnvironment;
import org.jolokia.osgi.security.Authenticator;
+import org.opendaylight.aaa.shiro.web.env.AAAShiroWebEnvironment;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * AAA hook for <code>odl-jolokia</code> configured w/ <code>org.jolokia.authMode=service-all</code>.
+ * AAA hook for @{code odl-jolokia} configured with {@code org.jolokia.authMode=service-all}.
*/
-public class ODLAuthenticator implements Authenticator {
+@Component(immediate = true)
+public final class ODLAuthenticator implements Authenticator {
private static final Logger LOG = LoggerFactory.getLogger(ODLAuthenticator.class);
- private final WebEnvironment env;
+ private final AAAShiroWebEnvironment env;
- public ODLAuthenticator(final WebEnvironment env) {
+ @Activate
+ public ODLAuthenticator(@Reference final AAAShiroWebEnvironment env) {
this.env = requireNonNull(env);
}
--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.shiro.web.env;
+
+import com.google.common.annotations.Beta;
+import org.apache.shiro.web.env.WebEnvironment;
+
+/**
+ * Implementation-internal interface for bridging {@link AAAWebEnvironment} through OSGi Service Registry.
+ */
+@Beta
+public interface AAAShiroWebEnvironment extends WebEnvironment {
+
+}
* Initialization happens in the context of this class's ClassLoader, with dependencies being injected into their
* thread-local variables.
*/
-public final class AAAWebEnvironment extends IniWebEnvironment {
+public final class AAAWebEnvironment extends IniWebEnvironment implements AAAShiroWebEnvironment {
private static final Logger LOG = LoggerFactory.getLogger(AAAWebEnvironment.class);
private AAAWebEnvironment(final Ini ini) {
import static java.util.Objects.requireNonNull;
import java.util.Arrays;
-import org.apache.shiro.web.env.WebEnvironment;
import org.opendaylight.aaa.shiro.filters.AAAShiroFilter;
import org.opendaylight.aaa.web.FilterDetails;
import org.opendaylight.aaa.web.WebContext;
import org.opendaylight.aaa.web.WebContextSecurer;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
/**
* Secures a {@link WebContext} using Shiro.
*
* @author Michael Vorburger.ch
*/
+@Component
public class ShiroWebContextSecurer implements WebContextSecurer {
- private final WebEnvironment webEnvironment;
+ private final AAAShiroWebEnvironment webEnvironment;
- public ShiroWebContextSecurer(final WebEnvironment webEnvironment) {
+ @Activate
+ public ShiroWebContextSecurer(@Reference final AAAShiroWebEnvironment webEnvironment) {
this.webEnvironment = requireNonNull(webEnvironment);
}
import org.opendaylight.aaa.web.WebServer;
import org.opendaylight.aaa.web.servlet.ServletSupport;
import org.opendaylight.yangtools.concepts.Registration;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
/**
* Initializer for web components.
* @author Michael Vorburger.ch
*/
@Singleton
-public class WebInitializer {
+@Component(service = { })
+public final class WebInitializer implements AutoCloseable {
private final Registration registraton;
@Inject
- public WebInitializer(final WebServer webServer, final ClaimCache claimCache, final IIDMStore iidMStore,
- final WebContextSecurer webContextSecurer, final ServletSupport servletSupport,
- final CustomFilterAdapterConfiguration customFilterAdapterConfig) throws ServletException {
+ @Activate
+ public WebInitializer(final @Reference WebServer webServer, @Reference final ClaimCache claimCache,
+ final @Reference ServletSupport servletSupport, final @Reference WebContextSecurer webContextSecurer,
+ final @Reference IIDMStore iidMStore,
+ final @Reference CustomFilterAdapterConfiguration customFilterAdapterConfig) throws ServletException {
final var webContextBuilder = WebContext.builder()
.name("OpenDaylight IDM realm management")
}
@PreDestroy
+ @Deactivate
+ @Override
public void close() {
registraton.close();
}
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
<odl:clustered-app-config
binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.ShiroConfiguration"
<reference id="authService" interface="org.opendaylight.aaa.api.AuthenticationService"/>
<reference id="passwordService" interface="org.opendaylight.aaa.api.password.service.PasswordHashService"/>
<reference id="idmStore" interface ="org.opendaylight.aaa.api.IIDMStore"/>
-
<reference id="passwordCredentialAuth" interface="org.opendaylight.aaa.api.PasswordCredentialAuth"/>
- <reference id="claimCache" interface="org.opendaylight.aaa.api.ClaimCache"/>
-
<reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
-
<reference id="certManager" interface="org.opendaylight.aaa.cert.api.ICertificateManager"/>
+ <reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport"/>
<bean id="provider" class="org.opendaylight.aaa.AAAShiroProvider" init-method="init" destroy-method="close">
<argument ref="passwordCredentialAuth"/>
<argument ref="idmStore"/>
</bean>
- <reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport"/>
-
<bean id="webEnvironment" class="org.opendaylight.aaa.shiro.web.env.AAAWebEnvironment" factory-method="create">
<argument ref="shiroConfiguration"/>
<argument ref="dataBroker"/>
<argument ref="passwordService"/>
<argument ref="servletSupport"/>
</bean>
-
- <bean id="webContextSecurer" class="org.opendaylight.aaa.shiro.web.env.ShiroWebContextSecurer">
- <argument ref="webEnvironment"/>
- </bean>
- <service ref="webContextSecurer" interface="org.opendaylight.aaa.web.WebContextSecurer" />
-
- <bean id="jolokiaAuthenticator" class="org.opendaylight.aaa.authenticator.ODLAuthenticator">
- <argument ref="webEnvironment"/>
- </bean>
- <service ref="jolokiaAuthenticator" interface="org.jolokia.osgi.security.Authenticator"/>
-
- <reference id="customFilterAdapterConfig"
- interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>
- <reference id="webServer" interface="org.opendaylight.aaa.web.WebServer" />
-
- <bean id="webInitializer" class="org.opendaylight.aaa.shiro.web.env.WebInitializer" destroy-method="close">
- <argument ref="webServer"/>
- <argument ref="claimCache"/>
- <argument ref="idmStore"/>
- <argument ref="webContextSecurer"/>
- <argument ref="servletSupport"/>
- <argument ref="customFilterAdapterConfig"/>
- </bean>
+ <service ref="webEnvironment" interface="org.opendaylight.aaa.shiro.web.env.AAAShiroWebEnvironment"/>
</blueprint>