x/ref: Restructure security packages

Here are the renamings:

security               -> lib/security
security/audit         -> lib/security/audit
security/flag          -> lib/security/securityflag
security/serialization -> lib/security/serialization

security/agent                -> services/agent
security/agent/agentd         -> services/agent/agentd
security/agent/keymgr         -> services/agent/keymgr
security/agent/server         -> services/agent/server
security/agent/cache          -> services/agent/internal/cache
security/agent/lru            -> services/agent/internal/lru
security/agent/pingpong       -> services/agent/internal/pingpong
security/agent/test_principal -> services/agent/internal/test_principal

Note that the restructuring is not done, even after this CL is
submitted.  In particular, services/agent is supposed to contain
the *.vdl files, and the client and server libraries are supposed
to live in services/agent/agentlib, per our conventions.  Also
lib/unixfd can also be moved under services/agent/internal.  That
will be fixed in a subsequent CL.

MultiPart: 1/3
Change-Id: Ie9b14083d133a661f0d3a6c33a3ae05e3bac3cd2
diff --git a/profiles/fake/runtime.go b/profiles/fake/runtime.go
index ceaa6cc..e2c5cf3 100644
--- a/profiles/fake/runtime.go
+++ b/profiles/fake/runtime.go
@@ -12,8 +12,7 @@
 	"v.io/v23/context"
 	"v.io/v23/rpc"
 	"v.io/v23/security"
-
-	vsecurity "v.io/x/ref/security"
+	vsecurity "v.io/x/ref/lib/security"
 )
 
 type contextKey int
diff --git a/profiles/internal/rpc/benchmark/internal/server.go b/profiles/internal/rpc/benchmark/internal/server.go
index 483fd17..0c94e23 100644
--- a/profiles/internal/rpc/benchmark/internal/server.go
+++ b/profiles/internal/rpc/benchmark/internal/server.go
@@ -5,13 +5,11 @@
 package internal
 
 import (
-	"v.io/x/ref/security/flag"
-
 	"v.io/v23"
 	"v.io/v23/context"
 	"v.io/v23/rpc"
 	"v.io/x/lib/vlog"
-
+	"v.io/x/ref/lib/security/securityflag"
 	"v.io/x/ref/profiles/internal/rpc/benchmark"
 )
 
@@ -47,7 +45,7 @@
 		vlog.Fatalf("Listen failed: %v", err)
 	}
 
-	if err := server.Serve("", benchmark.BenchmarkServer(&impl{}), flag.NewAuthorizerOrDie()); err != nil {
+	if err := server.Serve("", benchmark.BenchmarkServer(&impl{}), securityflag.NewAuthorizerOrDie()); err != nil {
 		vlog.Fatalf("Serve failed: %v", err)
 	}
 	return eps[0].Name(), func() {
diff --git a/profiles/internal/rt/mgmt_test.go b/profiles/internal/rt/mgmt_test.go
index 0380665..de8bd0c 100644
--- a/profiles/internal/rt/mgmt_test.go
+++ b/profiles/internal/rt/mgmt_test.go
@@ -18,14 +18,14 @@
 	"v.io/v23/naming"
 	"v.io/v23/rpc"
 	"v.io/v23/services/appcycle"
-
 	"v.io/x/ref/lib/mgmt"
-	_ "v.io/x/ref/profiles"
-	vflag "v.io/x/ref/security/flag"
+	"v.io/x/ref/lib/security/securityflag"
 	"v.io/x/ref/services/device"
 	"v.io/x/ref/test"
 	"v.io/x/ref/test/expect"
 	"v.io/x/ref/test/modules"
+
+	_ "v.io/x/ref/profiles"
 )
 
 //go:generate v23 test generate
@@ -289,7 +289,7 @@
 	if eps, err = server.Listen(v23.GetListenSpec(ctx)); err != nil {
 		t.Fatalf("Got error: %v", err)
 	}
-	if err := server.Serve("", device.ConfigServer(&configServer{ch}), vflag.NewAuthorizerOrDie()); err != nil {
+	if err := server.Serve("", device.ConfigServer(&configServer{ch}), securityflag.NewAuthorizerOrDie()); err != nil {
 		t.Fatalf("Got error: %v", err)
 	}
 	return server, eps[0].Name(), ch
diff --git a/profiles/internal/rt/rt_test.go b/profiles/internal/rt/rt_test.go
index 405a94e..014bdf1 100644
--- a/profiles/internal/rt/rt_test.go
+++ b/profiles/internal/rt/rt_test.go
@@ -13,14 +13,12 @@
 	"testing"
 	"time"
 
-	"v.io/x/lib/vlog"
-
 	"v.io/v23"
 	"v.io/v23/context"
 	"v.io/v23/security"
-
+	"v.io/x/lib/vlog"
 	"v.io/x/ref/envvar"
-	vsecurity "v.io/x/ref/security"
+	vsecurity "v.io/x/ref/lib/security"
 	"v.io/x/ref/test"
 	"v.io/x/ref/test/expect"
 	"v.io/x/ref/test/modules"
diff --git a/profiles/internal/rt/security.go b/profiles/internal/rt/security.go
index faf0661..8f350c2 100644
--- a/profiles/internal/rt/security.go
+++ b/profiles/internal/rt/security.go
@@ -15,11 +15,10 @@
 	"v.io/v23/rpc"
 	"v.io/v23/security"
 	"v.io/v23/verror"
-
 	"v.io/x/ref/lib/exec"
 	"v.io/x/ref/lib/mgmt"
-	vsecurity "v.io/x/ref/security"
-	"v.io/x/ref/security/agent"
+	vsecurity "v.io/x/ref/lib/security"
+	"v.io/x/ref/services/agent"
 )
 
 func initSecurity(ctx *context.T, credentials string, client rpc.Client) (security.Principal, error) {
diff --git a/profiles/roaming/roaminginit.go b/profiles/roaming/roaminginit.go
index 9edddc6..342422d 100644
--- a/profiles/roaming/roaminginit.go
+++ b/profiles/roaming/roaminginit.go
@@ -21,22 +21,19 @@
 	"v.io/v23/config"
 	"v.io/v23/context"
 	"v.io/v23/rpc"
-	"v.io/x/lib/vlog"
-
 	"v.io/x/lib/netconfig"
 	"v.io/x/lib/netstate"
+	"v.io/x/lib/vlog"
 	"v.io/x/ref/lib/flags"
+	"v.io/x/ref/lib/security/securityflag"
 	"v.io/x/ref/profiles/internal"
 	"v.io/x/ref/profiles/internal/lib/appcycle"
 	"v.io/x/ref/profiles/internal/lib/websocket"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/tcp"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/ws"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/wsh"
-	grt "v.io/x/ref/profiles/internal/rt"
+	"v.io/x/ref/profiles/internal/rt"
 	"v.io/x/ref/services/debug/debuglib"
-
-	// TODO(cnicolaou,ashankar): move this into flags.
-	sflag "v.io/x/ref/security/flag"
 )
 
 const (
@@ -61,7 +58,7 @@
 		Addrs: rpc.ListenAddrs(lf.Addrs),
 		Proxy: lf.ListenProxy,
 	}
-	reservedDispatcher := debuglib.NewDispatcher(vlog.Log.LogDir, sflag.NewAuthorizerOrDie())
+	reservedDispatcher := debuglib.NewDispatcher(vlog.Log.LogDir, securityflag.NewAuthorizerOrDie())
 
 	ac := appcycle.New()
 
@@ -72,7 +69,7 @@
 			listenSpec.AddressChooser = func(string, []rpc.Address) ([]rpc.Address, error) {
 				return []rpc.Address{&netstate.AddrIfc{addr, "nat", nil}}, nil
 			}
-			runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
+			runtime, ctx, shutdown, err := rt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
 			if err != nil {
 				return nil, nil, shutdown, err
 			}
@@ -115,7 +112,7 @@
 	listenSpec.StreamName = SettingsStreamName
 	listenSpec.AddressChooser = internal.IPAddressChooser
 
-	runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
+	runtime, ctx, shutdown, err := rt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
 	if err != nil {
 		return nil, nil, shutdown, err
 	}
@@ -133,7 +130,7 @@
 // monitorNetworkSettings will monitor network configuration changes and
 // publish subsequent Settings to reflect any changes detected.
 func monitorNetworkSettingsX(
-	runtime *grt.Runtime,
+	runtime *rt.Runtime,
 	ctx *context.T,
 	watcher netconfig.NetConfigWatcher,
 	prev netstate.AddrList,
diff --git a/profiles/static/staticinit.go b/profiles/static/staticinit.go
index 8458777..7da5a31 100644
--- a/profiles/static/staticinit.go
+++ b/profiles/static/staticinit.go
@@ -10,21 +10,18 @@
 	"v.io/v23"
 	"v.io/v23/context"
 	"v.io/v23/rpc"
-	"v.io/x/lib/vlog"
-
 	"v.io/x/lib/netstate"
+	"v.io/x/lib/vlog"
 	"v.io/x/ref/lib/flags"
+	"v.io/x/ref/lib/security/securityflag"
 	"v.io/x/ref/profiles/internal"
 	"v.io/x/ref/profiles/internal/lib/appcycle"
 	"v.io/x/ref/profiles/internal/lib/websocket"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/tcp"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/ws"
 	_ "v.io/x/ref/profiles/internal/rpc/protocols/wsh"
-	grt "v.io/x/ref/profiles/internal/rt"
+	"v.io/x/ref/profiles/internal/rt"
 	"v.io/x/ref/services/debug/debuglib"
-
-	// TODO(cnicolaou,ashankar): move this into flags.
-	sflag "v.io/x/ref/security/flag"
 )
 
 var commonFlags *flags.Flags
@@ -45,7 +42,7 @@
 		Addrs: rpc.ListenAddrs(lf.Addrs),
 		Proxy: lf.ListenProxy,
 	}
-	reservedDispatcher := debuglib.NewDispatcher(vlog.Log.LogDir, sflag.NewAuthorizerOrDie())
+	reservedDispatcher := debuglib.NewDispatcher(vlog.Log.LogDir, securityflag.NewAuthorizerOrDie())
 
 	ac := appcycle.New()
 
@@ -56,7 +53,7 @@
 			listenSpec.AddressChooser = func(string, []rpc.Address) ([]rpc.Address, error) {
 				return []rpc.Address{&netstate.AddrIfc{addr, "nat", nil}}, nil
 			}
-			runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
+			runtime, ctx, shutdown, err := rt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
 			if err != nil {
 				return nil, nil, nil, err
 			}
@@ -69,7 +66,7 @@
 	}
 	listenSpec.AddressChooser = internal.IPAddressChooser
 
-	runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
+	runtime, ctx, shutdown, err := rt.Init(ctx, ac, nil, &listenSpec, commonFlags.RuntimeFlags(), reservedDispatcher)
 	if err != nil {
 		return nil, nil, shutdown, err
 	}