1 package org.onap.so.svnfm.simulator.oauth;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.context.annotation.Profile;
7 import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
8 import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
9 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
12 @EnableAuthorizationServer
13 @Profile("oauth-authentication")
15 * Configures the authorization server for oauth token based authentication when the spring profile
16 * "oauth-authentication" is active
18 public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
19 private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationServerConfig.class);
21 private static final int ONE_DAY = 60 * 60 * 24;
24 public void configure(final ClientDetailsServiceConfigurer clients) throws Exception {
25 LOGGER.info("configuring oauth-authentication ...");
26 clients.inMemory().withClient("vnfm")
27 .secret("$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke") //password1$
28 .authorizedGrantTypes("client_credentials").scopes("write").accessTokenValiditySeconds(ONE_DAY)
29 .refreshTokenValiditySeconds(ONE_DAY);