/*
 * Copyright 2014 Open mHealth
 *
 * 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.
 */

package org.openmhealth.dsu.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.client.InMemoryClientDetailsService;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;

import javax.sql.DataSource;


/**
 * A configuration of OAuth2 support objects backed by a relational database. The DDL files to create the corresponding
 * database schemas are available in the resources directory at the root of the project.
 *
 * @author Emerson Farrugia
 */
@Configuration
public class JdbcOAuth2SupportConfguration {

    @Autowired
    private DataSource dataSource;

    /**
     * @return the store used to persist OAuth2 access and refresh tokens
     */
    @Bean
    public TokenStore tokenStore() {

        return new JdbcTokenStore(dataSource);
    }

    /**
     * @return the service used to retrieve OAuth2 client details
     */
    @Bean
    public ClientDetailsService clientDetailsService() {

        // FIXME revert this to the JDBC implementation once the schema is added
        // return new JdbcClientDetailsService(dataSource);
        return new InMemoryClientDetailsService();
    }
}

@@ -943,24 +943,20 @@
 .client.
-InMemory
+Jdbc
 ClientDe
@@ -1865,189 +1865,54 @@
     
-// FIXME revert this to the JDBC implementation once the schema is added%0A        // return new JdbcClientDetailsService(dataSource);%0A        return new InMemoryClientDetailsService(
+return new JdbcClientDetailsService(dataSource
 );%0A 

Enable the JDBC client details service.