List of usage examples for java.util StringTokenizer nextElement
public Object nextElement()
From source file:org.hfoss.posit.android.sync.Communicator.java
/** * /*ww w. j a v a2 s . c o m*/ * Retrieve finds from the server using a Communicator. * * @param serverGuids * @return */ public static boolean getFindsFromServer(Context context, String authKey, String serverGuids) { String guid; int rows = 0; StringTokenizer st = new StringTokenizer(serverGuids, ","); while (st.hasMoreElements()) { guid = st.nextElement().toString(); ContentValues cv = getRemoteFindById(context, authKey, guid); if (cv == null) { return false; // Shouldn't be null--we know its ID } else { Log.i(TAG, cv.toString()); try { // Find out what Find class POSIT is configured for Class<? extends Find> findClass = FindPluginManager.mFindPlugin.getmFindClass(); Log.i(TAG, "Find class = " + findClass.getSimpleName()); // Update the DB Find find = DbHelper.getDbManager(context).getFindByGuid(guid); if (find != null) { Log.i(TAG, "Updating existing find: " + find.getId()); Find updatedFind = findClass.newInstance(); updatedFind.updateObject(cv); // Find updatedFind = (OutsideInFind)find; // ((OutsideInFind) updatedFind).updateObject(cv); updatedFind.setId(find.getId()); rows = DbHelper.getDbManager(context).updateWithoutHistory(updatedFind); } else { // find = new OutsideInFind(); find = findClass.newInstance(); Log.i(TAG, "Inserting new find: " + find.getId()); find.updateObject(cv); // ((OutsideInFind) find).updateObject(cv); Log.i(TAG, "Adding a new find " + find); rows = DbHelper.getDbManager(context).insertWithoutHistory(find); } } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } DbHelper.releaseDbManager(); return rows > 0; }
From source file:gtu._work.ui.ObnfInsertCreaterUI.java
private void manualDefineDbFieldBtnAction() { String manualDefineText = manualDefineArea.getText(); String manualDefinePkText = StringUtils.defaultString(manualDefinePkArea.getText()); if (StringUtils.isBlank(manualDefineText)) { JCommonUtil._jOptionPane_showMessageDialog_error("?"); return;//from ww w .j av a 2 s . com } Set<String> useList = new HashSet<String>(); StringTokenizer tok = new StringTokenizer(manualDefineText); while (tok.hasMoreElements()) { String f = (String) tok.nextElement(); useList.add(f); } Set<String> pkList = new HashSet<String>(); StringTokenizer tok2 = new StringTokenizer(manualDefinePkText); while (tok2.hasMoreElements()) { String f = (String) tok2.nextElement(); pkList.add(f); } Map<String, String> pkMap = new HashMap<String, String>(); Map<String, String> columnMap = new HashMap<String, String>(); DefaultListModel dbFieldListModel = (DefaultListModel) dbFieldList.getModel(); if (dbFieldListModel.isEmpty()) { JCommonUtil._jOptionPane_showMessageDialog_error("\"?ObnfString\""); return; } for (Enumeration<?> enu = dbFieldListModel.elements(); enu.hasMoreElements();) { KeyValue kv = (KeyValue) enu.nextElement(); if (!pkList.isEmpty() && pkList.contains(kv.getKey())) { pkMap.put(kv.getKey(), kv.value); } else if (pkList.isEmpty() && kv.pk) { pkMap.put(kv.getKey(), kv.value); } else { columnMap.put(kv.getKey(), kv.value); } } StringBuffer sb = new StringBuffer(); sb.append("COLUMN=>\n"); this.keepKey(columnMap, useList, sb); JCommonUtil._jOptionPane_showMessageDialog_info(sb); this.putToDbFieldList(pkMap, columnMap); }
From source file:org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator.java
/** * Method that generates the JWT./* w ww . java2 s .c o m*/ * * @return signed JWT token * @throws IdentityOAuth2Exception */ @Override public void generateToken(OAuth2TokenValidationMessageContext messageContext) throws IdentityOAuth2Exception { String clientId = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getConsumerKey(); long issuedTime = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getIssuedTime().getTime(); String authzUser = messageContext.getResponseDTO().getAuthorizedUser(); int tenantID = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getTenantID(); String tenantDomain = OAuth2Util.getTenantDomain(tenantID); boolean isExistingUser = false; RealmService realmService = OAuthComponentServiceHolder.getRealmService(); // TODO : Need to handle situation where federated user name is similar to a one we have in our user store if (realmService != null && tenantID != MultitenantConstants.INVALID_TENANT_ID && tenantID == OAuth2Util.getTenantIdFromUserName(authzUser)) { try { UserRealm userRealm = realmService.getTenantUserRealm(tenantID); if (userRealm != null) { UserStoreManager userStoreManager = (UserStoreManager) userRealm.getUserStoreManager(); isExistingUser = userStoreManager .isExistingUser(MultitenantUtils.getTenantAwareUsername(authzUser)); } } catch (UserStoreException e) { log.error("Error occurred while loading the realm service", e); } } OAuthAppDAO appDAO = new OAuthAppDAO(); OAuthAppDO appDO; try { appDO = appDAO.getAppInformation(clientId); // Adding the OAuthAppDO as a context property for further use messageContext.addProperty("OAuthAppDO", appDO); } catch (IdentityOAuth2Exception e) { log.debug(e.getMessage(), e); throw new IdentityOAuth2Exception(e.getMessage()); } catch (InvalidOAuthClientException e) { log.debug(e.getMessage(), e); throw new IdentityOAuth2Exception(e.getMessage()); } String subscriber = appDO.getUserName(); String applicationName = appDO.getApplicationName(); //generating expiring timestamp long currentTime = Calendar.getInstance().getTimeInMillis(); long expireIn = currentTime + 1000 * 60 * getTTL(); // Prepare JWT with claims set JWTClaimsSet claimsSet = new JWTClaimsSet(); claimsSet.setIssuer(API_GATEWAY_ID); claimsSet.setSubject(authzUser); claimsSet.setIssueTime(new Date(issuedTime)); claimsSet.setExpirationTime(new Date(expireIn)); claimsSet.setClaim(API_GATEWAY_ID + "/subscriber", subscriber); claimsSet.setClaim(API_GATEWAY_ID + "/applicationname", applicationName); claimsSet.setClaim(API_GATEWAY_ID + "/enduser", authzUser); if (claimsRetriever != null) { //check in local cache String[] requestedClaims = messageContext.getRequestDTO().getRequiredClaimURIs(); if (requestedClaims == null && isExistingUser) { // if no claims were requested, return all requestedClaims = claimsRetriever.getDefaultClaims(authzUser); } CacheKey cacheKey = null; Object result = null; if (requestedClaims != null) { cacheKey = new ClaimCacheKey(authzUser, requestedClaims); result = claimsLocalCache.getValueFromCache(cacheKey); } SortedMap<String, String> claimValues = null; if (result != null) { claimValues = ((UserClaims) result).getClaimValues(); } else if (isExistingUser) { claimValues = claimsRetriever.getClaims(authzUser, requestedClaims); UserClaims userClaims = new UserClaims(claimValues); claimsLocalCache.addToCache(cacheKey, userClaims); } if (isExistingUser) { String claimSeparator = getMultiAttributeSeparator(authzUser, tenantID); if (StringUtils.isBlank(claimSeparator)) { userAttributeSeparator = claimSeparator; } } if (claimValues != null) { Iterator<String> it = new TreeSet(claimValues.keySet()).iterator(); while (it.hasNext()) { String claimURI = it.next(); String claimVal = claimValues.get(claimURI); List<String> claimList = new ArrayList<String>(); if (userAttributeSeparator != null && claimVal.contains(userAttributeSeparator)) { StringTokenizer st = new StringTokenizer(claimVal, userAttributeSeparator); while (st.hasMoreElements()) { String attValue = st.nextElement().toString(); if (StringUtils.isNotBlank(attValue)) { claimList.add(attValue); } } claimsSet.setClaim(claimURI, claimList.toArray(new String[claimList.size()])); } else { claimsSet.setClaim(claimURI, claimVal); } } } } JWT jwt = null; if (!JWSAlgorithm.NONE.equals(signatureAlgorithm)) { JWSHeader header = new JWSHeader(JWSAlgorithm.RS256); header.setX509CertThumbprint(new Base64URL(getThumbPrint(tenantDomain, tenantID))); jwt = new SignedJWT(header, claimsSet); jwt = signJWT((SignedJWT) jwt, tenantDomain, tenantID); } else { jwt = new PlainJWT(claimsSet); } if (log.isDebugEnabled()) { log.debug("JWT Assertion Value : " + jwt.serialize()); } OAuth2TokenValidationResponseDTO.AuthorizationContextToken token; token = messageContext.getResponseDTO().new AuthorizationContextToken("JWT", jwt.serialize()); messageContext.getResponseDTO().setAuthorizationContextToken(token); }
From source file:com.serena.rlc.provider.tfs.TFSBaseServiceProvider.java
@Getter(name = QUEUE_TYPE, displayName = "Queue Type", description = "Get Build Queue Type.") public FieldInfo getQueueTypeFieldValues(String fieldName, List<Field> properties) throws ProviderException { //TODO: queueTypes in provider configuration String queueTypes = "buildController,agentPool"; if (StringUtils.isEmpty(queueTypes)) { return null; }//from w w w . j a v a2 s. c o m StringTokenizer st = new StringTokenizer(queueTypes, ",;"); FieldInfo fieldInfo = new FieldInfo(fieldName); List<FieldValueInfo> values = new ArrayList<>(); FieldValueInfo value; String qType; while (st.hasMoreElements()) { qType = (String) st.nextElement(); qType = qType.trim(); value = new FieldValueInfo(qType, qType); values.add(value); } fieldInfo.setValues(values); return fieldInfo; }
From source file:org.hfoss.posit.android.sync.Communicator.java
/** * The data has the form: ["1","2", ...] or '[]' * @param data/*from w w w . j a va2s. c o m*/ * the list of image ids * @return the last image id in the list or null */ private static String parseImageIds(String data) { Log.i(TAG, "imageIdData = " + data + " " + data.length()); if (data.equals("[]")) { return null; } data = data.trim(); data = data.substring(1, data.length() - 1); //removes brackets StringTokenizer st = new StringTokenizer(data, ","); //in the form "123" String imgId = null; //only care about one image for this version of posit while (st.hasMoreElements()) { imgId = (String) st.nextElement(); Log.i(TAG, "Is this with quotes: " + imgId); imgId = imgId.substring(1, imgId.indexOf('"', 1)); // removes quotes. find the second quote in the string Log.i(TAG, "Is this without quotes: " + imgId); } Log.i(TAG, "Planning to fetch imageId " + imgId + " for a find"); return imgId; }
From source file:com.irets.bl.service.SearchService.java
public SearchService() { try {/*from w ww . ja v a 2 s .com*/ InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("login_credentials.properties"); this.loginCredentials.load(is); is.close(); this.objectRequestPhoto = this.loginCredentials.getProperty("objectRequestPhoto"); this.photoURLAvailable = this.loginCredentials.getProperty("photoURLAvailable"); this.defaultPageSize = Integer.valueOf(this.loginCredentials.getProperty("default_page_size", "20")); this.maxPageSize = Integer.valueOf(this.loginCredentials.getProperty("max_page_size", "100")); this.hwmSearchResponses = Integer .valueOf(this.loginCredentials.getProperty("high_water_mark_for_search_responses", "500")); this.mlsNumberPrefix = this.loginCredentials.getProperty("mls_number_prefix", ""); this.pendingStatus = this.loginCredentials.getProperty("pendingStatus", "Pending"); this.activeStatus = this.loginCredentials.getProperty("activeStatus", "Active"); this.server = this.loginCredentials.getProperty("server"); this.mlsList = this.loginCredentials.getProperty("mlsList"); if (mlsList != null) { //System.out.println("mlsList is " + mlsList); mlsSpecData = new ArrayList<MlsSpecificData>(); if (mlsList.indexOf(",") > -1) { StringTokenizer sToken = new StringTokenizer(mlsList, ","); while (sToken.hasMoreElements()) { String key = (String) sToken.nextElement(); String name = (String) this.loginCredentials.get(key + "Name"); String logo = (String) this.loginCredentials.get(key + "Logo"); String disc = (String) this.loginCredentials.get(key + "Disclaimer"); MlsSpecificData msd = new MlsSpecificData(key, name, logo, disc); mlsSpecData.add(msd); } } else { String name = (String) this.loginCredentials.get(mlsList + "Name"); String logo = (String) this.loginCredentials.get(mlsList + "Logo"); String disc = (String) this.loginCredentials.get(mlsList + "Disclaimer"); MlsSpecificData msd = new MlsSpecificData(mlsList, name, logo, disc); mlsSpecData.add(msd); } } this.exteriorFeatures = this.loginCredentials.getProperty("exteriorFeaturesList"); if (exteriorFeatures != null) { System.out.println("Ext features List ," + this.exteriorFeatures); this.exteriorFeaturesList = new ArrayList<String>(); // Traversing the Exterior Features if (exteriorFeatures.indexOf(",") > -1) { StringTokenizer sToken = new StringTokenizer(exteriorFeatures, ","); while (sToken.hasMoreElements()) { String key = (String) sToken.nextElement(); exteriorFeaturesList.add(key); } } else {// for just one exterior feature System.out.println("Only one Exterior Features... check"); exteriorFeaturesList.add(this.exteriorFeatures); } // Number of Keys should be same as the above exterior features String keys = (String) this.loginCredentials.get("exteriorFeaturesListKeys"); if (keys != null) { this.extFeaturesData = new ArrayList<ExteriorFeaturesData>(); if (keys.indexOf(",") > -1) { StringTokenizer sToken = new StringTokenizer(keys, ","); int idx = 0; while (sToken.hasMoreElements()) { String key = (String) sToken.nextElement(); String name = this.exteriorFeaturesList.get(idx); String fields = (String) this.loginCredentials.get(key); ExteriorFeaturesData efd = new ExteriorFeaturesData(key, name, fields); this.extFeaturesData.add(efd); idx++; System.out.println("Key/name/data is, " + key + "?" + name + "?" + fields); } } else {// for just one key System.out.println("Only one Exterior Features keys... check"); String fields = (String) this.loginCredentials.get(keys); ExteriorFeaturesData efd = new ExteriorFeaturesData(keys, this.exteriorFeaturesList.get(0), fields); this.extFeaturesData.add(efd); } } } } catch (Exception e) { //ignore e.printStackTrace(); } }
From source file:org.kchine.rpf.PoolUtils.java
public static String currentWinProcessID() throws Exception { String pslistpath = System.getProperty("java.io.tmpdir") + "/rpf/WinTools/" + "ps.exe"; System.out.println(pslistpath); File pslistFile = new File(pslistpath); if (!pslistFile.exists()) { pslistFile.getParentFile().mkdirs(); InputStream is = PoolUtils.class.getResourceAsStream("/wintools/ps.exe"); RandomAccessFile raf = new RandomAccessFile(pslistFile, "rw"); raf.setLength(0);/*from w ww .j a v a 2 s. co m*/ int b; while ((b = is.read()) != -1) raf.write((byte) b); raf.close(); } String[] command = new String[] { pslistpath }; Runtime rt = Runtime.getRuntime(); final Process proc = rt.exec(command); final StringBuffer psPrint = new StringBuffer(); final StringBuffer psError = new StringBuffer(); new Thread(new Runnable() { public void run() { try { InputStream is = proc.getInputStream(); int b; while ((b = is.read()) != -1) { psPrint.append((char) b); } } catch (Exception e) { e.printStackTrace(); } } }).start(); new Thread(new Runnable() { public void run() { try { InputStream is = proc.getErrorStream(); int b; while ((b = is.read()) != -1) { psError.append((char) b); } } catch (Exception e) { e.printStackTrace(); } } }).start(); int exitVal = proc.waitFor(); if (exitVal != 0) throw new Exception("ps exit code : " + exitVal); BufferedReader reader = new BufferedReader(new StringReader(psPrint.toString())); String line; int i = 0; while (!(line = reader.readLine()).startsWith("PID PPID THR PR NAME")) ++i; ++i; while ((line = reader.readLine()) != null) { StringTokenizer st = new StringTokenizer(line, " "); st.nextElement(); String PPID = (String) st.nextElement(); st.nextElement(); st.nextElement(); if (line.endsWith("\\ps.exe")) return PPID; ++i; } return null; }
From source file:org.jahia.data.viewhelper.principal.PrincipalViewHelper.java
/** * Create the view helper with a given string format given by the following * syntax :/*ww w .j a va 2 s .c o m*/ * textFormat ::= (principal)? (permissions)? (provider)? (name)? (properties)? * principal ::= "Principal" * permissions ::= "Permissions" * provider ::= "Provider," size * name ::= "Name," size * properties ::= "Properties," size * size ::= number{2..n} * * @param textFormat The string format given by the above syntax. */ public PrincipalViewHelper(String[] textFormat) { for (int i = 0; i < textFormat.length; i++) { final StringTokenizer st = new StringTokenizer(textFormat[i], ","); final String fieldToDisplay = (String) st.nextElement(); if (selectBoxFieldsHeading.contains(fieldToDisplay)) { if (st.hasMoreElements()) { selectBoxFieldsSize.add(Integer.valueOf(((String) st.nextElement()).trim())); } else { selectBoxFieldsSize.add(new Integer(-1)); } try { selectBoxFieldsMethod.add(PrincipalViewHelper.class.getMethod("get" + fieldToDisplay, new Class[] { JCRNodeWrapper.class, Integer.class })); } catch (java.lang.NoSuchMethodException nsme) { logger.error("Internal class error ! Please check Jahia code", nsme); } } } }
From source file:org.pentaho.reporting.libraries.base.util.IOUtils.java
/** * Parses the given name and returns the name elements as List of Strings. * * @param name the name, that should be parsed. * @return the parsed name.//from w w w . java 2 s . c o m */ private List<String> parseName(final String name) { final ArrayList<String> list = new ArrayList<String>(); final StringTokenizer strTok = new StringTokenizer(name, "/"); while (strTok.hasMoreElements()) { final String s = (String) strTok.nextElement(); if (s.length() != 0) { list.add(s); } } return list; }
From source file:net.sourceforge.dvb.projectx.xinput.ftp.XInputFileImpl.java
/** * @throws java.io.IOException// www . j a v a2s . co m */ public String[] getUserFTPCommand() { StringTokenizer st = new StringTokenizer(Common.getSettings().getProperty(Keys.KEY_FtpServer_Commands), "|"); String[] tokens = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) tokens[i] = st.nextElement().toString().trim(); return tokens; }