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)
}
示例#2
0
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)
}
示例#4
0
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
}
示例#5
0
func doGetServerPort() {
	server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server)
	port := easy_error.Wrap(server.GetHttpPort()).(uint16)
	fmt.Println(port)
}
示例#6
0
func getTomcatUsers() *tomcat_info.TomcatUsers {
	if tomcatusers == nil {
		tomcatusers = easy_error.Wrap(getServer().ReadTomcatUsers()).(*tomcat_info.TomcatUsers)
	}
	return tomcatusers
}
示例#7
0
func getServer() *tomcat_info.Server {
	if server == nil {
		server = easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server)
	}
	return server
}