public static void init(final GwAPI gwAPI, GwFacade facade) throws Exception {
		String aftenv = gwAPI.env.getProperty(AFT_ENVIRONMENT);
		if(aftenv==null) throw new Exception(AFT_ENVIRONMENT + " must be set");
		
		int equals, count=0;
		for(int slash = gwAPI.aafurl.indexOf('/');slash>0;++count) {
			equals = gwAPI.aafurl.indexOf('=',slash)+1;
			slash = gwAPI.aafurl.indexOf('/',slash+1);
			switch(count) {
				case 2:
//					service = gwAPI.aafurl.substring(equals, slash);
					break;
				case 3:
//					version = gwAPI.aafurl.substring(equals, slash);
					break;
				case 4:
//					envContext = gwAPI.aafurl.substring(equals, slash);
					break;
				case 5:
					routeOffer = gwAPI.aafurl.substring(equals);
					break;
			}
		}
		if(count<6) throw new MalformedURLException(gwAPI.aafurl);
		
		gwAPI.route(HttpMethods.GET,"/authz/perms/user/:user",API.VOID,new GwCode(facade,GET_PERMS_BY_USER, true) {
			@Override
			public void handle(final AuthzTrans trans, final HttpServletRequest req, final HttpServletResponse resp) throws Exception {
				TimeTaken tt = trans.start(GET_PERMS_BY_USER, Env.SUB);
				try {
					final String accept = req.getHeader("ACCEPT");
					final String user = pathParam(req,":user");
					if(!user.contains("@")) {
						context.error(trans,resp,Result.ERR_BadData,"User [%s] must be fully qualified with domain",user);
						return;
					}
					String key = trans.user() + user + (accept!=null&&accept.contains("xml")?"-xml":"-json");
					TimeTaken tt2 = trans.start("Cache Lookup",Env.SUB);
					Dated d;
					try {
						d = gwAPI.cacheUser.get(key);
					} finally {
						tt2.done();
					}
					
					if(d==null || d.data.isEmpty()) {
						tt2 = trans.start("AAF Service Call",Env.REMOTE);
						try {
							gwAPI.clientAsUser(trans.getUserPrincipal(), new Retryable<Void>() {
								@Override
								public Void code(Rcli<?> client) throws CadiException, ConnectException, APIException {
									Future<String> fp = client.read("/authz/perms/user/"+user,accept);
									if(fp.get(5000)) {
										gwAPI.cacheUser.put(key, new Dated(new User(fp.code(),fp.body())));
										resp.setStatus(HttpStatus.OK_200);
										ServletOutputStream sos;
										try {
											sos = resp.getOutputStream();
											sos.print(fp.value);
										} catch (IOException e) {
											throw new CadiException(e);
										}
									} else {
										gwAPI.cacheUser.put(key, new Dated(new User(fp.code(),fp.body())));
										context.error(trans,resp,fp.code(),fp.body());
									}
									return null;
								}
							});
						} finally {
							tt2.done();
						}
					} else {
						User u = (User)d.data.get(0);
						resp.setStatus(u.code);
						ServletOutputStream sos = resp.getOutputStream();
						sos.print(u.resp);
					}
				} finally {
					tt.done();
				}
			}
		});

		gwAPI.route(gwAPI.env,HttpMethods.GET,"/authn/basicAuth",new GwCode(facade,BASIC_AUTH, true) {
			@Override
			public void handle(final AuthzTrans trans, final HttpServletRequest req, HttpServletResponse resp) throws Exception {
				Principal p = trans.getUserPrincipal();
				if(p == null) {
					trans.error().log("Transaction not Authenticated... no Principal");
					resp.setStatus(HttpStatus.FORBIDDEN_403);
				} else if (p instanceof BasicPrincipal) {
					// the idea is that if call is made with this credential, and it's a BasicPrincipal, it's ok
					// otherwise, it wouldn't have gotten here.
					resp.setStatus(HttpStatus.OK_200);
				} else {
					trans.checkpoint("Basic Auth Check Failed: This wasn't a Basic Auth Trans");
					// For Auth Security questions, we don't give any info to client on why failed
					resp.setStatus(HttpStatus.FORBIDDEN_403);
				}
			}
		},"text/plain","*/*","*");

		/**
		 * Query User Has Perm
		 */
		gwAPI.route(HttpMethods.GET,"/ask/:user/has/:type/:instance/:action",API.VOID,new GwCode(facade,USER_HAS_PERM, true) {
			@Override
			public void handle(final AuthzTrans trans, final HttpServletRequest req, HttpServletResponse resp) throws Exception {
				try {
					resp.getOutputStream().print(
							gwAPI.aafLurPerm.fish(pathParam(req,":user"), new AAFPermission(
								pathParam(req,":type"),
								pathParam(req,":instance"),
								pathParam(req,":action"))));
					resp.setStatus(HttpStatus.OK_200);
				} catch(Exception e) {
					context.error(trans, resp, Result.ERR_General, e.getMessage());
				}
			}
		});

		if(AFTUAT.equals(aftenv)) {
			gwAPI.route(HttpMethods.GET,"/ist/aaf/:version/:path*",API.VOID ,new GwCode(facade,"Access UAT GUI for AAF", true) {
				@Override
				public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
					try{
						redirect(trans, req, resp, context, 
								new DME2Locator(gwAPI.env, gwAPI.dme2Man, AUTHZ_DME2_GUI, pathParam(req,":version"), IST, routeOffer), 
								pathParam(req,":path"));
					} catch (LocatorException e) {
						context.error(trans, resp, Result.ERR_BadData, e.getMessage());
					} catch (Exception e) {
						context.error(trans, resp, Result.ERR_General, e.getMessage());
					}
				}
			});

			gwAPI.route(HttpMethods.GET,"/test/aaf/:version/:path*",API.VOID ,new GwCode(facade,"Access TEST GUI for AAF", true) {
				@Override
				public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
					try{
						redirect(trans, req, resp, context, 
								new DME2Locator(gwAPI.env, gwAPI.dme2Man, AUTHZ_DME2_GUI, pathParam(req,":version"), TEST, routeOffer), 
								pathParam(req,":path"));
					} catch (LocatorException e) {
						context.error(trans, resp, Result.ERR_BadData, e.getMessage());
					} catch (Exception e) {
						context.error(trans, resp, Result.ERR_General, e.getMessage());
					}
				}
			});

			gwAPI.route(HttpMethods.GET,"/perf/aaf/:version/:path*",API.VOID ,new GwCode(facade,"Access PERF GUI for AAF", true) {
				@Override
				public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
					try{
						redirect(trans, req, resp, context, 
								new DME2Locator(gwAPI.env, gwAPI.dme2Man, AUTHZ_DME2_GUI, pathParam(req,":version"), PERF, routeOffer), 
								pathParam(req,":path"));
					} catch (LocatorException e) {
						context.error(trans, resp, Result.ERR_BadData, e.getMessage());
					} catch (Exception e) {
						context.error(trans, resp, Result.ERR_General, e.getMessage());
					}
				}
			});

			gwAPI.route(HttpMethods.GET,"/dev/aaf/:version/:path*",API.VOID,new GwCode(facade,"Access DEV GUI for AAF", true) {
				@Override
				public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
					try {
						redirect(trans, req, resp, context, 
								new DME2Locator(gwAPI.env, gwAPI.dme2Man, AUTHZ_DME2_GUI, pathParam(req,":version"), DEV, routeOffer), 
								pathParam(req,":path"));
					} catch (LocatorException e) {
						context.error(trans, resp, Result.ERR_BadData, e.getMessage());
					} catch (Exception e) {
						context.error(trans, resp, Result.ERR_General, e.getMessage());
					}
				}
			});
		} else {
			gwAPI.route(HttpMethods.GET,"/aaf/:version/:path*",API.VOID,new GwCode(facade,"Access PROD GUI for AAF", true) {
				@Override
				public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
					try {
						redirect(trans, req, resp, context, 
								new DME2Locator(gwAPI.env, gwAPI.dme2Man, AUTHZ_DME2_GUI, pathParam(req,":version"), PROD, routeOffer), 
								pathParam(req,":path"));
					} catch (LocatorException e) {
						context.error(trans, resp, Result.ERR_BadData, e.getMessage());
					} catch (Exception e) {
						context.error(trans, resp, Result.ERR_General, e.getMessage());
					}
				}
			});
		}
		
	}
public static void init ( final GwAPI gwAPI , GwFacade facade ) throws Exception { String aftenv = gwAPI . env . getProperty ( AFT_ENVIRONMENT ) ; if ( aftenv == null ) throw new Exception ( AFT_ENVIRONMENT + " must be set" ) ; int equals , count = 0 ; for ( int slash = gwAPI . aafurl . indexOf ( '/' ) ; slash > 0 ; ++ count ) { equals = gwAPI . aafurl . indexOf ( '=' , slash ) + 1 ; slash = gwAPI . aafurl . indexOf ( '/' , slash + 1 ) ; switch ( count ) { case 2 : break ; case 3 : break ; case 4 : break ; case 5 : routeOffer = gwAPI . aafurl . substring ( equals ) ; break ; } } if ( count < 6 ) throw new MalformedURLException ( gwAPI . aafurl ) ; gwAPI . route ( HttpMethods . GET , "/authz/perms/user/:user" , API . VOID , new GwCode ( facade , GET_PERMS_BY_USER , true ) { @ Override public void handle ( final AuthzTrans trans , final HttpServletRequest req , final HttpServletResponse resp ) throws Exception { TimeTaken tt = trans . start ( GET_PERMS_BY_USER , Env . SUB ) ; try { final String accept = req . getHeader ( "ACCEPT" ) ; final String user = pathParam ( req , ":user" ) ; if ( ! user . contains ( "@" ) ) { context . error ( trans , resp , Result . ERR_BadData , "User [%s] must be fully qualified with domain" , user ) ; return ; } String key = trans . user ( ) + user + ( accept != null && accept . contains ( "xml" ) ? "-xml" : "-json" ) ; TimeTaken tt2 = trans . start ( "Cache Lookup" , Env . SUB ) ; Dated d ; try { d = gwAPI . cacheUser . get ( key ) ; } finally { tt2 . done ( ) ; } if ( d == null || d . data . isEmpty ( ) ) { tt2 = trans . start ( "AAF Service Call" , Env . REMOTE ) ; try { gwAPI . clientAsUser ( trans . getUserPrincipal ( ) , new Retryable < Void > ( ) { @ Override public Void code ( Rcli < ? > client ) throws CadiException , ConnectException , APIException { Future < String > fp = client . read ( "/authz/perms/user/" + user , accept ) ; if ( fp . get ( 5000 ) ) { gwAPI . cacheUser . put ( key , new Dated ( new User ( fp . code ( ) , fp . body ( ) ) ) ) ; resp . setStatus ( HttpStatus . OK_200 ) ; ServletOutputStream sos ; try { sos = resp . getOutputStream ( ) ; sos . print ( fp . value ) ; } catch ( IOException e ) { throw new CadiException ( e ) ; } } else { gwAPI . cacheUser . put ( key , new Dated ( new User ( fp . code ( ) , fp . body ( ) ) ) ) ; context . error ( trans , resp , fp . code ( ) , fp . body ( ) ) ; } return null ; } } ) ; } finally { tt2 . done ( ) ; } } else { User u = ( User ) d . data . get ( 0 ) ; resp . setStatus ( u . code ) ; ServletOutputStream sos = resp . getOutputStream ( ) ; sos . print ( u . resp ) ; } } finally { tt . done ( ) ; } } } ) ; gwAPI . route ( gwAPI . env , HttpMethods . GET , "/authn/basicAuth" , new GwCode ( facade , BASIC_AUTH , true ) { @ Override public void handle ( final AuthzTrans trans , final HttpServletRequest req , HttpServletResponse resp ) throws Exception { Principal p = trans . getUserPrincipal ( ) ; if ( p == null ) { trans . error ( ) . log ( "Transaction not Authenticated... no Principal" ) ; resp . setStatus ( HttpStatus . FORBIDDEN_403 ) ; } else if ( p instanceof BasicPrincipal ) { resp . setStatus ( HttpStatus . OK_200 ) ; } else { trans . checkpoint ( "Basic Auth Check Failed: This wasn't a Basic Auth Trans" ) ; resp . setStatus ( HttpStatus . FORBIDDEN_403 ) ; } } } , "text/plain" , "*/*" , "*" ) ; gwAPI . route ( HttpMethods . GET , "/ask/:user/has/:type/:instance/:action" , API . VOID , new GwCode ( facade , USER_HAS_PERM , true ) { @ Override public void handle ( final AuthzTrans trans , final HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { resp . getOutputStream ( ) . print ( gwAPI . aafLurPerm . fish ( pathParam ( req , ":user" ) , new AAFPermission ( pathParam ( req , ":type" ) , pathParam ( req , ":instance" ) , pathParam ( req , ":action" ) ) ) ) ; resp . setStatus ( HttpStatus . OK_200 ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; if ( AFTUAT . equals ( aftenv ) ) { gwAPI . route ( HttpMethods . GET , "/ist/aaf/:version/:path*" , API . VOID , new GwCode ( facade , "Access UAT GUI for AAF" , true ) { @ Override public void handle ( AuthzTrans trans , HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { redirect ( trans , req , resp , context , new DME2Locator ( gwAPI . env , gwAPI . dme2Man , AUTHZ_DME2_GUI , pathParam ( req , ":version" ) , IST , routeOffer ) , pathParam ( req , ":path" ) ) ; } catch ( LocatorException e ) { context . error ( trans , resp , Result . ERR_BadData , e . getMessage ( ) ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; gwAPI . route ( HttpMethods . GET , "/test/aaf/:version/:path*" , API . VOID , new GwCode ( facade , "Access TEST GUI for AAF" , true ) { @ Override public void handle ( AuthzTrans trans , HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { redirect ( trans , req , resp , context , new DME2Locator ( gwAPI . env , gwAPI . dme2Man , AUTHZ_DME2_GUI , pathParam ( req , ":version" ) , TEST , routeOffer ) , pathParam ( req , ":path" ) ) ; } catch ( LocatorException e ) { context . error ( trans , resp , Result . ERR_BadData , e . getMessage ( ) ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; gwAPI . route ( HttpMethods . GET , "/perf/aaf/:version/:path*" , API . VOID , new GwCode ( facade , "Access PERF GUI for AAF" , true ) { @ Override public void handle ( AuthzTrans trans , HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { redirect ( trans , req , resp , context , new DME2Locator ( gwAPI . env , gwAPI . dme2Man , AUTHZ_DME2_GUI , pathParam ( req , ":version" ) , PERF , routeOffer ) , pathParam ( req , ":path" ) ) ; } catch ( LocatorException e ) { context . error ( trans , resp , Result . ERR_BadData , e . getMessage ( ) ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; gwAPI . route ( HttpMethods . GET , "/dev/aaf/:version/:path*" , API . VOID , new GwCode ( facade , "Access DEV GUI for AAF" , true ) { @ Override public void handle ( AuthzTrans trans , HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { redirect ( trans , req , resp , context , new DME2Locator ( gwAPI . env , gwAPI . dme2Man , AUTHZ_DME2_GUI , pathParam ( req , ":version" ) , DEV , routeOffer ) , pathParam ( req , ":path" ) ) ; } catch ( LocatorException e ) { context . error ( trans , resp , Result . ERR_BadData , e . getMessage ( ) ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; } else { gwAPI . route ( HttpMethods . GET , "/aaf/:version/:path*" , API . VOID , new GwCode ( facade , "Access PROD GUI for AAF" , true ) { @ Override public void handle ( AuthzTrans trans , HttpServletRequest req , HttpServletResponse resp ) throws Exception { try { redirect ( trans , req , resp , context , new DME2Locator ( gwAPI . env , gwAPI . dme2Man , AUTHZ_DME2_GUI , pathParam ( req , ":version" ) , PROD , routeOffer ) , pathParam ( req , ":path" ) ) ; } catch ( LocatorException e ) { context . error ( trans , resp , Result . ERR_BadData , e . getMessage ( ) ) ; } catch ( Exception e ) { context . error ( trans , resp , Result . ERR_General , e . getMessage ( ) ) ; } } } ) ; } }
Normal Init level APIs

@param gwAPI
@param facade
@throws Exception