Remove Code from cadi, it is now in authz
[aaf/cadi.git] / core / src / main / java / org / onap / aaf / cadi / config / UsersDump.java
diff --git a/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java b/core/src/main/java/org/onap/aaf/cadi/config/UsersDump.java
deleted file mode 100644 (file)
index e0893e6..0000000
+++ /dev/null
@@ -1,158 +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.config;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.OutputStream;\r
-import java.io.PrintStream;\r
-import java.util.Date;\r
-import java.util.HashSet;\r
-\r
-import org.onap.aaf.cadi.AbsUserCache;\r
-import org.onap.aaf.cadi.lur.LocalLur;\r
-\r
-public class UsersDump {\r
-\r
-       /**\r
-        * @param args\r
-        */\r
-       public static boolean write(OutputStream os, AbsUserCache<?> lur) {\r
-               PrintStream ps;\r
-               if(os instanceof PrintStream) {\r
-                       ps = (PrintStream)os;\r
-               } else {\r
-                       ps = new PrintStream(os);\r
-               }\r
-               try {\r
-                       ps.println("<?xml version='1.0' encoding='utf-8'?>");\r
-                       ps.println("<!--");\r
-                       ps.print(  "     Code Generated Tomcat Users and Roles from AT&T LUR on ");\r
-                       ps.println(new Date());\r
-                       ps.println(  "-->");\r
-                       ps.println("<tomcat-users>");\r
-\r
-                       // We loop through Users, but want to write Groups first... therefore, save off print\r
-                       StringBuilder sb = new StringBuilder();\r
-                       \r
-                       // Obtain all unique role names\r
-                       HashSet<String> groups = new HashSet<String>();\r
-                       for(AbsUserCache<?>.DumpInfo di : lur.dumpInfo()) {\r
-                               sb.append("\n  <user username=\"");\r
-                               sb.append(di.user);\r
-                               sb.append("\" roles=\"");\r
-                               boolean first = true;\r
-                               for(String role : di.perms) {\r
-                                       groups.add(role);\r
-                                       if(first)first = false;\r
-                                       else sb.append(',');\r
-                                       sb.append(role);\r
-                               }\r
-                               sb.append("\"/>");\r
-\r
-                       }\r
-\r
-                       // Print roles\r
-                       for(String group : groups) {\r
-                               ps.print("  <role rolename=\"");\r
-                               ps.print(group);\r
-                               ps.println("\"/>");\r
-                       }\r
-       \r
-                       ps.println(sb);\r
-\r
-                       ps.println("</tomcat-users>");\r
-                       ps.flush();\r
-               } catch (Throwable t) {\r
-                       t.printStackTrace(ps);\r
-                       return false;\r
-               }\r
-               return true;\r
-       }\r
-       \r
-       /**\r
-        * \r
-        * Note: This method returns a String if there's an error, or null if ok.\r
-        * This unusual style is necessitated by the fact that any Exceptions thrown are likely to \r
-        * be unlogged and hidden from view, making debugging almost impossible.\r
-        * \r
-        * @param writeto\r
-        * @param up\r
-        * @return\r
-        */\r
-       public static String updateUsers(String writeto, LocalLur up) {\r
-               // Dump a Tomcat-user.xml lookalike (anywhere)\r
-               if(writeto!=null) {\r
-                       // First read content\r
-                       ByteArrayOutputStream baos = new ByteArrayOutputStream();\r
-                       if(UsersDump.write(baos, up)) {\r
-                               byte[] postulate = baos.toByteArray();\r
-                               // now get contents of file\r
-                               File file = new File(writeto);\r
-                               boolean writeIt;\r
-                               if(file.exists()) {\r
-                                       try {\r
-                                               FileInputStream fis = new FileInputStream(file);\r
-                                               byte[] orig = new byte[(int)file.length()];\r
-                                               try {\r
-                                                       fis.read(orig);\r
-                                               } finally {\r
-                                                       fis.close();\r
-                                               }\r
-                                               // Starting at third "<" (<tomcat-users> line)\r
-                                               int startA=0, startB=0;\r
-                                               for(int i=0;startA<orig.length && i<3;++startA) if(orig[startA]=='<')++i;\r
-                                               for(int i=0;startB<orig.length && i<3;++startB) if(postulate[startB]=='<')++i;\r
-                                               \r
-                                               writeIt=orig.length-startA!=postulate.length-startB; // first, check if remaining length is the same\r
-                                               while(!writeIt && startA<orig.length && startB<postulate.length) {\r
-                                                       if(orig[startA++]!=postulate[startB++])writeIt = true;\r
-                                               }\r
-                                       } catch (Exception e) {\r
-                                               writeIt = true;\r
-                                       }\r
-                               } else {\r
-                                       writeIt = true;\r
-                               }\r
-                               \r
-                               if(writeIt) {\r
-                                       try {\r
-                                               FileOutputStream fos = new FileOutputStream(file);\r
-                                               try {\r
-                                                       fos.write(postulate);\r
-                                               } finally {\r
-                                                       fos.close();\r
-                                               }\r
-                                       } catch (IOException e) {\r
-                                               return e.getMessage();\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               return null; // no message means ok.\r
-       }\r
-\r
-}\r