Author: [email protected]
Date: Wed Apr 25 15:11:29 2012
New Revision: 2286
Log:
[AMDATUAUTH-123] Updated fs-store-consumer, mem-store-nonve, oauth-client and
oauth-server for new multi-tenancy design
Added:
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.consumerregistry.fs.xml
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.server.xml
Modified:
trunk/amdatu-auth/auth-stores/fs-store-consumer/pom.xml
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/osgi/Activator.java
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
trunk/amdatu-auth/auth-stores/mem-store-nonce/pom.xml
trunk/amdatu-auth/auth-stores/mem-store-nonce/src/main/java/org/amdatu/auth/oauth/store/nonce/mem/osgi/Activator.java
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.consumerregistry.fs.cfg
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.server.cfg
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.useradmin.rest.xml
trunk/amdatu-auth/oauth-client/pom.xml
trunk/amdatu-auth/oauth-client/src/main/java/org/amdatu/auth/oauth/client/osgi/
trunk/amdatu-auth/oauth-server/pom.xml
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/osgi/Activator.java
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/service/OAuthTokenProviderImpl.java
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAccessTokenServletImpl.java
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAuthorizeTokenServletImpl.java
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthRequestTokenServletImpl.java
trunk/amdatu-auth/release-demo/pom.xml
Modified: trunk/amdatu-auth/auth-stores/fs-store-consumer/pom.xml
==============================================================================
--- trunk/amdatu-auth/auth-stores/fs-store-consumer/pom.xml (original)
+++ trunk/amdatu-auth/auth-stores/fs-store-consumer/pom.xml Wed Apr 25
15:11:29 2012
@@ -63,7 +63,11 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
-
<Bundle-Activator>org.amdatu.auth.oauth.consumerregistry.fs.osgi.Activator</Bundle-Activator>
+ <X-MultiTenant-Version>1</X-MultiTenant-Version>
+
<X-MultiTenant-Bundle-Activator>org.amdatu.auth.oauth.consumerregistry.fs.osgi.Activator</X-MultiTenant-Bundle-Activator>
+ <X-MultiTenant-Binding>TENANTS</X-MultiTenant-Binding>
+
<X-MultiTenant-Scope>(|(org.amdatu.tenant.pid=%TENANTPID%)(objectClass=org.osgi.service.log.LogService))</X-MultiTenant-Scope>
+
<Bundle-Activator>org.amdatu.tenant.adapter.MultiTenantBundleActivator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<Import-Package>
Modified:
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/osgi/Activator.java
==============================================================================
---
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/osgi/Activator.java
(original)
+++
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/osgi/Activator.java
Wed Apr 25 15:11:29 2012
@@ -32,10 +32,11 @@
@Override
public void init(final BundleContext context, final DependencyManager
manager) throws Exception {
manager.add(
- createAdapterService(Tenant.class, null)
+ createComponent()
.setImplementation(FSConsumerRegistryImpl.class)
.setInterface(OAuthServiceConsumerRegistry.class.getName(),
null)
.add(createConfigurationDependency().setPid(FSConsumerRegistryImpl.CONFIGURATION_PID))
+
.add(createServiceDependency().setService(Tenant.class).setRequired(true))
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
}
Modified:
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
==============================================================================
---
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
(original)
+++
trunk/amdatu-auth/auth-stores/fs-store-consumer/src/main/java/org/amdatu/auth/oauth/consumerregistry/fs/service/FSConsumerRegistryImpl.java
Wed Apr 25 15:11:29 2012
@@ -40,6 +40,7 @@
import org.osgi.service.cm.ManagedService;
import org.osgi.service.log.LogService;
+@SuppressWarnings("rawtypes")
public class FSConsumerRegistryImpl implements ManagedService,
OAuthServiceConsumerRegistry {
/**
* Configuration PID.
@@ -57,9 +58,10 @@
private volatile Tenant m_tenant;
private FSConsumerStorage m_storage;
+ private Dictionary m_properties = null;
- public void start() {
- // FIXME: was getId()
+ public void start() throws Exception {
+ updateConfig();
m_logService.log(LogService.LOG_INFO,
"Service '" + getClass().getName() + "' started for tenant '" +
m_tenant.getPID() + "'");
}
@@ -72,13 +74,19 @@
* @throws ConfigurationException
* In case some Config Admin exception occurred
*/
- @SuppressWarnings("rawtypes")
public synchronized void updated(final Dictionary dictionary) throws
ConfigurationException {
- if (dictionary != null) {
+ m_properties = dictionary;
+ if (m_tenant != null) {
+ updateConfig();
+ }
+ }
+
+ private synchronized void updateConfig() throws ConfigurationException {
+ if (m_properties != null) {
// NB: we must read the tenant id from the service properties
instead of injected Tenant, ass the tenant
// is not yet injected by the dependency manager at this time
String tenantId = (String) m_tenant.getPID();
- String dataDirectoryName = (String) dictionary.get(DATA_DIRECTORY);
+ String dataDirectoryName = (String)
m_properties.get(DATA_DIRECTORY);
if (dataDirectoryName == null || "".equals(dataDirectoryName)) {
throw new ConfigurationException(DATA_DIRECTORY, "Missing
mandatory data directory configuration");
}
Modified: trunk/amdatu-auth/auth-stores/mem-store-nonce/pom.xml
==============================================================================
--- trunk/amdatu-auth/auth-stores/mem-store-nonce/pom.xml (original)
+++ trunk/amdatu-auth/auth-stores/mem-store-nonce/pom.xml Wed Apr 25
15:11:29 2012
@@ -47,7 +47,11 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
-
<Bundle-Activator>org.amdatu.auth.oauth.store.nonce.mem.osgi.Activator</Bundle-Activator>
+ <X-MultiTenant-Version>1</X-MultiTenant-Version>
+
<X-MultiTenant-Bundle-Activator>org.amdatu.auth.oauth.store.nonce.mem.osgi.Activator</X-MultiTenant-Bundle-Activator>
+ <X-MultiTenant-Binding>TENANTS</X-MultiTenant-Binding>
+
<X-MultiTenant-Scope>(|(org.amdatu.tenant.pid=%TENANTPID%)(objectClass=org.osgi.service.log.LogService))</X-MultiTenant-Scope>
+
<Bundle-Activator>org.amdatu.tenant.adapter.MultiTenantBundleActivator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<Import-Package>
Modified:
trunk/amdatu-auth/auth-stores/mem-store-nonce/src/main/java/org/amdatu/auth/oauth/store/nonce/mem/osgi/Activator.java
==============================================================================
---
trunk/amdatu-auth/auth-stores/mem-store-nonce/src/main/java/org/amdatu/auth/oauth/store/nonce/mem/osgi/Activator.java
(original)
+++
trunk/amdatu-auth/auth-stores/mem-store-nonce/src/main/java/org/amdatu/auth/oauth/store/nonce/mem/osgi/Activator.java
Wed Apr 25 15:11:29 2012
@@ -33,9 +33,10 @@
public void init(final BundleContext context, final DependencyManager
manager) throws Exception {
manager.add(
- createAdapterService(Tenant.class, null)
+ createComponent()
.setImplementation(InMemNonceStorageProviderImpl.class)
.setInterface(OAuthNonceStorageProvider.class.getName(), null)
+
.add(createServiceDependency().setService(Tenant.class).setRequired(true))
.add(createServiceDependency().setService(LogService.class).setRequired(true)));
}
Added:
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.consumerregistry.fs.xml
==============================================================================
--- (empty file)
+++
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.consumerregistry.fs.xml
Wed Apr 25 15:11:29 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2010-2012 The Amdatu Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
filter="(org.amdatu.tenant.pid=${amdatu.tenant.id})">
+ <OCD name="Amdatu Auth - OAuth Consumer FS Store Config"
id="org.amdatu.auth.oauth.consumerregistry.fs">
+ <AD id="datadir" type="STRING" cardinality="0" />
+ </OCD>
+ <Designate pid="org.amdatu.auth.oauth.consumerregistry.fs" bundle="*">
+ <Object ocdref="org.amdatu.auth.oauth.consumerregistry.fs">
+ <Attribute adref="datadir">
+ <Value>work/consumerregistrystore</Value>
+ </Attribute>
+ </Object>
+ </Designate>
+</MetaData>
\ No newline at end of file
Added:
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.server.xml
==============================================================================
--- (empty file)
+++
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.oauth.server.xml
Wed Apr 25 15:11:29 2012
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2010-2012 The Amdatu Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
filter="(org.amdatu.tenant.pid=${amdatu.tenant.id})">
+ <OCD name="Amdatu Auth - OAuth Consumer FS Store Config"
id="org.amdatu.auth.oauth.server">
+ <AD id="hostname" type="STRING" cardinality="0" />
+ <AD id="portnr" type="STRING" cardinality="0" />
+ <AD id="authorizeurl" type="STRING" cardinality="0" />
+ <AD id="request.timestamp.maxage" type="LONG" cardinality="0" />
+ <AD id="request.token.maxage" type="LONG" cardinality="0" />
+ <AD id="access.token.maxage" type="LONG" cardinality="0" />
+ <AD id="access.token.timeout" type="LONG" cardinality="0" />
+ </OCD>
+ <Designate pid="org.amdatu.auth.oauth.server" bundle="*">
+ <Object ocdref="org.amdatu.auth.oauth.server">
+ <!-- The hostname and portnr -->
+ <Attribute adref="hostname">
+ <Value>${amdatu.http.hostname}</Value>
+ </Attribute>
+ <Attribute adref="portnr">
+ <Value>${amdatu.http.port}</Value>
+ </Attribute>
+ <Attribute adref="authorizeurl">
+ <Value>/oauth-server/jsp/authorize.jsp</Value>
+ </Attribute>
+
+ <!-- The lifetime of an OAuth request is limited to
request.timestamp.maxage.
+ This defines the maximum amount of time between the signing of an
OAuth
+ request (at which point the oauth_timestamp is added to it) and the
+ receipt of the request.
+ Defaults to 300000 (5 minutes). -->
+ <Attribute adref="request.timestamp.maxage">
+ <Value>300000</Value>
+ </Attribute>
+
+ <!-- The lifetime of a request token is limited to request.token.maxage.
It must
+ be exchanged for an access token before this maxage. If the request
token
+ reached its maxage it is invalidated and cannot be exchanged for an
access
+ token anymore.
+ Defaults to 300000 (5 minutes). -->
+ <Attribute adref="request.token.maxage">
+ <Value>300000</Value>
+ </Attribute>
+
+ <!-- The lifetime of an access token is limited to access.token.maxage.
This is
+ an absolute maximum; the token always expires after this amount of
milliseconds,
+ even if the token is still actively used. Can be a negative number,
in which case
+ the access token does not expire. Can be used in combination with
access.token.timeout,
+ in which case BOTH apply.
+ Defaults to -1 (no maximum age). -->
+ <Attribute adref="access.token.maxage">
+ <Value>-1</Value>
+ </Attribute>
+
+ <!-- The access token is invalidated when it is not used (that is; send
along
+ with an OAuth request) for more then access.token.timeout
milliseconds.
+ Defaults to 1800000, meaning that the access token becomes invalid
when
+ it not used for a duration of 30 minutes.
+ May be a negative number, in which case the access token does not
timeout.
+ Can be used in combination with access.token.timeout, in which case
BOTH apply. -->
+ <Attribute adref="access.token.timeout">
+ <Value>1800000</Value>
+ </Attribute>
+ </Object>
+ </Designate>
+</MetaData>
+
+
+
+
+
+
+
+
Modified:
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.useradmin.rest.xml
==============================================================================
---
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.useradmin.rest.xml
(original)
+++
trunk/amdatu-auth/config/src/main/resources/org.amdatu.auth.useradmin.rest.xml
Wed Apr 25 15:11:29 2012
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
filter="(org.amdatu.tenant.pid=tenant1)">
+<MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
filter="(org.amdatu.tenant.pid=${amdatu.tenant.id})">
<OCD name="Amdatu Auth - UserAdmin REST service config"
id="org.amdatu.auth.useradmin.rest">
<AD id="password.minimum_length" type="INTEGER" cardinality="0" />
<AD id="password.require_mixed_case" type="BOOLEAN" cardinality="0" />
Modified: trunk/amdatu-auth/oauth-client/pom.xml
==============================================================================
--- trunk/amdatu-auth/oauth-client/pom.xml (original)
+++ trunk/amdatu-auth/oauth-client/pom.xml Wed Apr 25 15:11:29 2012
@@ -83,7 +83,6 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
-
<Bundle-Activator>org.amdatu.auth.oauth.client.osgi.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>org.amdatu.auth.oauth.client</Export-Package>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
Modified: trunk/amdatu-auth/oauth-server/pom.xml
==============================================================================
--- trunk/amdatu-auth/oauth-server/pom.xml (original)
+++ trunk/amdatu-auth/oauth-server/pom.xml Wed Apr 25 15:11:29 2012
@@ -67,20 +67,9 @@
</dependency>
<dependency>
<groupId>org.amdatu.web</groupId>
- <artifactId>org.amdatu.web.jaxrs</artifactId>
- <type>bundle</type>
- </dependency>
- <dependency>
- <groupId>org.amdatu.web</groupId>
<artifactId>org.amdatu.web.resource</artifactId>
<type>bundle</type>
</dependency>
- <dependency>
- <groupId>org.amdatu.osgisupport</groupId>
- <artifactId>org.amdatu.osgisupport</artifactId>
- <!-- FIXME: must become org.amdatu.platform.version -->
- <version>0.4.0-RC2</version>
- </dependency>
<dependency>
<groupId>commons-codec</groupId>
@@ -116,7 +105,11 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
-
<Bundle-Activator>org.amdatu.auth.oauth.server.osgi.Activator</Bundle-Activator>
+ <X-MultiTenant-Version>1</X-MultiTenant-Version>
+
<X-MultiTenant-Bundle-Activator>org.amdatu.auth.oauth.server.osgi.Activator</X-MultiTenant-Bundle-Activator>
+ <X-MultiTenant-Binding>TENANTS</X-MultiTenant-Binding>
+
<X-MultiTenant-Scope>(|(org.amdatu.tenant.pid=%TENANTPID%)(objectClass=org.osgi.service.log.LogService))</X-MultiTenant-Scope>
+
<Bundle-Activator>org.amdatu.tenant.adapter.MultiTenantBundleActivator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
net.oauth.*;version="[1.0,2.0)",
Modified:
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/osgi/Activator.java
==============================================================================
---
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/osgi/Activator.java
(original)
+++
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/osgi/Activator.java
Wed Apr 25 15:11:29 2012
@@ -16,8 +16,10 @@
package org.amdatu.auth.oauth.server.osgi;
import org.amdatu.auth.oauth.api.OAuthServiceProvider;
+import org.amdatu.auth.oauth.consumerregistry.OAuthServiceConsumerRegistry;
import org.amdatu.auth.oauth.server.OAuthAccessTokenServlet;
import org.amdatu.auth.oauth.server.OAuthAuthorizeTokenServlet;
+import org.amdatu.auth.oauth.server.OAuthNonceStorageProvider;
import org.amdatu.auth.oauth.server.OAuthRequestTokenServlet;
import org.amdatu.auth.oauth.server.OAuthServerConfig;
import org.amdatu.auth.oauth.server.OAuthTokenProvider;
@@ -29,10 +31,10 @@
import org.amdatu.auth.oauth.server.servlet.OAuthAccessTokenServletImpl;
import org.amdatu.auth.oauth.server.servlet.OAuthAuthorizeTokenServletImpl;
import org.amdatu.auth.oauth.server.servlet.OAuthRequestTokenServletImpl;
-import org.amdatu.libraries.osgi.ServiceDependentActivator;
+import org.amdatu.auth.tokenprovider.TokenProvider;
+import org.amdatu.auth.tokenprovider.TokenStorageProvider;
import org.amdatu.tenant.Tenant;
import org.amdatu.web.httpcontext.ResourceProvider;
-import org.amdatu.web.rest.jaxrs.JaxRsSpi;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -40,6 +42,7 @@
import javax.servlet.Servlet;
import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.cm.ManagedService;
@@ -47,10 +50,10 @@
/**
* This is the activator for the oAuth server bundle.
- *
+ *
* @author ivol
*/
-public class Activator extends ServiceDependentActivator {
+public class Activator extends DependencyActivatorBase {
/**
* Context id of the Authorization HTTP Context.
*/
@@ -72,19 +75,18 @@
public static final String RES_ALIAS = ALIAS + "/static";
@Override
- protected Class<?>[] getRequiredServices() {
- return new Class<?>[] {JaxRsSpi.class};
- }
-
- @Override
- public void initWithDependencies(final BundleContext context, final
DependencyManager manager) throws Exception {
+ public void init(final BundleContext context, final DependencyManager
manager) throws Exception {
// Create and register the OAuth token provider service component.
manager.add(
- createAdapterService(Tenant.class, null)
+ createComponent()
.setInterface(OAuthTokenProvider.class.getName(), null)
.setImplementation(OAuthTokenProviderImpl.class)
+
.add(createServiceDependency().setService(Tenant.class).setRequired(true))
.add(createServiceDependency().setService(LogService.class).setRequired(true))
.add(createServiceDependency().setService(OAuthServiceProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(TokenStorageProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(OAuthNonceStorageProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(OAuthServiceConsumerRegistry.class).setRequired(true))
.add(createServiceDependency().setService(OAuthServerConfiguration.class).setRequired(true)));
// Create and register the resource provider
@@ -128,15 +130,18 @@
Dictionary<String, String> servletProperties = new Hashtable<String,
String>();
servletProperties.put(org.amdatu.web.dispatcher.Constants.ALIAS_KEY,
alias);
servletProperties.put(org.amdatu.web.dispatcher.Constants.CONTEXT_ID_KEY,
CONTEXTID);
- return createAdapterService(OAuthTokenProvider.class, null)
+ return createComponent()
.setInterface(new String[] {servletInterface.getName(),
Servlet.class.getName()}, servletProperties)
.setImplementation(servletClass)
.add(createServiceDependency().setService(OAuthServiceProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(OAuthTokenProvider.class).setRequired(true))
+
.add(createServiceDependency().setService(Tenant.class).setRequired(true))
+
.add(createServiceDependency().setService(TokenProvider.class).setRequired(true))
.add(createServiceDependency().setService(LogService.class).setRequired(true));
}
@Override
- public void destroy(final BundleContext bundleContext, final
DependencyManager dependencyManager) throws Exception {
+ public void destroy(final BundleContext context, final DependencyManager
manager) throws Exception {
}
}
Modified:
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/service/OAuthTokenProviderImpl.java
==============================================================================
---
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/service/OAuthTokenProviderImpl.java
(original)
+++
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/service/OAuthTokenProviderImpl.java
Wed Apr 25 15:11:29 2012
@@ -35,14 +35,8 @@
import java.io.IOException;
import java.math.BigInteger;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
-import org.apache.felix.dm.ServiceDependency;
-import org.osgi.framework.Constants;
import org.osgi.service.log.LogService;
public class OAuthTokenProviderImpl implements OAuthTokenProvider {
@@ -54,7 +48,6 @@
private volatile OAuthServiceProvider m_serviceProvider;
private volatile OAuthServerConfiguration m_config;
private volatile Tenant m_tenant;
- private volatile DependencyManager m_dependencyManager;
// Tenant aware service dependencies
private volatile TokenStorageProvider m_tokenStore;
@@ -64,17 +57,6 @@
// The simple oAuth validator.
private PluggableOAuthValidator m_oAuthValidator;
- public void init(final Component component) {
- List<ServiceDependency> dependencies = new
ArrayList<ServiceDependency>();
-
- // Define tenant aware service dependencies
-
dependencies.add(getTenantServiceDependency(TokenStorageProvider.class));
-
dependencies.add(getTenantServiceDependency(OAuthNonceStorageProvider.class));
-
dependencies.add(getTenantServiceDependency(OAuthServiceConsumerRegistry.class));
-
- component.add(dependencies);
- }
-
public void start() {
// Create an OAuth validator with the specified maximum age
long requestMaxAge = m_config.getRequestTimestampMaxAge();
@@ -90,14 +72,6 @@
"Service '" + getClass().getName() + "' started for tenant '" +
m_tenant.getPID() + "'");
}
- private ServiceDependency getTenantServiceDependency(final Class<?> clazz)
{
- String tenantFilter = "(&(" + org.amdatu.tenant.Constants.PID_KEY +
"=" + m_tenant.getPID()
- + ")(" + Constants.OBJECTCLASS + "=" + clazz.getName() + "))";
- return m_dependencyManager.createServiceDependency()
- .setService(clazz, tenantFilter)
- .setRequired(true)
- .setInstanceBound(true);
- }
public synchronized OAuthConsumer getConsumer(final OAuthMessage
requestMessage) throws OAuthException {
try {
Modified:
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAccessTokenServletImpl.java
==============================================================================
---
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAccessTokenServletImpl.java
(original)
+++
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAccessTokenServletImpl.java
Wed Apr 25 15:11:29 2012
@@ -33,7 +33,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.felix.dm.Component;
import org.osgi.service.log.LogService;
public class OAuthAccessTokenServletImpl extends HttpServlet implements
OAuthAccessTokenServlet {
@@ -43,16 +42,11 @@
// Service dependencies, injected by the Felix dependency manager
private volatile LogService m_logService;
private volatile OAuthTokenProvider m_tokenProvider;
-
- private String m_tenantId;
-
- public void init(final Component component) {
- m_tenantId =
component.getServiceProperties().get(org.amdatu.tenant.Constants.PID_KEY).toString();
- }
+ private volatile Tenant m_tenant;
public void start() {
m_logService.log(LogService.LOG_INFO,
- "Service '" + getClass().getName() + "' started for tenant '" +
m_tenantId + "'");
+ "Service '" + getClass().getName() + "' started for tenant '" +
m_tenant.getPID() + "'");
}
@Override
@@ -100,7 +94,7 @@
response.setContentType("text/plain");
OutputStream out = null;
try {
- // TODO: We need to explore the possibilities to add
additional information to the OAuth tokens,
+ // NB: We need to explore the possibilities to add additional
information to the OAuth tokens,
// like a tenant id.
out = response.getOutputStream();
OAuth.formEncode(OAuth.newList(OAuth.OAUTH_TOKEN,
accessToken.getToken(), OAuth.OAUTH_TOKEN_SECRET,
Modified:
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAuthorizeTokenServletImpl.java
==============================================================================
---
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAuthorizeTokenServletImpl.java
(original)
+++
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthAuthorizeTokenServletImpl.java
Wed Apr 25 15:11:29 2012
@@ -40,9 +40,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.DependencyManager;
-import org.osgi.framework.Constants;
import org.osgi.service.log.LogService;
public class OAuthAuthorizeTokenServletImpl extends HttpServlet implements
OAuthAuthorizeTokenServlet {
@@ -54,26 +51,13 @@
private volatile TokenProvider m_tokenProvider;
private volatile OAuthTokenProvider m_oAuthTokenProvider;
private volatile OAuthServiceProvider m_serviceProvider;
- private volatile DependencyManager m_dependencyManager;
-
- private String m_tenantId;
-
- public void init(final Component component) {
- m_tenantId =
component.getServiceProperties().get(org.amdatu.tenant.Constants.PID_KEY).toString();
-
- // Create a service dependency on the token provider for 'our' tenant
- String tenantFilter =
- "(&(" + org.amdatu.tenant.Constants.PID_KEY + "=" + m_tenantId +
")(" + Constants.OBJECTCLASS
- + "=" + TokenProvider.class.getName() + "))";
- component.add(m_dependencyManager.createServiceDependency()
- .setService(TokenProvider.class,
tenantFilter).setRequired(true).setInstanceBound(true));
- }
+ private volatile Tenant m_tenant;
public void start() {
m_logService.log(LogService.LOG_INFO,
- "Service '" + getClass().getName() + "' started for tenant '" +
m_tenantId + "'");
+ "Service '" + getClass().getName() + "' started for tenant '" +
m_tenant.getPID() + "'");
}
-
+
@Override
public void doGet(final HttpServletRequest request, final
HttpServletResponse response) throws IOException,
ServletException {
Modified:
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthRequestTokenServletImpl.java
==============================================================================
---
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthRequestTokenServletImpl.java
(original)
+++
trunk/amdatu-auth/oauth-server/src/main/java/org/amdatu/auth/oauth/server/servlet/OAuthRequestTokenServletImpl.java
Wed Apr 25 15:11:29 2012
@@ -33,7 +33,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.felix.dm.Component;
import org.osgi.service.log.LogService;
/**
@@ -51,16 +50,11 @@
// Service dependencies, injected by the Felix dependency manager
private volatile LogService m_logService;
private volatile OAuthTokenProvider m_tokenProvider;
-
- private String m_tenantId;
-
- public void init(final Component component) {
- m_tenantId = component.getServiceProperties().get(
org.amdatu.tenant.Constants.PID_KEY).toString();
- }
+ private volatile Tenant m_tenant;
public void start() {
m_logService.log(LogService.LOG_INFO,
- "Service '" + getClass().getName() + "' started for tenant '" +
m_tenantId + "'");
+ "Service '" + getClass().getName() + "' started for tenant '" +
m_tenant.getPID() + "'");
}
@Override
Modified: trunk/amdatu-auth/release-demo/pom.xml
==============================================================================
--- trunk/amdatu-auth/release-demo/pom.xml (original)
+++ trunk/amdatu-auth/release-demo/pom.xml Wed Apr 25 15:11:29 2012
@@ -332,8 +332,6 @@
<type>bundle</type>
<scope>compile</scope>
</dependency>
-
-<!--
<dependency>
<groupId>org.amdatu.auth</groupId>
<artifactId>org.amdatu.auth.oauth.client</artifactId>
@@ -346,8 +344,15 @@
<type>bundle</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.amdatu.auth</groupId>
+ <artifactId>org.amdatu.auth.oauth.store.nonce.mem</artifactId>
+ <type>bundle</type>
+ <scope>compile</scope>
+ </dependency>
+<!--
<dependency>
<groupId>org.amdatu.auth</groupId>
<artifactId>org.amdatu.auth.example.oauth.consumer</artifactId>
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits