• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OAuthSignatureMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.oauth.signature.OAuthSignatureMethod的典型用法代码示例。如果您正苦于以下问题:Java OAuthSignatureMethod类的具体用法?Java OAuthSignatureMethod怎么用?Java OAuthSignatureMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OAuthSignatureMethod类属于net.oauth.signature包,在下文中一共展示了OAuthSignatureMethod类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readBytes

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Read the lines between BEGIN and END marker and convert
 * the Base64 encoded content into binary byte array.
 * 
 * @return DER encoded octet stream
 * @throws IOException
 */
private byte[] readBytes(BufferedReader reader, String endMarker) throws IOException
{
    String          line = null;
    StringBuffer    buf = new StringBuffer();

    while ((line = reader.readLine()) != null)
    {
        if (line.indexOf(endMarker) != -1) {

            return OAuthSignatureMethod.decodeBase64(buf.toString());
        }

        buf.append(line.trim());        
    }

    throw new IOException("Invalid PEM file: No end marker");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:PEMReader.java


示例2: getOAuthURL

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/** 
        * getOAuthURL - Form a GET request signed by OAuth
 * @param method
 * @param url
 * @param oauth_consumer_key
 * @param oauth_consumer_secret
 * @param signature
 */
public static String getOAuthURL(String method, String url, 
	String oauth_consumer_key, String oauth_secret, String signature)
{
	OAuthMessage om = new OAuthMessage(method, url, null);
	om.addParameter(OAuth.OAUTH_CONSUMER_KEY, oauth_consumer_key);
	if ( signature == null ) signature = OAuth.HMAC_SHA1;
	om.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, signature);
	om.addParameter(OAuth.OAUTH_VERSION, "1.0");
	om.addParameter(OAuth.OAUTH_TIMESTAMP, new Long((new Date().getTime()) / 1000).toString());
	om.addParameter(OAuth.OAUTH_NONCE, UUID.randomUUID().toString());

	OAuthConsumer oc = new OAuthConsumer(null, oauth_consumer_key, oauth_secret, null);
	try {
	    OAuthSignatureMethod osm = OAuthSignatureMethod.newMethod(signature, new OAuthAccessor(oc));
	    osm.sign(om);
	    url = OAuth.addParameters(url, om.getParameters());
	    return url;
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return null;
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:31,代码来源:BasicLTIUtil.java


示例3: invoke

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Send a request message to the service provider and get the response.
 * 
 * @return the response
 * @throws IOException
 *             failed to communicate with the service provider
 * @throws OAuthProblemException
 *             the HTTP response status code was not 200 (OK)
 */
public OAuthMessage invoke(OAuthMessage request, ParameterStyle style)
		throws IOException, OAuthException {
	OAuthResponseMessage response = access(request, style);
	if ((response.getHttpResponse().getStatusCode() / 100) != 2) {
		OAuthProblemException problem = response.toOAuthProblemException();
		try {
			problem.setParameter(
					OAuthProblemException.SIGNATURE_BASE_STRING,
					OAuthSignatureMethod.getBaseString(request));
		} catch (Exception ignored) {
		}
		throw problem;
	}
	return response;
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:25,代码来源:OAuthClient.java


示例4: createOAuthUrlString

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Creates a URL that contains the necessary OAuth query parameters for the
 * given JSON string.
 *
 * The required OAuth parameters are:
 * <ul>
 * <li>oauth_body_hash</li>
 * <li>oauth_consumer_key</li>
 * <li>oauth_signature_method</li>
 * <li>oauth_timestamp</li>
 * <li>oauth_nonce</li>
 * <li>oauth_version</li>
 * <li>oauth_signature</li>
 * </ul>
 *
 * @param method the HTTP method.
 * @param jsonBody the JSON string to construct the URL from.
 * @param rpcServerUrl the URL of the handler that services the JSON-RPC
 *        request.
 * @param accessor the OAuth accessor used to create the signed string.
 * @return a URL for the given JSON string, and the required OAuth parameters.
 */
public static String createOAuthUrlString(String method,
    String jsonBody, String rpcServerUrl, OAuthAccessor accessor, List<SimpleEntry<String, String>> params)
    throws IOException, URISyntaxException, OAuthException {
  OAuthMessage message =
      new OAuthMessage(method, rpcServerUrl, params);

  if (jsonBody != null) {
    // Compute the hash of the body.
    byte[] rawBody = jsonBody.getBytes(UTF_8);
    byte[] hash = DigestUtils.sha(rawBody);
    byte[] encodedHash = Base64.encodeBase64(hash);
    message.addParameter(OAUTH_BODY_HASH, new String(encodedHash, UTF_8));
  }

  // Add other parameters.

  message.addRequiredParameters(accessor);
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Signature base string: " + OAuthSignatureMethod.getBaseString(message));
  }

  // Construct the resulting URL.
  StringBuilder sb = new StringBuilder(rpcServerUrl);
  char connector = '?';
  for (Map.Entry<String, String> p : message.getParameters()) {
    if (!p.getKey().equals(jsonBody)) {
      sb.append(connector);
      sb.append(URLEncoder.encode(p.getKey(), UTF_8));
      sb.append('=');
      sb.append(URLEncoder.encode(p.getValue(), UTF_8));
      connector = '&';
    }
  }
  return sb.toString();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:58,代码来源:WaveService.java


示例5: testValidateMessageFailOnValidateMessageIOException

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessageFailOnValidateMessageIOException() throws Exception {

    SimpleOAuthValidator sov = Mockito.mock(SimpleOAuthValidator.class);
    PowerMockito.whenNew(SimpleOAuthValidator.class).withNoArguments().thenReturn(sov);
    Mockito.doThrow(new IOException("failed")).when(sov).validateMessage(Matchers.any(OAuthMessage.class), Matchers.any(OAuthAccessor.class));
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenReturn("");

    LtiVerificationResult result = BasicLTIUtil.validateMessage(Mockito.mock(HttpServletRequest.class), "https://example.com/lti-launch", "secret");        

    Assert.assertEquals(LtiError.BAD_REQUEST, result.getError());
    Assert.assertEquals(Boolean.FALSE, result.getSuccess());
    Assert.assertEquals(null, result.getLtiLaunchResult());
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:16,代码来源:BasicLTIUtilTest.java


示例6: testValidateMessageFailOnValidateMessageOAuthException

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessageFailOnValidateMessageOAuthException() throws Exception {

    SimpleOAuthValidator sov = Mockito.mock(SimpleOAuthValidator.class);
    PowerMockito.whenNew(SimpleOAuthValidator.class).withNoArguments().thenReturn(sov);
    Mockito.doThrow(new OAuthException("failed")).when(sov).validateMessage(Matchers.any(OAuthMessage.class), Matchers.any(OAuthAccessor.class));
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenReturn("");

    LtiVerificationResult result = BasicLTIUtil.validateMessage(Mockito.mock(HttpServletRequest.class), "https://example.com/lti-launch", "secret");

    Assert.assertEquals(LtiError.BAD_REQUEST, result.getError());
    Assert.assertEquals(Boolean.FALSE, result.getSuccess());
    Assert.assertEquals(null, result.getLtiLaunchResult());
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:16,代码来源:BasicLTIUtilTest.java


示例7: testValidateMessageFailOnValidateMessageURISyntaxException

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessageFailOnValidateMessageURISyntaxException() throws Exception {

    SimpleOAuthValidator sov = Mockito.mock(SimpleOAuthValidator.class);
    PowerMockito.whenNew(SimpleOAuthValidator.class).withNoArguments().thenReturn(sov);
    Mockito.doThrow(new URISyntaxException("failed", "failed")).when(sov).validateMessage(Matchers.any(OAuthMessage.class), Matchers.any(OAuthAccessor.class));
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenReturn("");

    LtiVerificationResult result = BasicLTIUtil.validateMessage(Mockito.mock(HttpServletRequest.class), "https://example.com/lti-launch", "secret");        

    Assert.assertEquals(LtiError.BAD_REQUEST, result.getError());
    Assert.assertEquals(Boolean.FALSE, result.getSuccess());
    Assert.assertEquals(null, result.getLtiLaunchResult());
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:16,代码来源:BasicLTIUtilTest.java


示例8: testValidateMessagePass

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessagePass() throws Exception {

    SimpleOAuthValidator sov = Mockito.mock(SimpleOAuthValidator.class);
    PowerMockito.whenNew(SimpleOAuthValidator.class).withNoArguments().thenReturn(sov);
    Mockito.doNothing().when(sov).validateMessage(Matchers.any(OAuthMessage.class), Matchers.any(OAuthAccessor.class));
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenReturn("");
    
    HttpServletRequest req = Mockito.mock(HttpServletRequest.class);
    Mockito.when(req.getParameter("user_id")).thenReturn("pgray");
    Mockito.when(req.getParameter("roles")).thenReturn("instructor, teacher,administrator");
    Mockito.when(req.getParameter("lti_version")).thenReturn("lpv1");
    Mockito.when(req.getParameter("lti_message_type")).thenReturn("lti");
    Mockito.when(req.getParameter("resource_link_id")).thenReturn("12345");
    Mockito.when(req.getParameter("context_id")).thenReturn("9876");
    Mockito.when(req.getParameter("launch_presentation_return_url")).thenReturn("http://example.com/return");
    Mockito.when(req.getParameter("tool_consumer_instance_guid")).thenReturn("instance_id");

    LtiVerificationResult result = BasicLTIUtil.validateMessage(req, "https://example.com/lti-launch", "secret1");        

    Assert.assertEquals(null, result.getError());
    Assert.assertEquals(Boolean.TRUE, result.getSuccess());
    Assert.assertNotNull(result.getLtiLaunchResult());
    
    Assert.assertEquals("pgray", result.getLtiLaunchResult().getUser().getId());
    Assert.assertEquals(3, result.getLtiLaunchResult().getUser().getRoles().size());
    Assert.assertTrue(result.getLtiLaunchResult().getUser().getRoles().contains("instructor"));
    Assert.assertTrue(result.getLtiLaunchResult().getUser().getRoles().contains("teacher"));
    Assert.assertTrue(result.getLtiLaunchResult().getUser().getRoles().contains("administrator"));
    
    Assert.assertEquals("lpv1", result.getLtiLaunchResult().getVersion());
    Assert.assertEquals("lti", result.getLtiLaunchResult().getMessageType());
    Assert.assertEquals("12345", result.getLtiLaunchResult().getResourceLinkId());
    Assert.assertEquals("9876", result.getLtiLaunchResult().getContextId());
    Assert.assertEquals("http://example.com/return", result.getLtiLaunchResult().getLaunchPresentationReturnUrl());
    Assert.assertEquals("instance_id", result.getLtiLaunchResult().getToolConsumerInstanceGuid());
    
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:40,代码来源:BasicLTIUtilTest.java


示例9: createOAuthUrlString

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Creates a URL that contains the necessary OAuth query parameters for the
 * given JSON string.
 *
 * The required OAuth parameters are:
 * <ul>
 * <li>oauth_body_hash</li>
 * <li>oauth_consumer_key</li>
 * <li>oauth_signature_method</li>
 * <li>oauth_timestamp</li>
 * <li>oauth_nonce</li>
 * <li>oauth_version</li>
 * <li>oauth_signature</li>
 * </ul>
 *
 * @param jsonBody the JSON string to construct the URL from.
 * @param rpcServerUrl the URL of the handler that services the JSON-RPC
 *        request.
 * @param accessor the OAuth accessor used to create the signed string.
 * @return a URL for the given JSON string, and the required OAuth parameters.
 */
public static String createOAuthUrlString(
    String jsonBody, String rpcServerUrl, OAuthAccessor accessor)
    throws IOException, URISyntaxException, OAuthException {
  OAuthMessage message =
      new OAuthMessage(POST, rpcServerUrl, Collections.<SimpleEntry<String, String>>emptyList());

  // Compute the hash of the body.
  byte[] rawBody = jsonBody.getBytes(UTF_8);
  byte[] hash = DigestUtils.sha(rawBody);
  byte[] encodedHash = Base64.encodeBase64(hash);
  message.addParameter(OAUTH_BODY_HASH, new String(encodedHash, UTF_8));

  // Add other parameters.

  message.addRequiredParameters(accessor);
  if (LOG.isLoggable(Level.FINE)) {
    LOG.fine("Signature base string: " + OAuthSignatureMethod.getBaseString(message));
  }

  // Construct the resulting URL.
  StringBuilder sb = new StringBuilder(rpcServerUrl);
  char connector = '?';
  for (Map.Entry<String, String> p : message.getParameters()) {
    if (!p.getKey().equals(jsonBody)) {
      sb.append(connector);
      sb.append(URLEncoder.encode(p.getKey(), UTF_8));
      sb.append('=');
      sb.append(URLEncoder.encode(p.getValue(), UTF_8));
      connector = '&';
    }
  }
  return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:55,代码来源:WaveService.java


示例10: invoke

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Send a request message to the service provider and get the response.
 * 
 * @return the response
 * @throws IOException
 *                 failed to communicate with the service provider
 * @throws OAuthProblemException
 *             the HTTP response status code was not 200 (OK)
 */
public OAuthMessage invoke(OAuthMessage request, ParameterStyle style)
        throws IOException, OAuthException {
    OAuthResponseMessage response = access(request, style);
    if ((response.getHttpResponse().getStatusCode() / 100) != 2) {
        OAuthProblemException problem = response.toOAuthProblemException();
        try {
            problem.setParameter(OAuthProblemException.SIGNATURE_BASE_STRING,
                                 OAuthSignatureMethod.getBaseString(request));
        } catch (Exception ignored) {
        }
        throw problem;
    }
    return response;
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:24,代码来源:OAuthClient.java


示例11: validateSignature

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
private void validateSignature(OAuthMessage message, OAuthAccessor accessor)
	throws net.oauth.OAuthException, IOException, URISyntaxException
{
	message.requireParameters(OAuth.OAUTH_CONSUMER_KEY, OAuth.OAUTH_SIGNATURE_METHOD, OAuth.OAUTH_SIGNATURE);
	OAuthSignatureMethod.newSigner(message, accessor).validate(message);
}
 
开发者ID:equella,项目名称:Equella,代码行数:7,代码来源:OAuthWebServiceImpl.java


示例12: validateSignature

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
protected void validateSignature(OAuthMessage message, OAuthAccessor accessor)
throws OAuthException, IOException, URISyntaxException {
    message.requireParameters(OAuth.OAUTH_CONSUMER_KEY,
            OAuth.OAUTH_SIGNATURE_METHOD, OAuth.OAUTH_SIGNATURE);
    OAuthSignatureMethod.newSigner(message, accessor).validate(message);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:SimpleOAuthValidator.java


示例13: synchronizeLTI1SiteMemberships

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
private final void synchronizeLTI1SiteMemberships(final Site site, final String membershipsId, final String membershipsUrl, final String oauth_consumer_key, boolean isEmailTrustedConsumer) {

        // Lookup the secret
        final String configPrefix = "basiclti.provider." + oauth_consumer_key + ".";
        final String oauth_secret = serverConfigurationService.getString(configPrefix+ "secret", null);
        if (oauth_secret == null) {
            log.error("launch.key.notfound {}. This site's memberships will NOT be synchronised.", oauth_consumer_key);
            return;
        }

        OAuthMessage om = new OAuthMessage("POST", membershipsUrl, null);
        om.addParameter(OAuth.OAUTH_CONSUMER_KEY, oauth_consumer_key);
        om.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
        om.addParameter(OAuth.OAUTH_VERSION, "1.0");
        om.addParameter(OAuth.OAUTH_TIMESTAMP, new Long((new Date().getTime()) / 1000).toString());
        om.addParameter(OAuth.OAUTH_NONCE, UUID.randomUUID().toString());
        om.addParameter(BasicLTIConstants.LTI_MESSAGE_TYPE, "basic-lis-readmembershipsforcontext");
        om.addParameter(BasicLTIConstants.LTI_VERSION, "LTI-1p0");
        om.addParameter("id", membershipsId);

        OAuthConsumer oc = new OAuthConsumer(null, oauth_consumer_key, oauth_secret, null);

        try {
            OAuthSignatureMethod osm = OAuthSignatureMethod.newMethod(OAuth.HMAC_SHA1, new OAuthAccessor(oc));
            osm.sign(om);

            URL url = new URL(membershipsUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setInstanceFollowRedirects(false); 
            connection.setRequestMethod("POST");
            connection.setUseCaches (false);
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
            bw.write(OAuth.formEncode(om.getParameters()));
            bw.flush();
            bw.close();

            processMembershipsResponse(connection, site, oauth_consumer_key, isEmailTrustedConsumer);
        } catch (Exception e) {
            log.warn("Problem synchronizing LTI1 memberships.", e);
        }
    }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:44,代码来源:SiteMembershipsSynchroniserImpl.java


示例14: synchronizeMoodleExtSiteMemberships

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
private final void synchronizeMoodleExtSiteMemberships(final Site site, final String membershipsId, final String membershipsUrl, final String oauth_consumer_key, boolean isEmailTrustedConsumer) {

        // Lookup the secret
        final String configPrefix = "basiclti.provider." + oauth_consumer_key + ".";
        final String oauth_secret = serverConfigurationService.getString(configPrefix+ "secret", null);
        if (oauth_secret == null) {
            log.error("launch.key.notfound {}. This site's memberships will NOT be synchronised.", oauth_consumer_key);
            return;
        }

        String type = "readMembershipsWithGroups";
        String uuid = UUID.randomUUID().toString();
        String xml = "<sourcedId>" + membershipsId + "</sourcedId>";

        StringBuilder sb = new StringBuilder("<?xml version = \"1.0\" encoding = \"UTF-8\"?>");
        sb.append("<imsx_POXEnvelope xmlns = \"http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0\">");
        sb.append("<imsx_POXHeader>");
        sb.append("<imsx_POXRequestHeaderInfo>");
        sb.append("<imsx_version>V1.0</imsx_version>");
        sb.append("<imsx_messageIdentifier>" + uuid + "</imsx_messageIdentifier>");
        sb.append("</imsx_POXRequestHeaderInfo>");
        sb.append("</imsx_POXHeader>");
        sb.append("<imsx_POXBody>");
        sb.append("<" + type + "Request>");
        sb.append(xml);
        sb.append("</" + type + "Request>");
        sb.append("</imsx_POXBody>");
        sb.append("</imsx_POXEnvelope>");

        String callXml = sb.toString();

        if(log.isDebugEnabled()) log.debug("callXml: {}", callXml);

        String bodyHash = OAuthSignatureMethod.base64Encode(LegacyShaUtil.sha1(callXml));
        log.debug(bodyHash);

        OAuthMessage om = new OAuthMessage("POST", membershipsUrl, null);
        om.addParameter("oauth_body_hash", bodyHash);
        om.addParameter("oauth_consumer_key", oauth_consumer_key);
        om.addParameter("oauth_signature_method", "HMAC-SHA1");
        om.addParameter("oauth_version", "1.0");
        om.addParameter("oauth_timestamp", new Long(new Date().getTime()).toString());

        OAuthConsumer oc = new OAuthConsumer(null, oauth_consumer_key, oauth_secret, null);

        try {
            OAuthSignatureMethod osm = OAuthSignatureMethod.newMethod("HMAC-SHA1",new OAuthAccessor(oc));
            osm.sign(om);

            String authzHeader = om.getAuthorizationHeader(null);

            if(log.isDebugEnabled()) log.debug("AUTHZ HEADER: {}", authzHeader);

            URL url = new URL(membershipsUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setInstanceFollowRedirects(false); 
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Authorization", authzHeader);
            connection.setRequestProperty("Content-Length", "" + Integer.toString(callXml.getBytes().length));
            connection.setRequestProperty("Content-Type", "text/xml");
            connection.setUseCaches (false);
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
            bw.write(callXml);
            bw.flush();
            bw.close();

            processMembershipsResponse(connection, site, oauth_consumer_key, isEmailTrustedConsumer);
        } catch (Exception e) {
            log.warn("Problem synchronizing Mooodle memberships.", e);
        }
    }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:74,代码来源:SiteMembershipsSynchroniserImpl.java


示例15: testValidateMessageFailWhenUriIsMalformed

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessageFailWhenUriIsMalformed() throws Exception {
    
    HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
    String url = "https://example.com/lti-launch";
    
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenThrow(new URISyntaxException("","",0));

    LtiVerificationResult result = BasicLTIUtil.validateMessage(requestMock, url, "secret");

    Assert.assertEquals(LtiError.BAD_REQUEST, result.getError());
    Assert.assertEquals(Boolean.FALSE, result.getSuccess());
    
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:16,代码来源:BasicLTIUtilTest.java


示例16: testValidateMessageFailOnIOException

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
@Test
public void testValidateMessageFailOnIOException() throws Exception {
    
    HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
    String url = "https://example.com/lti-launch";
    
    PowerMockito.mockStatic(OAuthSignatureMethod.class);
    PowerMockito.when(OAuthSignatureMethod.getBaseString(Matchers.any(OAuthMessage.class))).thenThrow(new IOException(""));

    LtiVerificationResult result = BasicLTIUtil.validateMessage(requestMock, url, "secret");

    Assert.assertEquals(LtiError.BAD_REQUEST, result.getError());
    Assert.assertEquals(Boolean.FALSE, result.getSuccess());
    
}
 
开发者ID:IMSGlobal,项目名称:basiclti-util-java,代码行数:16,代码来源:BasicLTIUtilTest.java


示例17: sign

import net.oauth.signature.OAuthSignatureMethod; //导入依赖的package包/类
/**
 * Add a signature to the message.
 * 
 * @throws URISyntaxException
 */
public void sign(OAuthAccessor accessor) throws IOException,
        OAuthException, URISyntaxException {
    OAuthSignatureMethod.newSigner(this, accessor).sign(this);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:OAuthMessage.java



注:本文中的net.oauth.signature.OAuthSignatureMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractFormValidator类代码示例发布时间:2022-05-22
下一篇:
Java NoPlayerException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap