/** */ public TelnetSAuth_A(CellEndpoint endpoint, Args args) throws Exception { _endpoint = endpoint; _args = args ; _password = args.getOpt("passwd") ; _password = _password == null ? "elch" : _password ; _localOk = args.hasOption("localOk") ; _acmCell = args.getOpt("acm") ; String pwdFile = args.getOpt( "pswdfile" ) ; synchronized (TelnetSAuth_A.class) { if( ( __passwordFile == null ) && ( pwdFile != null ) ){ __passwordFile = new UnixPassword(pwdFile) ; } } } //
/** * Usage : ... [-legacy=<port>] [-role=satellite|core] -mode=none|tls -- [<port>] <client options> */ public LocationManager(String name, String args) throws CommandException, IOException, BadConfigException { super(name, "System", args); this.args = getArgs(); coreDomains = CoreDomains.createWithMode(getCellDomainName(), getCuratorFramework(), this.args.getOpt("mode")); if (this.args.hasOption("role")) { role = CellDomainRole.valueOf(this.args.getOption("role").toUpperCase()); switch (role) { case CORE: checkArgument(this.args.argc() >= 1, "Listening port is required."); client = new CoreClient(); coreDomains.onChange(client::update); coreConfig = new CoreConfig(getCuratorFramework(), client::reset); break; default: client = new Client(); coreDomains.onChange(client::update); coreConfig = null; break; } } else { role = null; client = null; coreConfig = null; } }
public StreamEngineLoginCellFactory(Args args, CellEndpoint endpoint) { this.args = args; this.endpoint = endpoint; protocol = checkProtocol(args.getOpt("prot")); LOGGER.info("Using protocol : {}", protocol); try { authClass = toAuthClass(args.getOpt("auth"), protocol); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("No such class: " + args.getOpt("auth")); } Constructor<?> authConstructor; if (authClass != null) { try { authConstructor = authClass.getConstructor(AUTH_CON_SIGNATURE); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Class lacks authentication constructor: " + authClass); } LOGGER.trace("Using authentication constructor: {}", authConstructor); } else { authConstructor = null; LOGGER.trace("No authentication used"); } this.authConstructor = authConstructor; }
public Object ac_show_all_$_1( Args args )throws Exception { String user = args.getOpt("auth") ; if( user == null ) { throw new Exception("Not authenticated"); } String command = args.argv(0) ; _log.info( "show all : mode={};user=user", command) ; if( command.equals("exception") ) { throw new Exception("hallo otto"); } if( command.equals("null") ) { return null; } if( command.equals("object") ) { return args; } return "Done" ; } public static final String hh_check_permission = "<user> <acl>" ;
public LocationManagerConnector(String cellName, String args, SocketFactory socketFactory) { super(cellName, "System", args); Args a = getArgs(); _domain = a.getOpt("domain"); _ssf = requireNonNull(socketFactory); HostAndPort where = HostAndPort.fromString(a.getOpt("where")); _address = new InetSocketAddress(where.getHost(), where.getPort()); }
public static void main( String [] args ) { if( args.length < 1 ){ System.err.println( "Usage : ... <parseString>" ) ; System.exit(4); } Args lineArgs; if( args.length == 1 ) { lineArgs = new Args(args[0]); } else { lineArgs = new Args(args); } System.out.print( lineArgs.getInfo() ) ; System.out.println( "pvr="+lineArgs.getOpt( "pvr" ) ) ; }
String levelString = args.getOpt("level") ;
private void startListenerWithTls() throws ExecutionException, InterruptedException, UnknownHostException { checkArgument(args.hasOption("socketfactory"), "No Socketfactory provided to Core Domain for channel encryption"); String cellArgs = String.format("%s -socketfactory='%s'", Integer.parseInt((args.argc() == 1) ? args.argv(0) : args.argv(1)), args.getOpt("socketfactory")); lmTls = startListener(cellArgs); LOGGER.info("lmTls: {}; port; {} ", lmTls, lmTls.getListenPort()); info.addCore("tls", InetAddress.getLocalHost().getCanonicalHostName(), lmTls.getListenPort()); }
timeout = Long.parseLong(_args.getOpt("acceptErrorWait")); } catch (NumberFormatException e) { String listen = _args.getOpt("listen"); if (Strings.isNullOrEmpty(listen)) { _socketAddress = new InetSocketAddress(listenPort); String ssf = _args.getOpt("socketfactory"); if (ssf != null) { Args args = new Args(ssf);
public String ac_create_user_$_1( Args args )throws Exception { checkPermission( args.getOpt("auth" ) , "user.*.create" ) ; String user = args.argv(0) ; _userMetaDb.createUser( user ) ; return "" ; } public static final String hh_create_group = "<groupName>" ;
public String ac_create_acl_$_1( Args args )throws Exception { checkPermission( args.getOpt("auth") , "super.access" ) ; _aclDb.createAclItem(args.argv(0)); return "" ; } public static final String hh_ls_acl = "<aclName> -resolve" ;
@Override protected void starting() { Args args = getArgs(); checkArgument(args.argc() >= 1, "Usage : ... <dbPath>"); File dbBase = new File(args.argv(0)); _aclDb = new AclDb(new File(dbBase, "acls")); _userDb = new InMemoryUserRelation(new FileUserRelation(new File(dbBase, "relations"))); _userMetaDb = new UserMetaDb(new File(dbBase, "meta")); UserAdminCommands uac = new UserAdminCommands(_userDb, _aclDb, _userMetaDb); addCommandListener(uac); setCommandExceptionEnabled(true); // // read the password file information // String tmp; if ((tmp = args.getOpt("syspassword")) != null) { _sysPassword = new UserPasswords(new File(tmp)); _log.info("using as SystemPasswordfile : {}", tmp); } if ((tmp = args.getOpt("egpassword")) != null) { _egPassword = new UserPasswords(new File(tmp)); _log.info("using as EgPasswordfile : {}", tmp); } }
boolean resolve = !args.hasOption( "nr" ); String src = args.getOpt("source"); Object input; if (src == null) {
/** * Returns the value of an option. * * @param option the option * @return the value of the option, or null if the option is * not defined * @throws IllegalArgumentException if <code>required</code> is true * and the option is not defined. */ protected String getOption(Option option) { String s; s = args.getOpt(option.name()); if (s != null && (!s.isEmpty() || !option.required())) { return s; } if (option.required()) { throw new IllegalArgumentException(option.name() + " is a required argument"); } return option.defaultValue(); }
public String ac_remove_$_3( Args args )throws Exception { if( ! args.argv(1).equals("from") ) { throw new CommandSyntaxException("keyword 'from' missing"); } String group = args.argv(2) ; String princ = args.argv(0) ; checkPermission( args.getOpt("auth" ) , "group."+group+".access" ) ; _userDb.removeElement(group,princ); return "" ; } public static final String hh_add_access = "[-allowed|-denied] <acl> <principal>" ;
public String ac_add_$_3( Args args )throws Exception { if( ! args.argv(1).equals("to") ) { throw new CommandSyntaxException("keyword 'to' missing"); } String group = args.argv(2) ; String princ = args.argv(0) ; checkPermission( args.getOpt("auth" ) , "group."+group+".access" ) ; _userDb.addElement(group, princ); return "" ; } public static final String hh_remove = "<principalName> from <groupName>" ;
public String ac_create_group_$_1( Args args )throws Exception { checkPermission( args.getOpt("auth" ) , "user.*.create" ) ; String group = args.argv(0) ; _userMetaDb.createGroup( group ) ; _userDb.createContainer( group ) ; _aclDb.createAclItem( "group."+group+".access" ) ; return "" ; } public static final String hh_destroy_principal = "<principalName>" ;
} catch (InterruptedException ignored) { } catch (BadConfigException be) { LOGGER.error("Invalid ports provided for starting connector in mode {}", args.getOpt("mode"));
public String ac_destroy_principal_$_1( Args args )throws Exception { checkPermission( args.getOpt("auth" ) , "user.*.create" ) ; String user = args.argv(0) ; Enumeration<String> e = _userDb.getElementsOf(user) ; if( e.hasMoreElements() ) { throw new DatabaseException("Not Empty : " + user); } e = _userDb.getParentsOf(user) ; if( e.hasMoreElements() ) { throw new DatabaseException("Still in groups : " + user); } _userMetaDb.removePrincipal( user ) ; try{ _userDb.removeContainer( user ) ; _aclDb.removeAclItem( "group."+user+".access" ) ; }catch( Exception ee ){ _log.warn(args + " : " + ee ) ; // // not an error // // System.err.println(" removeContainer : "+ee ) ; } return "" ; } public static final String hh_add = "<principalName> to <groupName>" ;
public String ac_add_access_$_2( Args args )throws Exception { boolean allowed = !args.hasOption("denied") ; String acl = args.argv(0) ; String princ = args.argv(1) ; checkPermission( args.getOpt("auth") , "acl."+acl+".access" ) ; if( allowed ){ _aclDb.addAllowed( acl , princ ) ; }else{ _aclDb.addDenied( acl , princ ) ; } return "" ; } public static final String hh_create_acl = "<aclName>" ;