Java Code Examples for org.openid4java.message.Message#keyValueFormEncoding()

The following examples show how to use org.openid4java.message.Message#keyValueFormEncoding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomOpenIdProviderHandler.java    From OpenID-Attacker with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
 
Example 2
Source File: CustomOpenIdProviderHandler.java    From OpenID-Attacker with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 3
Source File: CustomOpenIdProviderHandler.java    From OpenID-Attacker with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example 4
Source File: OpenIDProviderService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param params
 * @return
 * @throws Exception
 */
public String getOpenIDAssociationResponse(OpenIDParameterDTO[] params) {
    Message message = null;
    ParameterList paramList = null;

    paramList = getParameterList(params);
    message = OpenIDProvider.getInstance().getManager().associationResponse(paramList);
    return message.keyValueFormEncoding();
}
 
Example 5
Source File: OpenIDProviderService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * The verify method used by the OpenID Provider when using the OpenID Dumb
 * Mode
 *
 * @param params
 * @return
 * @throws Exception
 */
public String verify(OpenIDParameterDTO[] params) throws IdentityProviderException {
    String disableDumbMode = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_DISABLE_DUMB_MODE);

    if ("true".equalsIgnoreCase(disableDumbMode)) {
        throw new IdentityProviderException("OpenID relying parties with dumb mode not supported");
    }

    ParameterList paramList = getParameterList(params);
    Message message = OpenIDProvider.getInstance().getManager().verify(paramList);
    return message.keyValueFormEncoding();
}