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.builders;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.springframework.security.oauth2.provider.ClientDetails;
22  import org.springframework.security.oauth2.provider.ClientDetailsService;
23  import org.springframework.security.oauth2.provider.client.InMemoryClientDetailsService;
24  
25  /**
26   * @author Dave Syer
27   * 
28   */
29  public class InMemoryClientDetailsServiceBuilder extends
30  		ClientDetailsServiceBuilder<InMemoryClientDetailsServiceBuilder> {
31  
32  	private Map<String, ClientDetails> clientDetails = new HashMap<String, ClientDetails>();
33  
34  	@Override
35  	protected void addClient(String clientId, ClientDetails value) {
36  		clientDetails.put(clientId, value);
37  	}
38  
39  	@Override
40  	protected ClientDetailsService performBuild() {
41  		InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService();
42  		clientDetailsService.setClientDetailsStore(clientDetails);
43  		return clientDetailsService;
44  	}
45  
46  }