func main() { defer func() { err := easy_error.Apply(recover()) if err != nil { fmt.Println(err) os.Exit(2) } }() flag.Parse() server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server) tomcatusers := easy_error.Wrap(server.ReadTomcatUsers()).(*tomcat_info.TomcatUsers) usermap := tomcatusers.GetUsersWithRole("manager") manager, ok := usermap["manager"] if ok { fmt.Println(manager.Password) return } else { for _, v := range usermap { fmt.Println(v.Password) return } } fmt.Println("No manager user exists") os.Exit(1) }
func (server *Server) ReadTomcatUsers() (users *TomcatUsers, err error) { defer func() { err = easy_error.Apply(recover()) }() userfile := easy_error.Wrap(server.GetUserFile()).(string) file := easy_error.Wrap(os.Open(server.serverpath + "/" + userfile)).(*os.File) decoder := xml.NewDecoder(file) users = &TomcatUsers{} decoder.Decode(users) return }
func main() { defer func() { err := easy_error.Apply(recover()) if err != nil { fmt.Println(err) os.Exit(1) } }() flag.Parse() server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server) port := easy_error.Wrap(server.GetHttpPort()).(int16) fmt.Println(port) }
func ReadServer(serverpath string) (server *Server, err error) { defer func() { err = easy_error.Apply(recover()) }() file := easy_error.Wrap(os.Open(serverpath + "/conf/server.xml")).(*os.File) decoder := xml.NewDecoder(file) server = &Server{} server.serverpath = serverpath decoder.Decode(server) return }
func doGetServerPort() { server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server) port := easy_error.Wrap(server.GetHttpPort()).(uint16) fmt.Println(port) }
func getTomcatUsers() *tomcat_info.TomcatUsers { if tomcatusers == nil { tomcatusers = easy_error.Wrap(getServer().ReadTomcatUsers()).(*tomcat_info.TomcatUsers) } return tomcatusers }
func getServer() *tomcat_info.Server { if server == nil { server = easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server) } return server }