Remove Code from cadi, it is now in authz
[aaf/cadi.git] / aaf / src / main / java / org / onap / aaf / cadi / cm / PlaceArtifactScripts.java
diff --git a/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactScripts.java b/aaf/src/main/java/org/onap/aaf/cadi/cm/PlaceArtifactScripts.java
deleted file mode 100644 (file)
index d1b3141..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- *  *      http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- *  * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.cadi.cm;\r
-\r
-import java.io.File;\r
-\r
-import org.onap.aaf.cadi.CadiException;\r
-import org.onap.aaf.cadi.util.Chmod;\r
-\r
-import org.onap.aaf.inno.env.Trans;\r
-import org.onap.aaf.inno.env.util.Chrono;\r
-import org.onap.aaf.inno.env.util.Split;\r
-\r
-import certman.v1_0.Artifacts.Artifact;\r
-import certman.v1_0.CertInfo;\r
-\r
-public class PlaceArtifactScripts extends ArtifactDir {\r
-       @Override\r
-       public boolean _place(Trans trans, CertInfo certInfo, Artifact arti) throws CadiException {\r
-               try {\r
-                       // Setup check.sh script\r
-                       String filename = arti.getAppName()+".check.sh";\r
-                       File f1 = new File(dir,filename);\r
-                       String email = arti.getNotification() + '\n';\r
-                       if(email.startsWith("mailto:")) {\r
-                               email=email.substring(7);\r
-                       }  else {\r
-                               email=arti.getOsUser() + '\n';\r
-                       }\r
-                       \r
-                       StringBuilder classpath = new StringBuilder();\r
-                       boolean first = true;\r
-                       for(String pth : Split.split(File.pathSeparatorChar, System.getProperty("java.class.path"))) {\r
-                               if(first) {\r
-                                       first=false;\r
-                               } else {\r
-                                       classpath.append(File.pathSeparatorChar);\r
-                               }\r
-                               File f = new File(pth);\r
-                               classpath.append(f.getCanonicalPath().replaceAll("[0-9]+\\.[0-9]+\\.[0-9]+","*"));\r
-                       }\r
-                       \r
-                       write(f1,Chmod.to644,\r
-                                       "#!/bin/bash " + f1.getCanonicalPath()+'\n',\r
-                                       "# Certificate Manager Check Script\n",\r
-                                       "# Check on Certificate, and renew if needed.\n",\r
-                                       "# Generated by Certificate Manager " + Chrono.timeStamp()+'\n',\r
-                                       "DIR="+arti.getDir()+'\n',\r
-                                       "APP="+arti.getAppName()+'\n',\r
-                                       "EMAIL="+email,\r
-                                       "CP=\""+classpath.toString()+"\"\n",\r
-                                       checkScript\r
-                                       );\r
-                       \r
-                       // Setup check.sh script\r
-                       File f2 = new File(dir,arti.getAppName()+".crontab.sh");\r
-                       write(f2,Chmod.to644,\r
-                                       "#!/bin/bash " + f1.getCanonicalPath()+'\n',\r
-                                       "# Certificate Manager Crontab Loading Script\n",\r
-                                       "# Add/Update a Crontab entry, that adds a check on Certificate Manager generated Certificate nightly.\n",\r
-                                       "# Generated by Certificate Manager " + Chrono.timeStamp()+'\n',\r
-                                       "TFILE=\"/tmp/cmcron$$.temp\"\n",\r
-                                       "DIR=\""+arti.getDir()+"\"\n",\r
-                                       "CF=\""+arti.getAppName()+" Certificate Check Script\"\n",\r
-                                       "SCRIPT=\""+f1.getCanonicalPath()+"\"\n",\r
-                                       cronScript\r
-                                       );\r
-\r
-               } catch (Exception e) {\r
-                       throw new CadiException(e);\r
-               }\r
-               return true;\r
-       }\r
-       \r
-       private final static String checkScript = \r
-                       "> $DIR/$APP.msg\n\n" +\r
-                       "function mailit {\n" +\r
-                       "  printf \"$*\" | /bin/mail -s \"AAF Certman Notification for `uname -n`\" $EMAIL\n"+\r
-                       "}\n\n" +\r
-                       System.getProperty("java.home") + "/bin/" +"java -cp $CP " +\r
-                               CmAgent.class.getName() + \r
-                               " cadi_prop_files=$DIR/$APP.props check 2>  $DIR/$APP.STDERR > $DIR/$APP.STDOUT\n" +\r
-                       "case \"$?\" in\n" +\r
-                       "  0)\n" +\r
-                       "    # Note: Validation will be mailed only the first day after any modification\n" +\r
-                       "    if [ \"`find $DIR -mtime 0 -name $APP.check.sh`\" != \"\" ] ; then\n" +\r
-                       "       mailit `echo \"Certficate Validated:\\n\\n\" | cat - $DIR/$APP.msg`\n" +\r
-                       "    else\n" +\r
-                       "       cat $DIR/$APP.msg\n" +\r
-                       "    fi\n" +\r
-                       "    ;;\n" +\r
-                       "  1) mailit \"Error with Certificate Check:\\\\n\\\\nCheck logs $DIR/$APP.STDOUT and $DIR/$APP.STDERR on `uname -n`\"\n" +\r
-                       "    ;;\n" +\r
-                       "  2) mailit `echo \"Certificate Check Error\\\\n\\\\n\" | cat - $DIR/$APP.msg`\n" +\r
-                       "    ;;\n" +\r
-                       "  10) mailit `echo \"Certificate Replaced\\\\n\\\\n\" | cat - $DIR/$APP.msg`\n" +\r
-                       "      if [ -e $DIR/$APP.restart.sh ]; then\n" +\r
-                       "        # Note: it is THIS SCRIPT'S RESPONSIBILITY to notify upon success or failure as necessary!!\n" +\r
-                       "        /bin/sh $DIR/$APP.restart.sh\n" +\r
-                       "      fi\n" +\r
-                       "    ;;\n" +\r
-                       "  *) mailit `echo \"Unknown Error code for CM Agent\\\\n\\\\n\" | cat - $DIR/$APP.msg`\n" +\r
-                       "    ;;\n" +\r
-                       " esac\n\n" +\r
-                       " # Note: make sure to cover this sripts' exit Code\n";\r
-       \r
-       private final static String cronScript = \r
-                       "crontab -l | sed -n \"/#### BEGIN $CF/,/END $CF ####/!p\" > $TFILE\n" +\r
-                       "# Note: Randomize Minutes (0-60) and hours (1-4)\n" +\r
-                       "echo \"#### BEGIN $CF ####\" >> $TFILE\n" +\r
-                       "echo \"$(( $RANDOM % 60)) $(( $(( $RANDOM % 3 )) + 1 )) * * * /bin/bash $SCRIPT " +\r
-                               ">> $DIR/cronlog 2>&1 \" >> $TFILE\n" +\r
-                       "echo \"#### END $CF ####\" >> $TFILE\n" +\r
-                       "crontab $TFILE\n" +\r
-                       "rm $TFILE\n";\r
-}\r
-\r
-\r
-\r