<commit_before>/*
 * Copyright 2012 SURFnet bv, The Netherlands
 *
 * 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 nl.surfnet.coin.api.service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth.common.OAuthException;
import org.springframework.security.oauth.common.signature.SharedConsumerSecret;
import org.springframework.security.oauth.provider.ConsumerDetails;
import org.springframework.security.oauth.provider.ConsumerDetailsService;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;

import nl.surfnet.coin.api.oauth.ClientMetaData;
import nl.surfnet.coin.api.oauth.ClientMetaDataHolder;
import nl.surfnet.coin.api.oauth.ExtendedBaseClientDetails;
import nl.surfnet.coin.api.oauth.ExtendedBaseConsumerDetails;
import nl.surfnet.coin.janus.Janus;

/**
 * Mock details service. Replacement for JanusClientDetailsService.
 */
public class MockClientDetailsService implements ClientDetailsService, ConsumerDetailsService {

  private static final Logger LOG = LoggerFactory.getLogger(MockClientDetailsService.class);

  private String defaultSecret = "mysecret";
  private static final String CALLBACK_URL = "http://localhost:8080/mock-callback-url";

  @Override
  public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
    final ExtendedBaseClientDetails details = new ExtendedBaseClientDetails();
    details.setClientId(clientId);
    details.setScope(Arrays.asList("read"));
    details.setClientSecret(defaultSecret);<commit_msg>fixed selenium test on dev.<commit_after>/*
 * Copyright 2012 SURFnet bv, The Netherlands
 *
 * 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 nl.surfnet.coin.api.service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth.common.OAuthException;
import org.springframework.security.oauth.common.signature.SharedConsumerSecret;
import org.springframework.security.oauth.provider.ConsumerDetails;
import org.springframework.security.oauth.provider.ConsumerDetailsService;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;

import nl.surfnet.coin.api.oauth.ClientMetaData;
import nl.surfnet.coin.api.oauth.ClientMetaDataHolder;
import nl.surfnet.coin.api.oauth.ExtendedBaseClientDetails;
import nl.surfnet.coin.api.oauth.ExtendedBaseConsumerDetails;
import nl.surfnet.coin.janus.Janus;

/**
 * Mock details service. Replacement for JanusClientDetailsService.
 */
public class MockClientDetailsService implements ClientDetailsService, ConsumerDetailsService {

  private static final Logger LOG = LoggerFactory.getLogger(MockClientDetailsService.class);

  private String defaultSecret = "mysecret";
  private static final String CALLBACK_URL = "http://localhost/mock-callback-url";

  @Override
  public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
    final ExtendedBaseClientDetails details = new ExtendedBaseClientDetails();
    details.setClientId(clientId);
    details.setScope(Arrays.asList("read"));
    details.setClientSecret(defaultSecret);
{'fraction_non_alphanumeric': 0.0850194154915185, 'fraction_numerical': 0.006948702227672185, 'mean_word_length': 5.704109589041096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '833979', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1322, 'n_words': 343}