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====================================================
22 package org.onap.aaf.auth.cui;
24 import java.io.PrintWriter;
26 import javax.servlet.ServletInputStream;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
30 import org.onap.aaf.auth.cmd.AAFcli;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.auth.gui.AAF_GUI;
33 import org.onap.aaf.auth.rserv.HttpCode;
34 import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
35 import org.onap.aaf.cadi.http.HTransferSS;
36 import org.onap.aaf.cadi.principal.TaggedPrincipal;
37 import org.onap.aaf.misc.env.Env;
38 import org.onap.aaf.misc.env.TimeTaken;
40 public class CUI extends HttpCode<AuthzTrans, Void> {
41 private final AAF_GUI gui;
42 public CUI(AAF_GUI gui) {
43 super(null,"Command Line");
48 public void handle(AuthzTrans trans, HttpServletRequest req,HttpServletResponse resp) throws Exception {
49 ServletInputStream isr = req.getInputStream();
50 PrintWriter pw = resp.getWriter();
52 StringBuilder cmd = new StringBuilder();
54 while ((c=isr.read())>=0) {
58 TimeTaken tt = trans.start("Execute AAFCLI", Env.REMOTE);
60 TaggedPrincipal p = trans.getUserPrincipal();
61 // Access needs to be set after overall construction. Thus, the lazy create.
63 AAFConHttp aafcon = gui.aafCon();
64 aafcli= new AAFcli(gui.access,gui.env, pw,
66 aafcon.securityInfo(),
67 new HTransferSS(p,AAF_GUI.app,
68 aafcon.securityInfo()));
69 aafcli.verbose(false);
72 String cmdStr = cmd.toString();
73 if (!cmdStr.contains("--help")) {
74 cmdStr = cmdStr.replaceAll("help", "--help");
76 if (!cmdStr.contains("--version")) {
77 cmdStr = cmdStr.replaceAll("version", "--version");
82 } catch (Exception e) {
84 pw.println(e.getMessage());