List of usage examples for org.apache.commons.lang3 StringUtils substringBetween
public static String substringBetween(final String str, final String open, final String close)
Gets the String that is nested in between two Strings.
From source file:org.openecomp.sdnc.sli.SliPluginUtils.SvcLogicContextList.java
private static int getCtxListIndex(String key, String prefix) { String ctx_index_str = StringUtils.substringBetween(key.substring(prefix.length()), "[", "]"); try {/*from w ww . j av a 2 s . co m*/ return Integer.parseInt(ctx_index_str); } catch (NumberFormatException e) { throw new IllegalStateException( "Could not parse index value \"" + ctx_index_str + "\" in context memory key \"" + key + "\"", e); } }
From source file:org.openlmis.converter.BaseTypeConverter.java
List<String> getArrayValues(String value) { if (isBlank(value)) { return Collections.emptyList(); }//from w w w . j a v a 2 s .co m // single value if (!(value.startsWith("[") && value.endsWith("]"))) { return Lists.newArrayList(value); } String rawValues = StringUtils.substringBetween(value, "[", "]"); return isNotBlank(rawValues) ? Lists.newArrayList(StringUtils.split(rawValues, ',')) : Collections.emptyList(); }
From source file:org.openmainframe.ade.scores.LastSeenScorer.java
/** * Gets the delta values (change in seconds between each message instance) calculated by the * LastSeenLogginScoreContinuous class. Reformats the delta values so it the deltas are in an integer * array.// ww w.j a v a2 s. co m * @param analyzedMessageSummary The analysis results of a MessageSummary object. Message summaries contain * statistics and information on message instances. i.e. text body message, message id, severity, etc. * @return The delta values in an integer array. */ protected Integer[] extractDelta(IAnalyzedMessageSummary ms) { final String rawDelta = ms.getStatistics() .getStringStat(LastSeenLoggingScorerContinuous.class.getSimpleName() + "." + "res"); if (rawDelta.equals("[]")) { return null; } final List<String> stringDelta = Arrays .asList(StringUtils.split(StringUtils.substringBetween(rawDelta, "[", "]"), ", ")); final Integer[] delta = new Integer[stringDelta.size()]; for (int i = 0; i < stringDelta.size(); ++i) { delta[i] = Integer.decode(stringDelta.get(i)); } return delta; }
From source file:org.pac4j.oauth.client.LinkedInClient.java
@Override protected LinkedInProfile extractUserProfile(final String body) { final LinkedInProfile profile = new LinkedInProfile(); for (final String attribute : OAuthAttributesDefinitions.linkedinDefinition.getAllAttributes()) { final String value = StringUtils.substringBetween(body, "<" + attribute + ">", "</" + attribute + ">"); profile.addAttribute(attribute, value); if (LinkedInAttributesDefinition.URL.equals(attribute)) { final String id = StringUtils.substringBetween(value, "id=", "&authType="); profile.setId(id);/*ww w . ja v a 2 s . c om*/ } } return profile; }
From source file:org.pac4j.oauth.client.PayPalClientIT.java
@Override protected String getCallbackUrl(final WebClient webClient, final HtmlPage authorizationPage) throws Exception { final HtmlForm form = authorizationPage.getForms().get(0); final HtmlTextInput email = form.getInputByName("email"); email.setValueAttribute("testscribeup@gmail.com"); final HtmlPasswordInput password = form.getInputByName("password"); password.setValueAttribute("a1z2e3r4!$"); final HtmlSubmitInput submit = form.getInputByName("_eventId_submit"); final HtmlPage confirmPage = submit.click(); final HtmlAnchor anchor = (HtmlAnchor) confirmPage.getElementById("continueButtonLink"); final HtmlPage confirmPage2 = anchor.click(); final String content = confirmPage2.asXml(); final String url = StringUtils.substringBetween(content, "redirectUrl = \"", "\";"); final HtmlPage callbackPage = webClient.getPage(url); final String callbackUrl = callbackPage.getUrl().toString(); logger.debug("callbackUrl : {}", callbackUrl); return callbackUrl; }
From source file:org.pac4j.oauth.client.YahooClient.java
/** * {@inheritDoc}/* w w w . j a v a 2 s . co m*/ */ @Override protected YahooProfile retrieveUserProfileFromToken(final Token accessToken) { // get the guid : https://developer.yahoo.com/social/rest_api_guide/introspective-guid-resource.html String body = sendRequestForData(accessToken, getProfileUrl(accessToken)); final String guid = StringUtils.substringBetween(body, "<value>", "</value>"); logger.debug("guid : {}", guid); if (StringUtils.isBlank(guid)) { final String message = "Cannot find guid from body : " + body; logger.error(message); throw new HttpCommunicationException(message); } body = sendRequestForData(accessToken, "https://social.yahooapis.com/v1/user/" + guid + "/profile?format=json"); final YahooProfile profile = extractUserProfile(body); addAccessTokenToProfile(profile, accessToken); return profile; }
From source file:org.pac4j.oauth.profile.linkedin2.LinkedIn2Profile.java
public String getOAuth10Id() { String url = getSiteStandardProfileRequest(); return StringUtils.substringBetween(url, "id=", "&authType="); }
From source file:org.pac4j.play.cas.logout.PlayCacheLogoutHandler.java
public void destroySession(WebContext context) { final PlayWebContext webContext = (PlayWebContext) context; final String logoutRequest = context.getRequestParameter("logoutRequest"); logger.debug("logoutRequest: {}", logoutRequest); final String ticket = StringUtils.substringBetween(logoutRequest, "SessionIndex>", "</"); logger.debug("extract ticket: {}", ticket); final String sessionId = (String) Cache.get(ticket); Cache.remove(ticket);//from www . ja v a 2 s . c om webContext.getJavaSession().put(Pac4jConstants.SESSION_ID, sessionId); final ProfileManager profileManager = new ProfileManager(webContext); profileManager.remove(true); }
From source file:org.pac4j.play.PlayLogoutHandler.java
@Override public void destroySession(final WebContext context) { final String logoutRequest = context.getRequestParameter("logoutRequest"); logger.debug("logoutRequest : {}", logoutRequest); final String ticket = StringUtils.substringBetween(logoutRequest, "SessionIndex>", "</"); logger.debug("extract ticket : {}", ticket); final String sessionId = (String) StorageHelper.get(ticket); logger.debug("found sessionId : {}", sessionId); StorageHelper.removeProfile(sessionId); StorageHelper.remove(ticket);/* w w w. ja v a 2s.c o m*/ }
From source file:org.pac4j.vertx.cas.VertxSharedDataLogoutHandler.java
@Override public void destroySession(WebContext context) { final String logoutRequest = context.getRequestParameter("logoutRequest"); LOG.debug("logoutRequest: {}", logoutRequest); final String ticket = StringUtils.substringBetween(logoutRequest, "SessionIndex>", "</"); LOG.debug("extract ticket: {}", ticket); // get the session id first, then remove the pac4j profile from that session // TODO: ALSO MODIFY TO REMOVE VERTX USER final CompletableFuture<Void> userLogoutFuture = new CompletableFuture<>(); final String sessionId = getSessionId(ticket); sessionStore.getObservable(sessionId).map(session -> session.remove(SESSION_USER_HOLDER_KEY)) .doOnError(e -> {//from ww w . j av a2 s .c om e.printStackTrace(); }).subscribe(s -> userLogoutFuture.complete(null)); try { userLogoutFuture.get(blockingTimeoutSeconds, TimeUnit.SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { userLogoutFuture.completeExceptionally(new TechnicalException(e)); } doDestroySession(ticket); }