Add encryption for passwords
[clamp.git] / src / main / java / org / onap / clamp / clds / config / CldsConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); 
9  * you may not use this file except in compliance with the License. 
10  * You may obtain a copy of the License at
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software 
15  * distributed under the License is distributed on an "AS IS" BASIS, 
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17  * See the License for the specific language governing permissions and 
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.config;
25
26 import com.att.ajsc.common.AjscProvider;
27 import com.att.ajsc.common.AjscService;
28
29 import java.security.GeneralSecurityException;
30 import java.util.ArrayList;
31 import java.util.List;
32
33 import javax.sql.DataSource;
34 import javax.xml.transform.TransformerConfigurationException;
35
36 import org.onap.clamp.clds.client.CldsEventDelegate;
37 import org.onap.clamp.clds.client.DcaeDispatcherServices;
38 import org.onap.clamp.clds.client.DcaeInventoryServices;
39 import org.onap.clamp.clds.client.HolmesPolicyDelegate;
40 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
41 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
42 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
43 import org.onap.clamp.clds.client.PolicyClient;
44 import org.onap.clamp.clds.client.SdcCatalogServices;
45 import org.onap.clamp.clds.client.SdcSendReqDelegate;
46 import org.onap.clamp.clds.client.TcaPolicyDelegate;
47 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
48 import org.onap.clamp.clds.client.req.SdcReq;
49 import org.onap.clamp.clds.dao.CldsDao;
50 import org.onap.clamp.clds.model.refprop.RefProp;
51 import org.onap.clamp.clds.transform.XslTransformer;
52 import org.springframework.beans.factory.annotation.Autowired;
53 import org.springframework.beans.factory.annotation.Qualifier;
54 import org.springframework.boot.context.properties.ConfigurationProperties;
55 import org.springframework.context.ApplicationContext;
56 import org.springframework.context.annotation.Bean;
57 import org.springframework.context.annotation.Configuration;
58 import org.springframework.context.annotation.Profile;
59
60 @Configuration
61 @Profile("clamp-default")
62 public class CldsConfiguration {
63     @Autowired
64     private ApplicationContext context;
65
66     /**
67      * Clds Identity database DataSource configuration
68      * 
69      * @return
70      */
71     @Bean(name = "cldsDataSource")
72     @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
73     public DataSource cldsDataSource() {
74         return new EncodedPasswordBasicDataSource();
75     }
76
77     @Bean(name = "jaxrsProviders")
78     public List<?> jaxrsProviders() {
79         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
80     }
81
82     @Bean(name = "jaxrsServices")
83     public List<?> jaxrsServices() {
84         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
85     }
86
87     @Bean(name = "cldsDao")
88     public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
89         CldsDao cldsDao = new CldsDao();
90         cldsDao.setDataSource(dataSource);
91         return cldsDao;
92     }
93
94     @Bean(name = "cldsBpmnTransformer")
95     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
96         XslTransformer xslTransformer = new XslTransformer();
97         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
98         return xslTransformer;
99     }
100
101     @Bean
102     public RefProp getRefProp() {
103         return new RefProp();
104     }
105
106     @Bean
107     public SdcReq getSdcReq() {
108         return new SdcReq();
109     }
110
111     @Bean
112     public PolicyClient getPolicyClient() {
113         return new PolicyClient();
114     }
115
116     @Bean(name = "cldsEventDelegate")
117     public CldsEventDelegate getCldsEventDelegate() {
118         return new CldsEventDelegate();
119     }
120
121     @Bean(name = "sdcSendReqDelegate")
122     public SdcSendReqDelegate getSdcSendReqDelegate() {
123         return new SdcSendReqDelegate();
124     }
125
126     @Bean(name = "operationalPolicyDelegate")
127     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
128         return new OperationalPolicyDelegate();
129     }
130
131     @Bean(name = "operationalPolicyDeleteDelegate")
132     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
133         return new OperationalPolicyDeleteDelegate();
134     }
135
136     @Bean(name = "sdcCatalogServices")
137     public SdcCatalogServices getSdcCatalogServices() {
138         return new SdcCatalogServices();
139     }
140
141     @Bean(name = "dcaeDispatcherServices")
142     public DcaeDispatcherServices getDcaeDispatcherServices() {
143         return new DcaeDispatcherServices();
144     }
145
146     @Bean(name = "dcaeInventoryServices")
147     public DcaeInventoryServices getDcaeInventoryServices() {
148         return new DcaeInventoryServices();
149     }
150
151     @Bean(name = "tcaPolicyDelegate")
152     public TcaPolicyDelegate getTcaPolicyDelegate() {
153         return new TcaPolicyDelegate();
154     }
155
156     @Bean(name = "tcaPolicyDeleteDelegate")
157     public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
158         return new TcaPolicyDeleteDelegate();
159     }
160
161     @Bean(name = "holmesPolicyDelegate")
162     public HolmesPolicyDelegate getHolmesPolicyDelegate() {
163         return new HolmesPolicyDelegate();
164     }
165
166     @Bean(name = "holmesPolicyDeleteDelegate")
167     public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
168         return new HolmesPolicyDeleteDelegate();
169     }
170 }