List of usage examples for java.util Scanner close
public void close()
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function acquire a newly issued ticket from SPFE.</p> * * @param auth_type Defines which credentials will be asked of the user to authorize this ticket. * Currently only two values supported: 'p': to ask for PassKey and password; empty string to ask * for PassKey only (default).//ww w . ja v a 2 s. co m * @param ttl The period in seconds for the ticket to remain valid since issuance. The default * value is 120 seconds. * @return Ticket issued by the SPFE * @throws IOException * @throws WWPassProtocolException */ public String getTicket(String auth_type, int ttl) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("auth_type", auth_type); parameters.put("ttl", Integer.toString(ttl)); Scanner scanner = new Scanner(makeRequest("GET", "get", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function check the authentication of the ticket.</p> * * @param ticket The ticket to validate. * @param auth_type Defines which credentials will be asked of the user to authorize this ticket. * Currently only two values supported: 'p': to ask for PassKey and password; empty string to ask * for PassKey only (default).//from ww w .java2s.c o m * @param ttl The period in seconds for the ticket to remain valid since issuance. The default * value is 120 seconds. * @return Returns current ticket or newly issued ticket. The new ticket should be used in future * operations with the SPFE. * @throws IOException * @throws WWPassProtocolException */ public String putTicket(String ticket, String auth_type, int ttl) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("auth_type", auth_type); parameters.put("ttl", Integer.toString(ttl)); Scanner scanner = new Scanner(makeRequest("GET", "put", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request string data stored in the user's data container.</p> * * @param ticket The authenticated ticket issued by the SPFE. * @return Returns the data stored in the user's data container. Returns "None" character sequence if the data * container does not exist./*from w ww . j ava 2 s. c o m*/ * @throws IOException * @throws WWPassProtocolException */ public String readDataAsString(String ticket) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); Scanner scanner = new Scanner(makeRequest("GET", "read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Gets an id of the user from the Service Provider Front End. This ID is unique for one * Service Provider, and different for different Service Providers.</p> * * @param ticket Ticket issued by the SPFE * @param auth_type Defines which credentials should have been asked of the user to authenticate * this ticket. Currently, only two values are supported: 'p' for a PassKey and access code, * '' (empty string) for a PassKey only (default). * @return PUID issued by the SPFE//from w ww. j a v a 2 s . c o m * @throws IOException * @throws WWPassProtocolException */ public String getPUID(String ticket, String auth_type) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("auth_type", auth_type); Scanner scanner = new Scanner(makeRequest("GET", "puid", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request String data stored in the user's data container.</p> * * @param ticket The authenticated ticket issued by the SPFE. * @param container Arbitrary string (only the first 32 bytes matter) that identifies the user's data container. * @return Returns the data stored in the user's data container. Returns "None" character sequence if the data * container does not exist.//from ww w.j a v a 2 s .co m * @throws IOException * @throws WWPassProtocolException */ public String readDataAsString(String ticket, String container) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("container", container); Scanner scanner = new Scanner(makeRequest("GET", "read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.medigy.persist.model.data.EntitySeedDataPopulator.java
/** * Loads the reference data contained in separate data files */// w ww. ja v a2s . c om protected void loadExternalReferenceData() { try { InputStream propertyFileStream = Environment.class.getResourceAsStream(EXTERNAL_DATA_PROPERTY_FILE); if (propertyFileStream == null) propertyFileStream = Thread.currentThread().getContextClassLoader() .getResourceAsStream(EXTERNAL_DATA_PROPERTY_FILE); if (propertyFileStream == null) { log.warn("'" + EXTERNAL_DATA_PROPERTY_FILE + "' property file not found for loading reference data contained " + "in external files."); return; } Properties props = new java.util.Properties(); props.load(propertyFileStream); final Enumeration keys = props.keys(); while (keys.hasMoreElements()) { final String className = (String) keys.nextElement(); final String dataFileName = props.getProperty(className); InputStream stream = Environment.class.getResourceAsStream(dataFileName); if (stream == null) stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(dataFileName); Scanner sc = new Scanner(stream); int rowsAdded = 0; if (sc.hasNextLine()) { sc.findInLine( "\\\"([ \\.0-9a-zA-Z]*)\\\"\\s*\\\"([ \\.0-9a-zA-Z]*)\\\"\\s*\\\"([ \\.0-9a-zA-Z]*)\\\"\\s*\\\"([ \\.0-9a-zA-Z]*)\\\""); try { MatchResult result = sc.match(); final Class refClass = Class.forName(className); final Object refObject = refClass.newInstance(); if (refObject instanceof AbstractReferenceEntity) { final AbstractReferenceEntity refEntity = (AbstractReferenceEntity) refObject; refEntity.setCode(result.group(0)); refEntity.setLabel(result.group(1)); refEntity.setDescription(result.group(2)); HibernateUtil.getSession().save(refEntity); rowsAdded++; } } catch (Exception e) { log.error(className + ": Error at data row count = " + rowsAdded + " \n" + ExceptionUtils.getStackTrace(e)); } } sc.close(); log.info(className + ", Rows Added = " + rowsAdded); } //InputStream stream = new FileInputStream("e:\\netspective\\medigy\\persistence\\database\\refdata\\icd9-codes.txt"); } catch (Exception e) { log.error(ExceptionUtils.getStackTrace(e)); } }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request string data stored in the user's data container and lock it.</p> * * @param ticket The authenticated ticket issued by the SPFE. * @param lockTimeout The period in seconds for the data container to remain protected from the new data being * accessed./*w w w . j av a 2 s . c o m*/ * @return Returns the data stored in the user's data container, represented as String. Returns "None" character sequence if the data * container does not exist. * @throws IOException * @throws WWPassProtocolException */ public String readDataAsStringAndLock(String ticket, int lockTimeout) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("to", Integer.toString(lockTimeout)); parameters.put("lock", "1"); Scanner scanner = new Scanner(makeRequest("GET", "read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request string data stored in the Service * Provider data container.</p>//from w w w .j av a 2s. c o m * * @param pfid The data container identifier as returned by createPFID. * @return Returns the data stored in the Service Provider data container, represented as String. Returns "None" * character sequence if the data container does not exist. * @throws IOException * @throws WWPassProtocolException */ public String readDataSPasString(byte[] pfid) throws IOException, WWPassProtocolException { HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("pfid", pfid); Scanner scanner = new Scanner(makeRequest("GET", "sp/read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request string data stored in the user's data container and lock it.</p> * * @param ticket The authenticated ticket issued by the SPFE. * @param container Arbitrary string (only the first 32 bytes matter) that identifies the user's data container. * @param lockTimeout The period in seconds for the data container to remain protected from the new data being * accessed.// w w w . jav a 2s .co m * @return Returns the data stored in the user's data container, represented as String. Returns "None" character * sequence if the data container does not exist. * @throws IOException * @throws WWPassProtocolException */ public String readDataAsStringAndLock(String ticket, String container, int lockTimeout) throws IOException, WWPassProtocolException { HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put("ticket", ticket); parameters.put("container", container); parameters.put("to", Integer.toString(lockTimeout)); parameters.put("lock", "1"); Scanner scanner = new Scanner(makeRequest("GET", "read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }
From source file:com.wwpass.connection.WWPassConnection.java
/** * <p>Calls to this function request the string data stored in the Service * Provider's Data Container and try to atomically lock an associated lock.</p> * * @param pfid The data container identifier as returned by createPFID. * @param lockTimeout The period in seconds for the data container to remain protected from * the new data being accessed./*from w ww . j a v a2 s .c o m*/ * @return Returns the data stored in the Service Provider data container. Returns "False" character sequence if * the data container does not exist. * @throws IOException * @throws WWPassProtocolException */ public String readDataSPasStringAndLock(byte[] pfid, int lockTimeout) throws IOException, WWPassProtocolException { HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put("pfid", pfid); parameters.put("to", Integer.toString(lockTimeout)); parameters.put("lock", "1"); Scanner scanner = new Scanner(makeRequest("GET", "sp/read", parameters)); StringBuilder sb = new StringBuilder(); while (scanner.hasNextLine()) { sb.append(scanner.nextLine()); } scanner.close(); return sb.toString(); }