本文整理汇总了Java中org.openid4java.message.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.openid4java.message包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssociationResponse
import org.openid4java.message.Message; //导入依赖的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.Message; //导入依赖的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.Message; //导入依赖的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.Message; //导入依赖的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: addSReg
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* Add Simple Register extension message to the response message.
*
* @param response
* the response message to add to
* @param persona
* the persona
* @throws MessageException
* if add extension failed
*/
private void addSReg(final Message response, final Persona persona)
throws MessageException {
if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG)) {
MessageExtension ext = authRequest
.getExtension(SRegMessage.OPENID_NS_SREG);
if (ext instanceof SRegRequest) {
SRegRequest sregReq = (SRegRequest) ext;
// data released by the user
if (persona != null) {
Map<String, String> userDataSReg = persona.toAliasValueMap();
SRegResponse sregResp = SRegResponse.createSRegResponse(
sregReq, userDataSReg);
// (alternatively) manually add attribute values
// sregResp.addAttribute("email", email);
response.addExtension(sregResp);
}
} else {
throw new UnsupportedOperationException(ext.getClass()
+ " is unsupported.");
}
}
}
示例6: handleCheckAuthentication
import org.openid4java.message.Message; //导入依赖的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");
}
示例7: processTokenRequest
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* Creates an OpenID Token. Depending of the global config, either a token
* for the valid user or for the attacker is created.
*
* @param authRequest
*
* @return
*
* @throws MessageException
* @throws ServerException
* @throws AssociationException
*/
private AttackParameterKeeper processTokenRequest(final AuthRequest authRequest) throws OpenIdAttackerServerException {
final String userSelId = getValidUser().getIdentifier();
final String userSelClaimed = getValidUser().getClaimedId();
final Message token = serverManager.authResponse(authRequest, userSelId, userSelClaimed, true, false);
if (token instanceof AuthSuccess) {
try {
processAxExtension(token, authRequest);
processSRegExtension(token, authRequest);
generateSignatureForValidValues((AuthSuccess) token);
generateSignatureForAttackValues();
} catch (ServerException | MessageException | AssociationException ex) {
throw new OpenIdAttackerServerException(ex.getMessage());
}
} else {
throw new OpenIdAttackerServerException("Error while creating auth Response");
}
return getKeeper();
}
示例8: processSRegExtension
import org.openid4java.message.Message; //导入依赖的package包/类
private Message processSRegExtension(Message token, final AuthRequest authRequest) throws MessageException {
String sregNamespace = detectSRegVersion(authRequest);
if (sregNamespace != null) {
MessageExtension ext = authRequest.getExtension(sregNamespace);
if (ext instanceof SRegRequest) {
SRegRequest sregReq = (SRegRequest) ext;
SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, getValidUser().getUserDataMap());
token.addExtension(sregResp, "sreg");
} else if (ext instanceof SRegResponse) {
// what to do here?
} else {
final String message = String.format("TODO - Support of '%s'", ext.getClass().getCanonicalName());
throw new UnsupportedOperationException(message);
}
}
return token;
}
示例9: buildAuthenticationResponse
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* We sign directly (final 'true') because we don't add extensions
* response message can be either a DirectError or an AuthSuccess here.
*
* @param serverManager the server manager
* @param ticketId the ticket id
* @param service the service
* @param parameters the parameters
* @param associated the associated
* @param successFullAuthentication the success full authentication
* @param id the id
* @return response response
*/
protected Response buildAuthenticationResponse(final ServerManager serverManager,
final String ticketId, final OpenIdService service,
final Map<String, String> parameters,
final boolean associated, final boolean successFullAuthentication,
final String id) {
final Message response = serverManager.authResponse(this.parameterList, id, id,
successFullAuthentication, true);
parameters.putAll(response.getParameterMap());
if (!associated) {
parameters.put(OpenIdProtocolConstants.OPENID_ASSOCHANDLE, ticketId);
}
return buildRedirect(service, parameters);
}
示例10: OpenIDToken
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* Constructs an OpenID token encapsulating the provided OpenID Message.
* Should be used on the OP/STS side to generate a RSTR.
*
* @param openidMessage The OpenID message obtained from
* ServerManager.authResponse().
*/
public OpenIDToken(Message openidMessage)
{
setOpenIDMessage(openidMessage);
if (DEBUG)
_log.debug("Created " + _tokenType +" token");
}
示例11: setOpenIDMessage
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* Sets the OpenID Message to encapsulate into the token.
*/
public void setOpenIDMessage(Message openidMessage)
{
this._openidMessage = openidMessage;
if (OpenIDTokenType.OPENID20_TOKEN.toString().equals(
openidMessage.getParameterValue("openid.ns")))
_tokenType = OpenIDTokenType.OPENID20_TOKEN;
else
_tokenType = OpenIDTokenType.OPENID11_TOKEN;
}
示例12: getToken
import org.openid4java.message.Message; //导入依赖的package包/类
/**
* Generates the XML string representation of the OpenID token.
*/
public String getToken()
{
StringBuffer token = new StringBuffer();
token.append("<openid:OpenIDToken xmlns:openid=\"" +
Message.OPENID2_NS + "\">");
token.append(_openidMessage.keyValueFormEncoding());
token.append("</openid:OpenIDToken>");
return token.toString();
}
示例13: handleAssociationRequest
import org.openid4java.message.Message; //导入依赖的package包/类
public void handleAssociationRequest(String info, HttpServletResponse response, final ParameterList requestParameter) throws IOException {
LOG.info("--> BEGIN handleAssociationRequest");
Message openidResponse = getOpenIdProcessor().processAssociationRequest(requestParameter);
String assocHandle = openidResponse.getParameterValue("assoc_handle");
String shortLog = String.format("Association established: %s", assocHandle);
String requestText = info + "\n\n" + requestParameter.toString();
LOG.info(String.format(" --> assoc_handle = %s", assocHandle));
response.setStatus(HttpServletResponse.SC_OK);
String responseText = openidResponse.keyValueFormEncoding();
response.getWriter().println(responseText);
RequestLogger.getInstance().add(RequestType.ASSOCIATION, shortLog, requestText, responseText, idpType);
LOG.info("--> END handleAssociationRequest");
}
示例14: handleError
import org.openid4java.message.Message; //导入依赖的package包/类
public void handleError(HttpServletResponse response, HttpServletRequest request, final String errorMessage, final int ERROR_CODE) throws IOException {
LOG.info("--> BEGIN handleError");
Message openidResponse = DirectError.createDirectError(errorMessage);
response.setStatus(ERROR_CODE);
response.setContentType("text/html;charset=utf-8");
String responseText = openidResponse.keyValueFormEncoding();
response.getWriter().println(responseText);
String requestContent = String.format("%s %s\n\nParameters:\n\n%s",
request.getMethod(),
request.getRequestURL(),
new ParameterList(request.getParameterMap()));
RequestLogger.getInstance().add(RequestType.ERROR, errorMessage, requestContent, errorMessage, idpType);
LOG.info("--> END handleError");
}
示例15: generatePositiveCheckAuthenticationResponse
import org.openid4java.message.Message; //导入依赖的package包/类
public Message generatePositiveCheckAuthenticationResponse() {
HashMap<String, String> result = new LinkedHashMap<>();
result.put("ns", "http://specs.openid.net/auth/2.0");
result.put("is_valid", "true");
ParameterList responseParameters = new ParameterList(result);
try {
Message m = VerifyResponse.createVerifyResponse(responseParameters);
return m;
} catch (MessageException ex) {
throw new IllegalStateException("This should never happen", ex);
}
}