本文整理汇总了Java中org.openid4java.message.ParameterList.getParameterValue方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterList.getParameterValue方法的具体用法?Java ParameterList.getParameterValue怎么用?Java ParameterList.getParameterValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openid4java.message.ParameterList
的用法示例。
在下文中一共展示了ParameterList.getParameterValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssociationResponse
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
/**
* Gets the association response. Determines the mode first.
* If mode is set to associate, will set the response. Then
* builds the response parameters next and returns.
*
* @param request the request
* @return the association response
*/
public Map<String, String> getAssociationResponse(final HttpServletRequest request) {
final ParameterList parameters = new ParameterList(request.getParameterMap());
final String mode = parameters.hasParameter(OpenIdProtocolConstants.OPENID_MODE)
? parameters.getParameterValue(OpenIdProtocolConstants.OPENID_MODE)
: null;
Message response = null;
if (StringUtils.equals(mode, OpenIdProtocolConstants.ASSOCIATE)) {
response = serverManager.associationResponse(parameters);
}
final Map<String, String> responseParams = new HashMap<>();
if (response != null) {
responseParams.putAll(response.getParameterMap());
}
return responseParams;
}
示例2: getAssociationResponse
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
/**
* Gets the association response. Determines the mode first.
* If mode is set to associate, will set the response. Then
* builds the response parameters next and returns.
*
* @param request the request
* @return the association response
*/
public Map<String, String> getAssociationResponse(final HttpServletRequest request) {
final ParameterList parameters = new ParameterList(request.getParameterMap());
final String mode = parameters.hasParameter(OpenIdConstants.OPENID_MODE)
? parameters.getParameterValue(OpenIdConstants.OPENID_MODE)
: null;
Message response = null;
if (StringUtils.equals(mode, OpenIdConstants.ASSOCIATE)) {
response = serverManager.associationResponse(parameters);
}
final Map<String, String> responseParams = new HashMap<>();
if (response != null) {
responseParams.putAll(response.getParameterMap());
}
return responseParams;
}
示例3: getAssociationResponse
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
/**
* Gets the association response. Determines the mode first.
* If mode is set to associate, will set the response. Then
* builds the response parameters next and returns.
*
* @param request the request
* @return the association response
*/
public Map<String, String> getAssociationResponse(final HttpServletRequest request) {
final ParameterList parameters = new ParameterList(request.getParameterMap());
final String mode = parameters.hasParameter(OpenIdProtocolConstants.OPENID_MODE)
? parameters.getParameterValue(OpenIdProtocolConstants.OPENID_MODE)
: null;
Message response = null;
if (StringUtils.equals(mode, OpenIdProtocolConstants.ASSOCIATE)) {
response = this.serverManager.associationResponse(parameters);
}
final Map<String, String> responseParams = new HashMap<>();
if (response != null) {
responseParams.putAll(response.getParameterMap());
}
return responseParams;
}
示例4: getAssociationResponse
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
public Map<String, String> getAssociationResponse(final HttpServletRequest request) {
ParameterList parameters = new ParameterList(request.getParameterMap());
final String mode = parameters.hasParameter("openid.mode")
? parameters.getParameterValue("openid.mode")
: null;
Message response = null;
if (mode != null && mode.equals("associate")) {
response = serverManager.associationResponse(parameters);
}
final Map<String, String> responseParams = new HashMap<String, String>();
if (response != null) {
responseParams.putAll(response.getParameterMap());
}
return responseParams;
}
示例5: handleCheckAuthentication
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
private void handleCheckAuthentication(String info, HttpServletResponse response, final ParameterList requestParameter) throws IOException {
LOG.info("--> BEGIN handleCheckAuthentication");
String assocHandle = requestParameter.getParameterValue("openid.assoc_handle");
String shortLog = String.format("Returning check_authentication = true for %s", assocHandle);
LOG.info(String.format(" --> assoc_handle = %s", assocHandle));
Message responseMessage;
if (idpType.equals(IdpType.ATTACKER)) {
responseMessage = getOpenIdProcessor().generatePositiveCheckAuthenticationResponse();
} else {
responseMessage = getOpenIdProcessor().generateCorrectCheckAuthenticationResponse(requestParameter);
}
String responseText = responseMessage.keyValueFormEncoding();
response.getWriter().println(responseText);
response.setStatus(HttpServletResponse.SC_OK);
String requestText = String.format("%s\n\n%s", info, requestParameter.toString());
RequestLogger.getInstance().add(RequestType.CHECK_AUTHENTICATION, shortLog, requestText, responseText, idpType);
LOG.info("--> END handleCheckAuthentication");
}
示例6: getOpenIDMessageMode
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
/**
* Returns the mode field of the OpenID message.
*
* @param paramList
* @param response
* @param request
* @return
* @throws IOException
*/
private String getOpenIDMessageMode(ParameterList paramList, HttpServletResponse response,
HttpServletRequest request) throws IOException {
String mode = null;
if (paramList == null) {
if (log.isDebugEnabled()) {
log.debug("Invalid OpenID message :" + request.getQueryString());
}
directResponse(response, getErrorResponseText("Invalid OpenID message"));
return null;
}
mode = paramList.hasParameter(OpenId.ATTR_MODE) ? paramList.getParameterValue(OpenId.ATTR_MODE) : null;
if (log.isDebugEnabled()) {
log.debug("OpenID authentication mode :" + mode);
}
return mode;
}
示例7: handleTokenRequestWithPostRedirect
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
public void handleTokenRequestWithPostRedirect(String info, HttpServletResponse response, final ParameterList requestParameter) throws OpenIdAttackerServerException, IOException {
String assoc_handle = requestParameter.getParameterValue("openid.assoc_handle");
LOG.info(String.format("--> BEGIN handleTokenRequestwithGetRedirect for assoc_handle='%s'",
assoc_handle != null ? assoc_handle : "<NONE>"));
AttackParameterKeeper keeper = getOpenIdProcessor().processTokenRequest(requestParameter);
response.setStatus(HttpServletResponse.SC_OK);
String destinationUrl = getDestinationUrl(keeper);
boolean performAttack;
boolean interceptIdpResponse;
if (idpType == IdpType.ATTACKER) {
performAttack = OpenIdServerConfiguration.getAttackerInstance().isPerformAttack();
interceptIdpResponse = OpenIdServerConfiguration.getAttackerInstance().isInterceptIdPResponse();
} else {
performAttack = OpenIdServerConfiguration.getAnalyzerInstance().isPerformAttack();
interceptIdpResponse = OpenIdServerConfiguration.getAnalyzerInstance().isInterceptIdPResponse();
}
Map<String, String> getParameters = AttackParameterHandler.createMapByMethod(keeper, HttpMethod.GET, performAttack);
Map<String, String> postParamters = AttackParameterHandler.createMapByMethod(keeper, HttpMethod.POST, performAttack);
String postRedirectHtml = HttpPostRedirect.createPostRedirect(destinationUrl, getParameters, postParamters, interceptIdpResponse);
response.getWriter().println(postRedirectHtml);
RequestType type;
if (performAttack) {
type = RequestType.TOKEN_ATTACK;
} else {
type = RequestType.TOKEN_VALID;
}
String responseText = String.format("GET:\n\n%s\nPOST:\n\n%s", PrintHelper.mapToString(getParameters), PrintHelper.mapToString(postParamters));
RequestLogger.getInstance().add(type, "Token generated", info + "\n\n" + requestParameter.toString(), responseText, idpType);
LOG.info("--> END handleTokenRequestwithGetRedirect");
}
示例8: handleTokenRequestwithGetRedirect
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
public void handleTokenRequestwithGetRedirect(HttpServletResponse response, final ParameterList requestParameter)
throws OpenIdAttackerServerException {
String assoc_handle = requestParameter.getParameterValue("openid.assoc_handle");
LOG.info(String.format("--> BEGIN handleTokenRequestwithGetRedirect for assoc_handle='%s'",
assoc_handle != null ? assoc_handle : "<NONE>"));
AttackParameterKeeper keeper = openIdProcessor.processTokenRequest(requestParameter);
response.setStatus(HttpServletResponse.SC_SEE_OTHER);
boolean performAttack = false;
if (idpType == IdpType.ATTACKER) {
performAttack = OpenIdServerConfiguration.getAttackerInstance().isPerformAttack();
} else {
performAttack = OpenIdServerConfiguration.getAnalyzerInstance().isPerformAttack();
}
RequestType type;
if (performAttack) {
type = RequestType.TOKEN_ATTACK;
} else {
type = RequestType.TOKEN_VALID;
}
Map<String, String> getParameters = AttackParameterHandler.createMapByMethod(keeper, HttpMethod.GET, performAttack);
String location = HttpPostRedirect.createGetRequest(getDestinationUrl(keeper), getParameters);
response.setHeader("Location", location);
String responseText = String.format("GET:\n\n%s", PrintHelper.mapToString(getParameters));
RequestLogger.getInstance().add(type, "Token generated", requestParameter.toString(), responseText, idpType);
LOG.info("--> END handleTokenRequestwithGetRedirect");
}
示例9: handleRequest
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
private void handleRequest(ParameterList requestParameter, String target, HttpServletResponse response, Request baseRequest) throws IOException, OpenIdAttackerServerException, TransformerException {
// get the openIdProcessor.mode
final String method = baseRequest.getMethod();
final HttpURI uri = baseRequest.getUri();
final String protocol = baseRequest.getProtocol();
final String info = String.format("%s %s %s", method, uri, protocol);
final String mode = requestParameter.hasParameter("openid.mode")
? requestParameter.getParameterValue("openid.mode") : null;
if (uri.getCompletePath().equals("/favicon.ico")) {
handleFaviconRequest(info, response);
} else if (target.contains("xxe")) {
// Case: XXE
handleXxeRequest(info, response, requestParameter);
} /*else if (target.contains("dtd")) {
// Case: DTD
handleDtdRequest(info, response, requestParameter);
}*/ else if (mode == null) {
if (target.contains("xrds") || requestParameter.toString().contains("xrds")) {
// Case: Request XRDS Document
handleXrdsRequest(info, response);
} else {
// Case: Request HTML Document
handleHtmlDiscovery(info, response);
}
} else if ("associate".equals(mode)) {
// Case: Process Association
handleAssociationRequest(info, response, requestParameter);
} else if ("checkid_setup".equals(mode) || "checkid_immediate".equals(mode)) {
// Case: Generate Token
handleTokenRequest(info, response, requestParameter);
} else if ("check_authentication".equals(mode)) {
handleCheckAuthentication(info, response, requestParameter);
} else {
throw new IllegalStateException("Unknown Request");
}
baseRequest.setHandled(true);
}
示例10: processRequest
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
/**
* Process the request.
*
* @param httpReq
* the HTTP request
* @param httpResp
* the HTTp resposne
* @return process result string
* @throws Exception
* indicate authenticate error
*/
private String processRequest(final HttpServletRequest httpReq,
final HttpServletResponse httpResp) throws MessageException,
IOException {
Domain domain = this.getDomain(httpReq);
if (getLog().isDebugEnabled()) {
getLog().debug("domain: " + domain);
}
ServerManager serverManager =
this.getJosService().getServerManager(domain);
// extract the parameters from the request
ParameterList request = new ParameterList(httpReq.getParameterMap());
String mode = request.getParameterValue("openid.mode");
Message response;
String responseText;
if ("associate".equals(mode)) {
// --- process an association request ---
response = serverManager.associationResponse(request);
responseText = response.keyValueFormEncoding();
} else if ("checkid_setup".equals(mode)
|| "checkid_immediate".equals(mode)) {
AuthRequest authReq = AuthRequest.createAuthRequest(request,
serverManager.getRealmVerifier());
new ApprovingRequestProcessor(httpReq, httpResp, getJosService(),
serverManager, new ApprovingRequest(authReq)).checkId();
responseText = null;
} else if ("check_authentication".equals(mode)) {
// --- processing a verification request ---
response = serverManager.verify(request);
responseText = response.keyValueFormEncoding();
} else {
// --- error response ---
response = DirectError.createDirectError("Unknown request");
responseText = response.keyValueFormEncoding();
}
// return the result to the user
return responseText;
}
示例11: getLoginPageQueryParams
import org.openid4java.message.ParameterList; //导入方法依赖的package包/类
public static String getLoginPageQueryParams(ParameterList params) throws IdentityException {
String queryParams = null;
try {
String realm = params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_REALM) != null ?
URLEncoder.encode(params.getParameterValue(
OpenIDConstants.OpenIDRequestParameters.OPENID_REALM),
StandardCharsets.UTF_8.name()) : "";
String returnTo =
params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_RETURN_TO) != null ?
URLEncoder.encode(
params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_RETURN_TO),
StandardCharsets.UTF_8.name()) : "";
String claimedId =
params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_CLAIMED_ID) != null ?
URLEncoder.encode(
params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_CLAIMED_ID),
StandardCharsets.UTF_8.name()) : "";
String identity =
params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_IDENTITY) != null ?
URLEncoder.encode(params.getParameterValue(OpenIDConstants.OpenIDRequestParameters.OPENID_IDENTITY),
StandardCharsets.UTF_8.name()) : "";
queryParams = "?" + OpenIDConstants.OpenIDRequestParameters.OPENID_REALM + "=" + realm
+ "&" + OpenIDConstants.OpenIDRequestParameters.OPENID_RETURN_TO + "=" + returnTo
+ "&" + OpenIDConstants.OpenIDRequestParameters.OPENID_CLAIMED_ID + "=" + claimedId
+ "&" + OpenIDConstants.OpenIDRequestParameters.OPENID_IDENTITY + "=" + identity;
} catch (UnsupportedEncodingException e) {
log.error("UTF-8 encoding is not supported", e);
throw IdentityException.error("UTF-8 encoding is not supported");
}
String username = null;
if (params.getParameterValue(OpenIDConstants.OpenIDRequestParameters
.OPENID_IDENTITY) != null) {
username = OpenIDUtil.getUserName(params.getParameterValue(OpenIDConstants.OpenIDRequestParameters
.OPENID_IDENTITY));
queryParams = queryParams + "&" + OpenIDConstants.RequestParameter.USERNAME + "=" + username;
}
return queryParams;
}