View Javadoc
1   /*
2    * Copyright 2002-2013 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.security.oauth2.config.annotation.configurers;
17  
18  import javax.sql.DataSource;
19  
20  import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
21  import org.springframework.security.oauth2.config.annotation.builders.ClientDetailsServiceBuilder;
22  import org.springframework.security.oauth2.config.annotation.builders.InMemoryClientDetailsServiceBuilder;
23  import org.springframework.security.oauth2.config.annotation.builders.JdbcClientDetailsServiceBuilder;
24  import org.springframework.security.oauth2.provider.ClientDetailsService;
25  
26  /**
27   * @author Rob Winch
28   * 
29   */
30  public class ClientDetailsServiceConfigurer extends
31  		SecurityConfigurerAdapter<ClientDetailsService, ClientDetailsServiceBuilder<?>> {
32  
33  	public ClientDetailsServiceConfigurer(ClientDetailsServiceBuilder<?> builder) {
34  		setBuilder(builder);
35  	}
36  
37  	public ClientDetailsServiceBuilder<?> withClientDetails(ClientDetailsService clientDetailsService) throws Exception {
38  		setBuilder(getBuilder().clients(clientDetailsService));
39  		return this.and();
40  	}
41  
42  	public InMemoryClientDetailsServiceBuilder inMemory() throws Exception {
43  		InMemoryClientDetailsServiceBuilder next = getBuilder().inMemory();
44  		setBuilder(next);
45  		return next;
46  	}
47  	public JdbcClientDetailsServiceBuilder jdbc(DataSource dataSource) throws Exception {
48  		JdbcClientDetailsServiceBuilder next = getBuilder().jdbc().dataSource(dataSource);
49  		setBuilder(next);
50  		return next;
51  	}
52  	
53  	@Override
54  	public void init(ClientDetailsServiceBuilder<?> builder) throws Exception {
55  	}
56  
57  	@Override
58  	public void configure(ClientDetailsServiceBuilder<?> builder) throws Exception {
59  	}
60  
61  }