63d4a31f11501961bfbea876249e923ecb14fb96
[appc.git] /
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP : APPC\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Copyright (C) 2017 Amdocs\r
8  * =============================================================================\r
9  * Licensed under the Apache License, Version 2.0 (the "License");\r
10  * you may not use this file except in compliance with the License.\r
11  * You may obtain a copy of the License at\r
12  * \r
13  *      http://www.apache.org/licenses/LICENSE-2.0\r
14  * \r
15  * Unless required by applicable law or agreed to in writing, software\r
16  * distributed under the License is distributed on an "AS IS" BASIS,\r
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
18  * See the License for the specific language governing permissions and\r
19  * limitations under the License.\r
20  * \r
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  * ============LICENSE_END=========================================================\r
23  */\r
24 \r
25 package org.openecomp.appc.adapter.iaas.impl;\r
26 \r
27 import java.util.Properties;\r
28 \r
29 public class ServiceCatalogFactory {\r
30 \r
31     /**\r
32      * This method accepts a fully qualified identity service URL and uses that to determine which version of the\r
33      * serviceCatalog to load.\r
34      *\r
35      * @param url The parsed URL of the identity service\r
36      * @param projectIdentifier The project or tenant to be used to connect to the service\r
37      * @param principal The principal or user to be used to connect to the service\r
38      * @param ceredential The credential or password to be used to connect to the service\r
39      * @param properties Properties object for proxy information\r
40      * @return The serviceCatalog for identity service version specified in the url, null if not supported.\r
41      */\r
42     public static ServiceCatalog getServiceCatalog(String url, String projectIdentifier, String principal,\r
43             String credential, String domain, Properties properties) {\r
44         String version = IdentityURL.parseURL(url).getVersion();\r
45         String prefix = version.split("\\.")[0];\r
46 \r
47         if (prefix != null) {\r
48             switch (prefix) {\r
49                 case "v2":\r
50                     return new ServiceCatalogV2(url, projectIdentifier, principal, credential, properties);\r
51                 case "v3":\r
52                     return new ServiceCatalogV3(url, projectIdentifier, principal, credential, domain, properties);\r
53             }\r
54         }\r
55         return null;\r
56     }\r
57 }\r