Convert AuthorizeRequest to name value pairs
438316
private function _convertAuthorize($request) {
        
        $parameters = array();
        $parameters['Action'] = 'Authorize';
        if ($request->isSetSellerId()) {
            $parameters['SellerId'] =  $request->getSellerId();
        }
        if ($request->isSetAmazonOrderReferenceId()) {
            $parameters['AmazonOrderReferenceId'] =  $request->getAmazonOrderReferenceId();
        }
        if ($request->isSetAuthorizationReferenceId()) {
            $parameters['AuthorizationReferenceId'] =  $request->getAuthorizationReferenceId();
        }
        if ($request->isSetAuthorizationAmount()) {
            $authorizationAmount = $request->getAuthorizationAmount();
            if ($authorizationAmount->isSetAmount()) {
                $parameters['AuthorizationAmount' . '.' . 'Amount'] =  $authorizationAmount->getAmount();
            }
            if ($authorizationAmount->isSetCurrencyCode()) {
                $parameters['AuthorizationAmount' . '.' . 'CurrencyCode'] =  $authorizationAmount->getCurrencyCode();
            }
        }
        if ($request->isSetSellerAuthorizationNote()) {
            $parameters['SellerAuthorizationNote'] =  $request->getSellerAuthorizationNote();
        }
        if ($request->isSetOrderItemCategories()) {
            $orderItemCategories = $request->getOrderItemCategories();
            foreach  ($orderItemCategories->getOrderItemCategory() as $orderItemCategoryIndex => $orderItemCategory) {
                $parameters['OrderItemCategories' . '.' . 'OrderItemCategory' . '.'  . ($orderItemCategoryIndex + 1)] =  $orderItemCategory;
            }
        }
        if ($request->isSetTransactionTimeout()) {
            $parameters['TransactionTimeout'] =  $request->getTransactionTimeout();
        }
        if ($request->isSetCaptureNow()) {
            $parameters['CaptureNow'] =  $request->getCaptureNow() ? "true" : "false";
        }
        if ($request->isSetSoftDescriptor()) {
            $parameters['SoftDescriptor'] =  $request->getSoftDescriptor();
        }

        return $parameters;
    }
189127
def username_from_request(request):
    
    if config.USERNAME_FORM_FIELD in request.POST:
        return request.POST[config.USERNAME_FORM_FIELD][:255]
    return None
958484
private void authorizeRequest(Context context, HttpRequestBase httpRequest) throws FMSException {
        context.getAuthorizer().authorize(httpRequest);
    }
191189
protected Map<String, String> parseHeaderParameters(HttpServletRequest request) {
    String header = null;
    Enumeration<String> headers = request.getHeaders("Authorization");
    while (headers.hasMoreElements()) {
      String value = headers.nextElement();
      if ((value.toLowerCase().startsWith("oauth "))) {
        header = value;
        break;
      }
    }

    Map<String, String> parameters = null;
    if (header != null) {
      parameters = new HashMap<String, String>();
      String authHeaderValue = header.substring(6);

      //create a map of the authorization header values per OAuth Core 1.0, section 5.4.1
      String[] headerEntries = StringSplitUtils.splitIgnoringQuotes(authHeaderValue, ',');
      for (Object o : StringSplitUtils.splitEachArrayElementAndCreateMap(headerEntries, "=", "\"").entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        try {
          String key = oauthDecode((String) entry.getKey());
          String value = oauthDecode((String) entry.getValue());
          parameters.put(key, value);
        }
        catch (DecoderException e) {
          throw new IllegalStateException(e);
        }
      }
    }

    return parameters;
  }
352266
function signatureBaseString(requestMethod, uri, body, protocolParams) {
    return [
        encode(requestMethod.toUpperCase()),
        encode(baseStringUri(uri)),
        encode(normalizedRequestParameters(uri, body, protocolParams))
    ].join('&');
}
920433
protected String getUsernameParameterFromRequest(final HttpServletRequest request) {
        return request.getParameter(StringUtils.defaultString(configurationContext.getUsernameParameter(), "username"));
    }
631773
def _GetActualName(name):
   
   if _allowCapitalizedNames:
      name = UncapitalizeVmodlName(name)
   for defMap in _dataDefMap, _managedDefMap, _enumDefMap:
      dic = defMap.get(name)
      if dic:
         return dic[0]
   return None
489628
def get_username(self):
        """"""
        _from = self.auth_context['from']
        if self.token_version == 1:
            return '{0}'.format(_from)
        elif self.token_version == 2:
            _user_type = self.auth_context['user_type']
            return '{0}/{1}/{2}'.format(
                self.token_version,
                _user_type,
                _from
            )
1105271
public static Optional<String> getParameterNameFromAnnotations(Annotation[] memberAnnotations) {
        for (Annotation a : memberAnnotations) {
            if (a instanceof QueryParam) {
                return Optional.of("query param " + ((QueryParam) a).value());
            } else if (a instanceof PathParam) {
                return Optional.of("path param " + ((PathParam) a).value());
            } else if (a instanceof HeaderParam) {
                return Optional.of("header " + ((HeaderParam) a).value());
            } else if (a instanceof CookieParam) {
                return Optional.of("cookie " + ((CookieParam) a).value());
            } else if (a instanceof FormParam) {
                return Optional.of("form field " + ((FormParam) a).value());
            } else if (a instanceof Context) {
                return Optional.of("context");
            } else if (a instanceof MatrixParam) {
                return Optional.of("matrix param " + ((MatrixParam) a).value());
            }
        }

        return Optional.empty();
    }
1071776
private static AuthorizationStatus convert(AuthorizationResultStatus status) {
        AuthorizationStatus result;

        switch (status) {
            case ACCEPTED:
                result = AuthorizationStatus.ACCEPTED;
                break;
            case BLOCKED:
                result = AuthorizationStatus.BLOCKED;
                break;
            case EXPIRED:
                result = AuthorizationStatus.EXPIRED;
                break;
            case INVALID:
                result = AuthorizationStatus.INVALID;
                break;
            default:
                throw new AssertionError("AuthorizationResultStatus has unknown status: " + status);
        }

        return result;
    }
531535
def from_name(cls, name):
        """"""
        result = cls.list({'items_per_page': 500})
        webaccs = {}
        for webacc in result:
            webaccs[webacc['name']] = webacc['id']
        return webaccs.get(name)
76371
private function _convertAuthorizeOnBillingAgreement($request) {
    
    	$parameters = array();
    	$parameters['Action'] = 'AuthorizeOnBillingAgreement';
    	if ($request->isSetSellerId()) {
    		$parameters['SellerId'] =  $request->getSellerId();
    	}
    	if ($request->isSetAmazonBillingAgreementId()) {
    		$parameters['AmazonBillingAgreementId'] =  $request->getAmazonBillingAgreementId();
    	}
    	if ($request->isSetAuthorizationReferenceId()) {
    		$parameters['AuthorizationReferenceId'] =  $request->getAuthorizationReferenceId();
    	}
    	if ($request->isSetAuthorizationAmount()) {
    		$authorizationAmountauthorizeOnBillingAgreementRequest = $request->getAuthorizationAmount();
    		if ($authorizationAmountauthorizeOnBillingAgreementRequest->isSetAmount()) {
    			$parameters['AuthorizationAmount' . '.' . 'Amount'] =  $authorizationAmountauthorizeOnBillingAgreementRequest->getAmount();
    		}
    		if ($authorizationAmountauthorizeOnBillingAgreementRequest->isSetCurrencyCode()) {
    			$parameters['AuthorizationAmount' . '.' . 'CurrencyCode'] =  $authorizationAmountauthorizeOnBillingAgreementRequest->getCurrencyCode();
    		}
    	}
    	if ($request->isSetSellerAuthorizationNote()) {
    		$parameters['SellerAuthorizationNote'] =  $request->getSellerAuthorizationNote();
    	}
    	if ($request->isSetTransactionTimeout()) {
    		$parameters['TransactionTimeout'] =  $request->getTransactionTimeout();
    	}
    	if ($request->isSetCaptureNow()) {
    		$parameters['CaptureNow'] =  $request->getCaptureNow() ? "true" : "false";
    	}
    	if ($request->isSetSoftDescriptor()) {
    		$parameters['SoftDescriptor'] =  $request->getSoftDescriptor();
    	}
    	if ($request->isSetSellerNote()) {
    		$parameters['SellerNote'] =  $request->getSellerNote();
    	}
    	if ($request->isSetPlatformId()) {
    		$parameters['PlatformId'] =  $request->getPlatformId();
    	}
    	if ($request->isSetSellerOrderAttributes()) {
    		$sellerOrderAttributesauthorizeOnBillingAgreementRequest = $request->getSellerOrderAttributes();
    		if ($sellerOrderAttributesauthorizeOnBillingAgreementRequest->isSetSellerOrderId()) {
    			$parameters['SellerOrderAttributes' . '.' . 'SellerOrderId'] =  $sellerOrderAttributesauthorizeOnBillingAgreementRequest->getSellerOrderId();
    		}
    		if ($sellerOrderAttributesauthorizeOnBillingAgreementRequest->isSetStoreName()) {
    			$parameters['SellerOrderAttributes' . '.' . 'StoreName'] =  $sellerOrderAttributesauthorizeOnBillingAgreementRequest->getStoreName();
    		}
    		if ($sellerOrderAttributesauthorizeOnBillingAgreementRequest->isSetOrderItemCategories()) {
    			$orderItemCategoriessellerOrderAttributes = $sellerOrderAttributesauthorizeOnBillingAgreementRequest->getOrderItemCategories();
    			foreach  ($orderItemCategoriessellerOrderAttributes->getOrderItemCategory() as $orderItemCategoryorderItemCategoriesIndex => $orderItemCategoryorderItemCategories) {
    				$parameters['SellerOrderAttributes' . '.' . 'OrderItemCategories' . '.' . 'OrderItemCategory' . '.'  . ($orderItemCategoryorderItemCategoriesIndex + 1)] =  $orderItemCategoryorderItemCategories;
    			}
    		}
    		if ($sellerOrderAttributesauthorizeOnBillingAgreementRequest->isSetCustomInformation()) {
    			$parameters['SellerOrderAttributes' . '.' . 'CustomInformation'] =  $sellerOrderAttributesauthorizeOnBillingAgreementRequest->getCustomInformation();
    		}
    	}
    	if ($request->isSetInheritShippingAddress()) {
    		$parameters['InheritShippingAddress'] =  $request->getInheritShippingAddress() ? "true" : "false";
    	}
    
    	return $parameters;
    }
811798
protected String getBasicAuthRealmName(WebRequest webRequest) {
        SecurityMetadata securityMetadata = webRequest.getSecurityMetadata();
        if (securityMetadata != null) {
            LoginConfiguration loginConfig = securityMetadata.getLoginConfiguration();
            if (loginConfig != null && loginConfig.getRealmName() != null) {
                return loginConfig.getRealmName();
            }
            if (config.getDisplayAuthenticationRealm()) {
                return userRegistry.getRealm();
            }
        }
        String realm = "defaultRealm";
        return realm;
    }
1315123
protected function serializeAuthorizationParameters()
    {
        return sprintf(
            'id=%s&nonce=%s&realm=%s&version=%s',
            $this->id,
            $this->nonce,
            rawurlencode($this->realm),
            $this->version
        );
    }
741204
def request_name(self, name, allow_replacement=True, replace=False):
		
		return NameOwner(self, name, allow_replacement, replace)
898196
protected NameID encodeNameIdBasedOnNameFormat(final RequestAbstractType authnRequest,
                                                   final Object assertion,
                                                   final String nameFormat,
                                                   final SamlRegisteredService service,
                                                   final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
        try {
            if (authnRequest instanceof AttributeQuery) {
                val query = AttributeQuery.class.cast(authnRequest);
                val nameID = query.getSubject().getNameID();
                nameID.detach();
                LOGGER.debug("Choosing NameID format [{}] with value [{}] for attribute query", nameID.getFormat(), nameID.getValue());
                return nameID;
            }

            val attribute = prepareNameIdAttribute(assertion, nameFormat, adaptor);
            val encoder = prepareNameIdEncoder(authnRequest, nameFormat, attribute, service, adaptor);
            LOGGER.debug("Encoding NameID based on [{}]", nameFormat);
            var nameId = encoder.encode(attribute);
            LOGGER.debug("Final NameID encoded with format [{}] has value [{}]", nameId.getFormat(), nameId.getValue());
            return nameId;
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        return null;
    }
374827
static public String[] getUserNameAndPassword(String auth) throws Exception {

		auth = auth.trim();
		String[] components = auth.split("\\s+");
		if( components.length > 0 ) {
			if( "basic".equalsIgnoreCase(components[0].trim()) ) {
				// Basic authentication was used, second word is uuencoded
				if( components.length > 1 ) {
					String encoded = components[1];

					byte[] decoded = Base64.decodeBase64( encoded.getBytes() );
					StringWriter sw = new StringWriter();
					for(int loop=0; loop<decoded.length; ++loop) {
						sw.write((int)decoded[loop]);
					}

					String userAndPass = sw.toString();
					String[] tokens = userAndPass.trim().split(":");
					
					if( tokens.length < 2 ) {
						throw new Exception("Unable to decode name from basic authorization");
					}
					
					return tokens;
				} else {
					throw new Exception("Invalid authorization using Basic encoding");
				}
			}
		}
		
		throw new Exception("Unknown authorization type: "+auth);
	}