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====================================================
23 package org.onap.aaf.auth.hello;
27 import javax.servlet.Filter;
29 import org.onap.aaf.auth.env.AuthzEnv;
30 import org.onap.aaf.auth.env.AuthzTrans;
31 import org.onap.aaf.auth.env.AuthzTransFilter;
32 import org.onap.aaf.auth.rserv.HttpCode;
33 import org.onap.aaf.auth.rserv.HttpMethods;
34 import org.onap.aaf.auth.server.AbsService;
35 import org.onap.aaf.auth.server.JettyServiceStarter;
36 import org.onap.aaf.auth.server.Log4JLogIt;
37 import org.onap.aaf.cadi.CadiException;
38 import org.onap.aaf.cadi.LocatorException;
39 import org.onap.aaf.cadi.PropAccess;
40 import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn;
41 import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm;
42 import org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker;
43 import org.onap.aaf.cadi.config.Config;
44 import org.onap.aaf.cadi.register.Registrant;
45 import org.onap.aaf.cadi.register.RemoteRegistrant;
46 import org.onap.aaf.misc.env.APIException;
47 import org.onap.aaf.misc.env.Env;
49 public class AAF_Hello extends AbsService<AuthzEnv,AuthzTrans> {
50 public enum API{TOKEN_REQ, TOKEN,INTROSPECT, ERROR,VOID};
51 public AAFAuthn<?> aafAuthn;
52 public AAFLurPerm aafLurPerm;
55 * Construct AuthzAPI with all the Context Supporting Routes that Authz needs
58 * @throws APIException
60 public AAF_Hello(final AuthzEnv env) throws Exception {
61 super(env.access(), env);
63 aafLurPerm = aafCon().newLur();
64 // Note: If you need both Authn and Authz construct the following:
65 aafAuthn = aafCon().newAuthn(aafLurPerm);
67 String aaf_env = env.getProperty(Config.AAF_ENV);
69 throw new APIException("aaf_env needs to be set");
72 // Initialize Facade for all uses
73 AuthzTrans trans = env.newTrans();
74 StringBuilder sb = new StringBuilder();
75 trans.auditTrail(2, sb);
82 * Setup XML and JSON implementations for each supported Version type
84 * We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties
85 * to do Versions and Content switches
88 public void route(HttpMethods meth, String path, API api, HttpCode<AuthzTrans, AAF_Hello> code){
89 String version = "1.0";
90 // Get Correct API Class from Mapper
91 route(env,meth,path,code,"text/plain;version="+version,"*/*");
95 public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
98 new AuthzTransFilter(env,aafCon(),
99 new AAFTrustChecker((Env)env),
102 } catch (NumberFormatException e) {
103 throw new CadiException("Invalid Property information", e);
107 @SuppressWarnings("unchecked")
109 public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException {
110 return new Registrant[] {
111 new RemoteRegistrant<AuthzEnv>(aafCon(),port)
115 public static void main(final String[] args) {
117 Log4JLogIt logIt = new Log4JLogIt(args, "hello");
118 PropAccess propAccess = new PropAccess(logIt,args);
121 new JettyServiceStarter<AuthzEnv,AuthzTrans>(
122 new AAF_Hello(new AuthzEnv(propAccess)),true)
124 } catch (Exception e) {
127 } catch (Exception e) {