Examples of OAuthConsumerDTO


Examples of org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerDTO

    org.apache.axis2.context.MessageContext msgContext;
    Axis2MessageContext axis2Msgcontext = null;
    axis2Msgcontext = (Axis2MessageContext) synCtx;
    msgContext = axis2Msgcontext.getAxis2MessageContext();
    Map headersMap = null;
    OAuthConsumerDTO consumer = null;
    String authHeader = null;
    boolean isValidConsumer = false;

    if (log.isDebugEnabled()) {
      log.debug("Mediation for Entitlement started");
    }

    String prefix = (String) msgContext.getProperty(NhttpConstants.SERVICE_PREFIX);
    String postfix = (String) msgContext.getProperty(NhttpConstants.REST_URL_POSTFIX);
    try {
      configContext = cfgCtx;
      headersMap = (Map) msgContext
          .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);

      if (headersMap != null) {
        authHeader = (String) headersMap.get("Authorization");
        client = new OAuthServiceClient(getRemoteServiceUrl(), configContext);
        consumer = new OAuthConsumerDTO();
        consumer.setBaseString(prefix + postfix);
        if (synCtx.isDoingGET()) {
          consumer.setHttpMethod("GET");
        }
        if (authHeader != null) {
          String[] headers = authHeader.split(",");
          if (headers != null && headers.length > 0) {
            for (int i = 0; i < headers.length; i++) {
              String[] elements = headers[i].split("=");
              if (elements != null && elements.length > 0) {
                if ("oauth_consumer_key".equals(elements[0].trim())) {
                  consumer.setOauthConsumerKey(removeLeadingAndTrailingQuatation(elements[1]
                      .trim()));
                } else if ("oauth_nonce".equals(elements[0].trim())) {
                  consumer.setOauthNonce(removeLeadingAndTrailingQuatation(elements[1]
                      .trim()));
                } else if ("oauth_signature".equals(elements[0].trim())) {
                  consumer.setOauthSignature(removeLeadingAndTrailingQuatation(elements[1]
                      .trim()));
                } else if ("oauth_signature_method".equals(elements[0].trim())) {
                  consumer.setOauthSignatureMethod(removeLeadingAndTrailingQuatation(elements[1]
                      .trim()));
                } else if ("oauth_timestamp".equals(elements[0].trim())) {
                  consumer.setOauthTimeStamp(removeLeadingAndTrailingQuatation(elements[1]
                      .trim()));
                }
              }
            }
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.