2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.cadi.enduser;
23 import java.io.IOException;
24 import java.net.URISyntaxException;
25 import java.security.GeneralSecurityException;
27 import org.onap.aaf.cadi.Access;
28 import org.onap.aaf.cadi.CadiException;
29 import org.onap.aaf.cadi.LocatorException;
30 import org.onap.aaf.cadi.PropAccess;
31 import org.onap.aaf.cadi.config.Config;
32 import org.onap.aaf.cadi.oauth.TokenClientFactory;
33 import org.onap.aaf.misc.env.APIException;
35 public class ClientFactory {
36 private final TokenClientFactory tcf;
37 public ClientFactory(final PropAccess access) throws APIException, CadiException {
39 tcf = TokenClientFactory.instance(access);
40 } catch (GeneralSecurityException | IOException e) {
41 throw new CadiException(e);
45 public ClientFactory(String[] args) throws APIException, CadiException {
46 this(new PropAccess(args));
49 public SimpleRESTClient simpleRESTClient(final String endpoint, final String ... scopes) throws URISyntaxException, LocatorException, CadiException, APIException {
50 return new SimpleRESTClient(tcf, Config.AAF_OAUTH2_TOKEN_URL, endpoint, scopes);
53 public Access getAccess() {