/*JWTBearerInterface
549
public function getClientKey($client_id, $subject)
    {
        if (isset($this->jwt[$client_id])) {
            $jwt = $this->jwt[$client_id];
            if ($jwt) {
                if ($jwt["subject"] == $subject) {
                    return $jwt["key"];
                }
            }
        }

        return false;
    }
47867
protected void renderTextAreaValue(FacesContext facesContext, UIComponent uiComponent) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();
        
        Object addNewLineAtStart = uiComponent.getAttributes().get(ADD_NEW_LINE_AT_START_ATTR);
        if (addNewLineAtStart != null)
        {
            boolean addNewLineAtStartBoolean = false;
            if (addNewLineAtStart instanceof String)
            {
                addNewLineAtStartBoolean = Boolean.valueOf((String)addNewLineAtStart);
            }
            else if (addNewLineAtStart instanceof Boolean)
            {
                addNewLineAtStartBoolean = (Boolean) addNewLineAtStart;
            }
            if (addNewLineAtStartBoolean)
            {
                writer.writeText("\n", null);
            }
        }
        
        String strValue = org.apache.myfaces.shared.renderkit.RendererUtils.getStringValue(facesContext, uiComponent);
        if (strValue != null)
        {
            writer.writeText(strValue, org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR);
        }
    }
1104804
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		SocialShare socialShare = (SocialShare) component;
		ResponseWriter rw = context.getResponseWriter();
		String clientId = socialShare.getClientId();

		if (!BsfUtils.isStringValued(socialShare.getShares())) {
			return;
		}

		beginResponsiveWrapper(component, rw);

		rw.startElement("div", socialShare);
		rw.writeAttribute("id", clientId + "_wrapper", "id");

		// Create the div container
		rw.startElement("div", socialShare);
		rw.writeAttribute("id", clientId, "id");
		if (BsfUtils.isStringValued(socialShare.getStyle()))
			rw.writeAttribute("style", socialShare.getStyle(), "style");
		rw.writeAttribute("class", socialShare.getStyleClass(), "class");
		rw.endElement("div");

		rw.endElement("div");

		// decode shares
		String shares = "";
		String[] _share = socialShare.getShares().split(",");
		for (int i = 0; i < _share.length; i++) {
			_share[i] = "'" + _share[i] + "'";
			shares += _share[i];
			if (i < _share.length - 1)
				shares += ",";
		}

		String showCount = socialShare.getShowCount();
		if (!"false".equalsIgnoreCase(showCount) && !"true".equalsIgnoreCase(showCount)
				&& BsfUtils.isStringValued(showCount))
			showCount = "'" + showCount + "'";

		String scriptId = "#" + BsfUtils.escapeJQuerySpecialCharsInSelector(clientId);
		rw.startElement("script", socialShare);
		rw.writeText("$(function () { " +
		// social share section
				"$('" + scriptId + "').jsSocials({  "
				+ (BsfUtils.isStringValued(socialShare.getUrl()) ? "url: '" + socialShare.getUrl() + "', " : "")
				+ (BsfUtils.isStringValued(socialShare.getText()) ? "text: '" + socialShare.getText() + "', " : "")
				+ (BsfUtils.isStringValued(socialShare.getShareIn()) ? "shareIn: '" + socialShare.getShareIn() + "', "	: "")
				+ (BsfUtils.isStringValued(showCount) ? "showCount: " + showCount + ", " : "")
				+ (socialShare.isShowLabel() ? "showLabel: true, " : "showLabel: false,") + "shares: [" + shares + "] "
				+ "});" 
				+ (socialShare.isDisableBlock() ?
				// no block
						"" :
						// overlay
						"$('" + scriptId + "_wrapper').block({" 
						      + "	message: '" + socialShare.getBlockMessage() 
						      + "',"
						      + "	css: { " + "		border: 'none', " 
						      + "     padding: '8px', "
						      + "		backgroundColor: '#000', " 
						      + "		'-webkit-border-radius': '10px', "
						      + "		'-moz-border-radius': '10px', " 
						      + " 	'border-radius': '10px', "
						      + "		opacity: 1, " 
						      + "		color: '#fff', " + "		fontSize: '12px', "
						      + "		cursor: 'default', " 
						      + "		top: '40%', " 
						      + "		left: '35%' " 
						      + "	}, "
						      + " overlayCSS: { "
						      + "     backgroundColor: '#000', " 
						      + "     opacity: 0.6, "
						      + "     cursor: 'default' " 
						      + " } " 
						      + "}); " 
						      + "$('" + scriptId
						      + "_wrapper').click(function() { $('" + scriptId + "_wrapper').unblock(); }); ")
				              + "});", null);

		rw.endElement("script");
	}
1269638
@Override
    public Builder issuer(String issuerUrl) throws InvalidClaimException {
        if (issuerUrl != null && !issuerUrl.isEmpty()) {
            claims.put(Claims.ISSUER, issuerUrl);
        } else {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new Object[] { Claims.ISSUER, issuerUrl });
            throw new InvalidClaimException(err);
        }
        return this;
    }
274941
private AuthenticationResult handleJwtSSO(HttpServletRequest req, HttpServletResponse res) {
        String jwtCookieName = JwtSSOTokenHelper.getJwtCookieName();
        if (jwtCookieName == null) { // jwtsso feature not active
            return null;
        }

        String encodedjwtssotoken = ssoCookieHelper.getJwtSsoTokenFromCookies(req, jwtCookieName);

        if (encodedjwtssotoken == null) { //jwt sso cookie is missing, look at the auth header
            encodedjwtssotoken = getJwtBearerToken(req);
        }
        if (encodedjwtssotoken == null) {
            return null;
        } else {
            if (LoggedOutJwtSsoCookieCache.contains(encodedjwtssotoken)) {
                String LoggedOutMsg = "JWT_ALREADY_LOGGED_OUT";
                if (req.getAttribute(LoggedOutMsg) == null) {
                    Tr.audit(tc, LoggedOutMsg, new Object[] {});
                    req.setAttribute(LoggedOutMsg, "true");
                }

                return new AuthenticationResult(AuthResult.FAILURE, Tr.formatMessage(tc, LoggedOutMsg));
            }
            return authenticateWithJwt(req, res, encodedjwtssotoken);
        }
    }
1342528
protected void renderInputBegin(FacesContext facesContext,
            UIComponent uiComponent) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();
        
        writer.startElement(HTML.INPUT_ELEM, uiComponent);
        writer.writeAttribute(HTML.TYPE_ATTR, org.apache.myfaces.shared.renderkit.html.HTML.INPUT_TYPE_PASSWORD, null);

        if (uiComponent instanceof ClientBehaviorHolder
                && !((ClientBehaviorHolder) uiComponent).getClientBehaviors().isEmpty())
        {
            writer.writeAttribute(HTML.ID_ATTR, 
                                  uiComponent.getClientId(facesContext), null);
        }
        else
        {
            HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
        }
        writer.writeAttribute(HTML.NAME_ATTR,
                              uiComponent.getClientId(facesContext), null);

        boolean isRedisplay;
        if (uiComponent instanceof HtmlInputSecret)
        {
            isRedisplay = ((HtmlInputSecret)uiComponent).isRedisplay();
        }
        else
        {
            isRedisplay = org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent, 
                    JSFAttr.REDISPLAY_ATTR, false);
        }
        if (isRedisplay)
        {
            String strValue = RendererUtils.getStringValue(facesContext, uiComponent);
            writer.writeAttribute(HTML.VALUE_ATTR, strValue, JSFAttr.VALUE_ATTR);
        }

        Map<String, List<ClientBehavior>> behaviors = null;
        if (uiComponent instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
            
            long commonPropertiesMarked = 0L;
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
            }
            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderChangeEventProperty(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderEventProperties(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
                if (isCommonEventsOptimizationEnabled(facesContext))
                {
                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                }
                else
                {
                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                            facesContext, writer, uiComponent, behaviors);
                }
            }
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabledAndEvents(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
            }
        }
        else
        {
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabled(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
            }
        }

        if (isDisabled(facesContext, uiComponent))
        {
            writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
        }

        if (isAutocompleteOff(facesContext, uiComponent))
        {
            writer.writeAttribute(HTML.AUTOCOMPLETE_ATTR, AUTOCOMPLETE_VALUE_OFF, HTML.AUTOCOMPLETE_ATTR);
        }
    }
1300698
@Override
    public java.util.concurrent.Future<GetSubscriptionAttributesResult> getSubscriptionAttributesAsync(String subscriptionArn,
            com.amazonaws.handlers.AsyncHandler<GetSubscriptionAttributesRequest, GetSubscriptionAttributesResult> asyncHandler) {

        return getSubscriptionAttributesAsync(new GetSubscriptionAttributesRequest().withSubscriptionArn(subscriptionArn), asyncHandler);
    }
653206
protected void renderInputTag(FacesContext context, ResponseWriter rw, String clientId,
			SelectBooleanCheckbox selectBooleanCheckbox) throws IOException {
		int numberOfDivs = 0;
		String responsiveStyleClass = Responsive.getResponsiveStyleClass(selectBooleanCheckbox, false).trim();
		if (responsiveStyleClass.length() > 0 && isHorizontalForm(selectBooleanCheckbox)) {
			rw.startElement("div", selectBooleanCheckbox);
			rw.writeAttribute("class", responsiveStyleClass, "class");
			numberOfDivs++;
		}
		
		renderInputTag(rw, context, selectBooleanCheckbox, clientId);
		renderInputTagAttributes(rw, clientId, selectBooleanCheckbox);
		// Render Ajax Capabilities
		AJAXRenderer.generateBootsFacesAJAXAndJavaScript(FacesContext.getCurrentInstance(), selectBooleanCheckbox, rw, false);

		renderInputTagValue(context, rw, selectBooleanCheckbox);
		renderInputTagEnd(rw, selectBooleanCheckbox);
		renderInputTagHelper(rw, context, selectBooleanCheckbox, clientId);
		
		while (numberOfDivs > 0) {
			rw.endElement("div"); 
			numberOfDivs--;
		}
	}
1301334
@Override
	public String getJwtCookieName() {
		// TODO Auto-generated method stub
		JwtSsoBuilderConfig jwtssobuilderConfig = getJwtSSOBuilderConfig();
		if (jwtssobuilderConfig != null) {
			return jwtssobuilderConfig.getCookieName();
		}
		return null;
	}
1211674
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered())
			return;

		ProgressBar progressBar = (ProgressBar) component;
		ResponseWriter rw = context.getResponseWriter();
		String clientId = progressBar.getClientId();

        String span = startColSpanDiv(rw, progressBar);
		rw.startElement("div", progressBar); // outer div
		rw.writeAttribute("class", "progress", "class");
		rw.writeAttribute("id", clientId, "id");
		rw.writeAttribute("class", progressBar.getStyleClass(), null);
		rw.writeAttribute("style", progressBar.getStyle(), null);
		Tooltip.generateTooltip(context, progressBar, rw);

		rw.startElement("div", progressBar); // inner div, responsible for the actual bar

		int max = progressBar.getMax();
		int min = progressBar.getMin();

		if (max == min)
			throw new FacesException("ProgressBar: max and min values must not match.");

		String svalue = progressBar.getValue();
		if (null == svalue) {
			throw new FacesException("Please define the value of the progressbar. It must not be null, nor may it be omitted.");
		}
		double value = Double.parseDouble(svalue);
		double progressCompletion = (value - min) / (max - min) * 100;

		String style = "width: " + progressCompletion + "%;";
		//append inline style, if set
		style += progressBar.getContentStyle() != null ? progressBar.getContentStyle() : "";

		rw.writeAttribute("style", style, null);

		rw.writeAttribute("role", "progressbar", "role");
		rw.writeAttribute("aria-valuemax", max, "aria-valuemax");
		rw.writeAttribute("aria-valuemin", min, "aria-valuemin");
		rw.writeAttribute("aria-valuenow", progressCompletion, "aria-valuenow");

		NumberFormat nf = NumberFormat.getInstance();
		nf.setMaximumFractionDigits(progressBar.getMaxDecimalPlaces());

		String caption = progressBar.getCaption();

		if (caption != null && !caption.isEmpty())
			rw.writeAttribute("aria-valuetext", caption, "aria-valuetext");

		writeStyleClass(progressBar, rw);

		String labelText = caption != null ? caption : nf.format(progressCompletion) + "%";
		writeCaption(progressBar, rw, labelText);

		rw.endElement("div");
		rw.endElement("div");
        closeColSpanDiv(rw, span);
		Tooltip.activateTooltips(context, progressBar);
	}
1033178
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		RemoteCommand remoteCommand = (RemoteCommand) component;
		ResponseWriter rw = context.getResponseWriter();
		String clientId = remoteCommand.getClientId();

		String parameters=remoteCommand.getParameters();
		String parametersAsJson=null;
		if (null != parameters && parameters.length()>0) {
			parametersAsJson = "";
			String[] params = parameters.split(",");
			for (String p: params) {
				p=p.trim();
				parametersAsJson += "'" + p + "':" + p + ",";
			}
			parametersAsJson=parametersAsJson.substring(0, parametersAsJson.length()-1);
		}
		StringBuilder call = AJAXRenderer.generateAJAXCall(context, remoteCommand, null, parametersAsJson);
		String name = remoteCommand.getName();
		if (null == name) {
			throw new FacesException("b:remoteCommand: Please define the name of the JavaScript function calling the Java backend.");
		}
			
		rw.startElement("script", component);
		rw.writeAttribute("id", clientId, null);
		String c = call.toString().replace("callAjax(this,", "callAjax(document.getElementById('" + clientId + "'),");
		if (parameters!=null) {
			rw.append("function " + name + "(" + parameters + ", event){" + c + "}");
		} else {
			rw.append("function " + name + "(event){" + c + "}");
		}
		rw.endElement("script");

	}
742700
@Override
    public Builder claimFrom(JwtToken jwt, String claimName) throws InvalidClaimException, InvalidTokenException {
        isValidToken(jwt);
        if (JwtUtils.isNullEmpty(claimName)) {
            String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_ERR", new Object[] { claimName });
            throw new InvalidClaimException(err);
        }
        if (jwt.getClaims().get(claimName) != null) {
            claims.put(claimName, jwt.getClaims().get(claimName));
        }
        // else {
        // String err = Tr.formatMessage(tc, "JWT_INVALID_CLAIM_VALUE_ERR", new
        // Object[] { claimName, "null" });
        // throw new InvalidClaimException(err);
        // }
        return this;
    }
1313459
void init() throws MpJwtProcessingException {
        String methodName = "init";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName);
        }
        setUpJsseHelper();
        if (this.jsseHelper == null) {
            if (tc.isDebugEnabled()) {
                Tr.exit(tc, methodName);
            }
            return;
        }
        Properties sslProps = null;
        try {
            sslProps = getSslPropertiesFromJsseHelper();
        } catch (Exception e) {
            String msg = Tr.formatMessage(tc, "ERROR_LOADING_SSL_PROPS", new Object[] { e.getLocalizedMessage() });
            Tr.error(tc, msg);
            throw new MpJwtProcessingException(msg, e);
        }
        setKeystoreAndTruststoreNames(sslProps);
        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName);
        }
    }
25989
private String getBearerToken(HttpConnectionInterceptorContext context) {
        final AtomicReference<String> iamTokenResponse = new AtomicReference<String>();
        boolean result = super.requestCookie(context, iamServerUrl, iamTokenRequestBody,
                "application/x-www-form-urlencoded", "application/json",
                new StoreBearerCallable(iamTokenResponse));
        if (result) {
            return iamTokenResponse.get();
        } else {
            return null;
        }
    }
798358
@Override
	public boolean shouldUseLtpaIfJwtAbsent() {
		// TODO Auto-generated method stub
		JwtSsoBuilderConfig jwtssobuilderConfig = getJwtSSOBuilderConfig();
		if (jwtssobuilderConfig != null) {
			return jwtssobuilderConfig.isUseLtpaIfJwtAbsent();
		}
		return true;
	}
325702
private void processTokenRequest(HttpServletResponse response, JwtConfig jwtConfig) throws IOException {

		String tokenString = new TokenBuilder().createTokenString(jwtConfig);
		addNoCacheHeaders(response);
		response.setStatus(200);

		if (tokenString == null) {
			return;
		}
		try {
			PrintWriter pw = response.getWriter();
			response.setHeader(WebConstants.HTTP_HEADER_CONTENT_TYPE, WebConstants.HTTP_CONTENT_TYPE_JSON);
			pw.write("{\"token\": \"" + tokenString + "\"}");
			pw.flush();
			pw.close();
		} catch (IOException e) {
			if (tc.isDebugEnabled()) {
				Tr.debug(tc, "Caught an exception attempting to get the response writer: " + e.getLocalizedMessage());
			}
		}
	}
734598
@Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        PuiButton button = (PuiButton) component;
        writer.startElement("pui-button", component);
        String actionListener = button.getActionListener();
        if ((null != actionListener) && (!actionListener.contains("("))) {
            actionListener += "()";
        }
        renderNonEmptyAttribute(writer, "actionListener", actionListener);
        renderNonEmptyAttribute(writer, "disabled", button.getDisabled());
        renderNonEmptyAttribute(writer, "icon", button.getIcon());
        renderNonEmptyAttribute(writer, "iconPos", button.getIconPos());
        renderNonEmptyAttribute(writer, "value", button.getValue());
        writer.endElement("pui-button");
    }