org.springframework.util.Base64Utils.encodeToString()

Here are the examples of the java api org.springframework.util.Base64Utils.encodeToString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

122 Examples 7

19 View Source File : KdniaoTrackQueryAPI.java
License : Apache License 2.0
Project Creator : zhengkaixing

/**
 * base64编码
 *
 * @param str     内容
 * @param charset 编码方式
 * @throws UnsupportedEncodingException
 */
private String base64(String str, String charset) throws UnsupportedEncodingException {
    return Base64Utils.encodeToString(str.getBytes(charset));
}

19 View Source File : RSAUtils.java
License : Eclipse Public License 1.0
Project Creator : zhaoqilong3031

public static String rsaSign(String content, String privateKey, String charset) {
    try {
        PrivateKey priKey = getPrivate(SIGN_ALGORITHM, privateKey);
        java.security.Signature signature = java.security.Signature.getInstance(SIGN_ALGORITHMS);
        signature.initSign(priKey);
        if (StringUtils.isEmpty(charset)) {
            signature.update(content.getBytes());
        } else {
            signature.update(content.getBytes(charset));
        }
        return Base64Utils.encodeToString(signature.sign());
    } catch (Exception e) {
        throw new CustomException("签名失败", e);
    }
}

19 View Source File : AdminUtils.java
License : Apache License 2.0
Project Creator : tmobile

private static SecretKeySpec getSecretKey(final String baseKey) throws UnsupportedEncodingException {
    String secretKeyValue = Base64Utils.encodeToString(baseKey.substring(0, 16).getBytes()).substring(0, 16);
    return new SecretKeySpec(secretKeyValue.getBytes("UTF-8"), "AES");
}

19 View Source File : Base64Util.java
License : GNU Affero General Public License v3.0
Project Creator : stategen

public static String encode(String src) {
    src = StringUtil.toStringIfNullThenEmpty(src);
    return Base64Utils.encodeToString(src.getBytes());
}

19 View Source File : Base64Util.java
License : GNU Affero General Public License v3.0
Project Creator : stategen

public static String encodeToString(byte[] src) {
    return Base64Utils.encodeToString(src);
}

19 View Source File : ExpressService.java
License : GNU Lesser General Public License v3.0
Project Creator : qiguliuxing

/**
 * Sign签名生成
 *
 * @param content
 *            内容
 * @param keyValue
 *            Appkey
 * @param charset
 *            编码方式
 * @return DataSign签名
 */
private String encrypt(String content, String keyValue, String charset) {
    if (keyValue != null) {
        content = content + keyValue;
    }
    byte[] src = new byte[0];
    try {
        src = MD5(content, charset).getBytes(charset);
        return Base64Utils.encodeToString(src);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

19 View Source File : ImageResourceIntTest.java
License : Apache License 2.0
Project Creator : otto-de

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultImageShouldBeFound(String filter) throws Exception {
    restImageMockMvc.perform(get("/api/images?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(image.getId().intValue()))).andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))).andExpect(jsonPath("$.[*].smallContentType").value(hasItem(DEFAULT_SMALL_CONTENT_TYPE))).andExpect(jsonPath("$.[*].small").value(hasItem(Base64Utils.encodeToString(DEFAULT_SMALL)))).andExpect(jsonPath("$.[*].mediumContentType").value(hasItem(DEFAULT_MEDIUM_CONTENT_TYPE))).andExpect(jsonPath("$.[*].medium").value(hasItem(Base64Utils.encodeToString(DEFAULT_MEDIUM)))).andExpect(jsonPath("$.[*].largeContentType").value(hasItem(DEFAULT_LARGE_CONTENT_TYPE))).andExpect(jsonPath("$.[*].large").value(hasItem(Base64Utils.encodeToString(DEFAULT_LARGE))));
}

19 View Source File : SslUtil.java
License : Apache License 2.0
Project Creator : osswangxining

public static String getX509CertificateString(javax.security.cert.X509Certificate cert) throws javax.security.cert.CertificateEncodingException, IOException {
    return EncryptionUtil.trimNewLines(Base64Utils.encodeToString(cert.getEncoded()));
}

19 View Source File : IARestClient.java
License : Apache License 2.0
Project Creator : odpi

/**
 * Utility function to easily encode a username and preplacedword to send through as authorization info.
 *
 * @param username username to encode
 * @param preplacedword preplacedword to encode
 * @return String of appropriately-encoded credentials for authorization
 */
private static String encodeBasicAuth(String username, String preplacedword) {
    return Base64Utils.encodeToString((username + ":" + preplacedword).getBytes(UTF_8));
}

19 View Source File : SignatureProvider.java
License : Apache License 2.0
Project Creator : NotFound403

/**
 * Do request sign.
 *
 * @param newLine           the has suffix
 * @param privateKey        the private key
 * @param orderedComponents the orderedComponents
 * @return the string
 * @since 1.0.4.RELEASE
 */
@SneakyThrows
public String doRequestSign(boolean newLine, PrivateKey privateKey, String... orderedComponents) {
    Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER);
    signer.initSign(privateKey);
    final String signatureStr = createSign(newLine, orderedComponents);
    signer.update(signatureStr.getBytes(StandardCharsets.UTF_8));
    return Base64Utils.encodeToString(signer.sign());
}

19 View Source File : ProductVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getProductVariant() throws Exception {
    // Initialize the database
    productVariantRepository.saveAndFlush(productVariant);
    // Get the productVariant
    restProductVariantMockMvc.perform(get("/api/product-variants/{id}", productVariant.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(productVariant.getId().intValue())).andExpect(jsonPath("$.variantName").value(DEFAULT_VARIANT_NAME.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.percentage").value(DEFAULT_PERCENTAGE.doubleValue())).andExpect(jsonPath("$.fullPhotoContentType").value(DEFAULT_FULL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.fullPhoto").value(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO))).andExpect(jsonPath("$.fullPhotoUrl").value(DEFAULT_FULL_PHOTO_URL.toString())).andExpect(jsonPath("$.thumbnailPhotoContentType").value(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.thumbnailPhoto").value(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO))).andExpect(jsonPath("$.thumbnailPhotoUrl").value(DEFAULT_THUMBNAIL_PHOTO_URL.toString())).andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue()));
}

19 View Source File : ProductVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void searchProductVariant() throws Exception {
    // Initialize the database
    productVariantRepository.saveAndFlush(productVariant);
    when(mockProductVariantSearchRepository.search(queryStringQuery("id:" + productVariant.getId()), PageRequest.of(0, 20))).thenReturn(new PageImpl<>(Collections.singletonList(productVariant), PageRequest.of(0, 1), 1));
    // Search the productVariant
    restProductVariantMockMvc.perform(get("/api/_search/product-variants?query=id:" + productVariant.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
}

19 View Source File : ProductVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultProductVariantShouldBeFound(String filter) throws Exception {
    restProductVariantMockMvc.perform(get("/api/product-variants?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
    // Check, that the count call also returns 1
    restProductVariantMockMvc.perform(get("/api/product-variants/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

19 View Source File : ProductVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getAllProductVariants() throws Exception {
    // Initialize the database
    productVariantRepository.saveAndFlush(productVariant);
    // Get all the productVariantList
    restProductVariantMockMvc.perform(get("/api/product-variants?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
}

19 View Source File : ProductCategoryResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultProductCategoryShouldBeFound(String filter) throws Exception {
    restProductCategoryMockMvc.perform(get("/api/product-categories?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productCategory.getId().intValue()))).andExpect(jsonPath("$.[*].category").value(hasItem(DEFAULT_CATEGORY.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].imageFullContentType").value(hasItem(DEFAULT_IMAGE_FULL_CONTENT_TYPE))).andExpect(jsonPath("$.[*].imageFull").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE_FULL)))).andExpect(jsonPath("$.[*].imageFullUrl").value(hasItem(DEFAULT_IMAGE_FULL_URL.toString()))).andExpect(jsonPath("$.[*].imageThumbContentType").value(hasItem(DEFAULT_IMAGE_THUMB_CONTENT_TYPE))).andExpect(jsonPath("$.[*].imageThumb").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE_THUMB)))).andExpect(jsonPath("$.[*].imageThumbUrl").value(hasItem(DEFAULT_IMAGE_THUMB_URL.toString())));
    // Check, that the count call also returns 1
    restProductCategoryMockMvc.perform(get("/api/product-categories/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

19 View Source File : OrdersLineVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultOrdersLineVariantShouldBeFound(String filter) throws Exception {
    restOrdersLineVariantMockMvc.perform(get("/api/orders-line-variants?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(ordersLineVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME.toString()))).andExpect(jsonPath("$.[*].variantValue").value(hasItem(DEFAULT_VARIANT_VALUE.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
    // Check, that the count call also returns 1
    restOrdersLineVariantMockMvc.perform(get("/api/orders-line-variants/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

19 View Source File : OrdersLineExtraResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultOrdersLineExtraShouldBeFound(String filter) throws Exception {
    restOrdersLineExtraMockMvc.perform(get("/api/orders-line-extras?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(ordersLineExtra.getId().intValue()))).andExpect(jsonPath("$.[*].ordersLineExtraName").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_NAME.toString()))).andExpect(jsonPath("$.[*].ordersLineExtraValue").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_VALUE.toString()))).andExpect(jsonPath("$.[*].ordersLineExtraPrice").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_PRICE.doubleValue()))).andExpect(jsonPath("$.[*].ordersOptionDescription").value(hasItem(DEFAULT_ORDERS_OPTION_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString())));
    // Check, that the count call also returns 1
    restOrdersLineExtraMockMvc.perform(get("/api/orders-line-extras/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

19 View Source File : CompanyResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void searchCompany() throws Exception {
    // Initialize the database
    companyRepository.saveAndFlush(company);
    when(mockCompanySearchRepository.search(queryStringQuery("id:" + company.getId()), PageRequest.of(0, 20))).thenReturn(new PageImpl<>(Collections.singletonList(company), PageRequest.of(0, 1), 1));
    // Search the company
    restCompanyMockMvc.perform(get("/api/_search/companies?query=id:" + company.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(company.getId().intValue()))).andExpect(jsonPath("$.[*].companyName").value(hasItem(DEFAULT_COMPANY_NAME))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION))).andExpect(jsonPath("$.[*].note").value(hasItem(DEFAULT_NOTE))).andExpect(jsonPath("$.[*].companyLogoContentType").value(hasItem(DEFAULT_COMPANY_LOGO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].companyLogo").value(hasItem(Base64Utils.encodeToString(DEFAULT_COMPANY_LOGO)))).andExpect(jsonPath("$.[*].companyLogoUrl").value(hasItem(DEFAULT_COMPANY_LOGO_URL))).andExpect(jsonPath("$.[*].active").value(hasItem(DEFAULT_ACTIVE.booleanValue())));
}

19 View Source File : CompanyResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getAllCompanies() throws Exception {
    // Initialize the database
    companyRepository.saveAndFlush(company);
    // Get all the companyList
    restCompanyMockMvc.perform(get("/api/companies?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(company.getId().intValue()))).andExpect(jsonPath("$.[*].companyName").value(hasItem(DEFAULT_COMPANY_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].note").value(hasItem(DEFAULT_NOTE.toString()))).andExpect(jsonPath("$.[*].companyLogoContentType").value(hasItem(DEFAULT_COMPANY_LOGO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].companyLogo").value(hasItem(Base64Utils.encodeToString(DEFAULT_COMPANY_LOGO)))).andExpect(jsonPath("$.[*].companyLogoUrl").value(hasItem(DEFAULT_COMPANY_LOGO_URL.toString()))).andExpect(jsonPath("$.[*].active").value(hasItem(DEFAULT_ACTIVE.booleanValue())));
}

19 View Source File : CompanyResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getCompany() throws Exception {
    // Initialize the database
    companyRepository.saveAndFlush(company);
    // Get the company
    restCompanyMockMvc.perform(get("/api/companies/{id}", company.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(company.getId().intValue())).andExpect(jsonPath("$.companyName").value(DEFAULT_COMPANY_NAME.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.note").value(DEFAULT_NOTE.toString())).andExpect(jsonPath("$.companyLogoContentType").value(DEFAULT_COMPANY_LOGO_CONTENT_TYPE)).andExpect(jsonPath("$.companyLogo").value(Base64Utils.encodeToString(DEFAULT_COMPANY_LOGO))).andExpect(jsonPath("$.companyLogoUrl").value(DEFAULT_COMPANY_LOGO_URL.toString())).andExpect(jsonPath("$.active").value(DEFAULT_ACTIVE.booleanValue()));
}

19 View Source File : CompanyResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultCompanyShouldBeFound(String filter) throws Exception {
    restCompanyMockMvc.perform(get("/api/companies?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(company.getId().intValue()))).andExpect(jsonPath("$.[*].companyName").value(hasItem(DEFAULT_COMPANY_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].note").value(hasItem(DEFAULT_NOTE.toString()))).andExpect(jsonPath("$.[*].companyLogoContentType").value(hasItem(DEFAULT_COMPANY_LOGO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].companyLogo").value(hasItem(Base64Utils.encodeToString(DEFAULT_COMPANY_LOGO)))).andExpect(jsonPath("$.[*].companyLogoUrl").value(hasItem(DEFAULT_COMPANY_LOGO_URL.toString()))).andExpect(jsonPath("$.[*].active").value(hasItem(DEFAULT_ACTIVE.booleanValue())));
    // Check, that the count call also returns 1
    restCompanyMockMvc.perform(get("/api/companies/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

19 View Source File : RsaUtil.java
License : GNU Lesser General Public License v3.0
Project Creator : lets-mica

/**
 * 得到密钥字符串(经过base64编码)
 *
 * @param key key
 * @return base 64 编码后的 key
 */
public static String getKeyString(Key key) {
    return Base64Utils.encodeToString(key.getEncoded());
}

19 View Source File : OrderController.java
License : Apache License 2.0
Project Creator : kick7788

/**
 * Sign签名生成
 *
 * @param content 内容
 * @param keyValue Appkey
 * @param charset 编码方式
 * @return DataSign签名
 */
private String encrypt(String content, String keyValue, String charset) {
    if (keyValue != null) {
        content = content + keyValue;
    }
    byte[] src;
    try {
        src = MD5(content, charset).getBytes(charset);
        return Base64Utils.encodeToString(src);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

19 View Source File : Response.java
License : GNU General Public License v3.0
Project Creator : iSafeBlue

public String getBodyToBase64() {
    return Base64Utils.encodeToString(status.getContentBytes());
}

19 View Source File : ExpressService.java
License : MIT License
Project Creator : guqing

/**
 * Sign签名生成
 *
 * @param content  内容
 * @param keyValue Appkey
 * @param charset  编码方式
 * @return DataSign签名
 */
private String encrypt(String content, String keyValue, String charset) {
    if (keyValue != null) {
        content = content + keyValue;
    }
    byte[] src = new byte[0];
    try {
        src = MD5(content, charset).getBytes(charset);
        return Base64Utils.encodeToString(src);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

19 View Source File : WebClientAuthMiddlewareConfig.java
License : MIT License
Project Creator : daggerok

private static String basicAuthorization(final String token) {
    final byte[] basicAuthValue = token.getBytes(StandardCharsets.UTF_8);
    final String encoded = Base64Utils.encodeToString(basicAuthValue);
    return format("Basic %s", encoded);
}

19 View Source File : Base64Test.java
License : Apache License 2.0
Project Creator : chachae

public static String en() {
    return Base64Utils.encodeToString(":fefwgewg".getBytes());
}

19 View Source File : ServiceRunner.java
License : Apache License 2.0
Project Creator : apache

private static String encodePreplacedword(final String preplacedword) {
    return Base64Utils.encodeToString(preplacedword.getBytes());
}

18 View Source File : ProductResourceIntTest.java
License : Apache License 2.0
Project Creator : xebialabs

@Test
@Transactional
public void getAllProducts() throws Exception {
    // Initialize the database
    productRepository.saveAndFlush(product);
    // Get all the productList
    restProductMockMvc.perform(get("/api/products?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(product.getId().intValue()))).andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue()))).andExpect(jsonPath("$.[*].size").value(hasItem(DEFAULT_SIZE.toString()))).andExpect(jsonPath("$.[*].imageContentType").value(hasItem(DEFAULT_IMAGE_CONTENT_TYPE))).andExpect(jsonPath("$.[*].image").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE))));
}

18 View Source File : ProductResourceIntTest.java
License : Apache License 2.0
Project Creator : xebialabs

@Test
@Transactional
public void getProduct() throws Exception {
    // Initialize the database
    productRepository.saveAndFlush(product);
    // Get the product
    restProductMockMvc.perform(get("/api/products/{id}", product.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(product.getId().intValue())).andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue())).andExpect(jsonPath("$.size").value(DEFAULT_SIZE.toString())).andExpect(jsonPath("$.imageContentType").value(DEFAULT_IMAGE_CONTENT_TYPE)).andExpect(jsonPath("$.image").value(Base64Utils.encodeToString(DEFAULT_IMAGE)));
}

18 View Source File : ExpressService.java
License : GNU General Public License v3.0
Project Creator : wlhbdp

/**
 * Sign签名生成
 *
 * @param content  内容
 * @param keyValue Appkey
 * @param charset  编码方式
 * @return DataSign签名
 */
private String encrypt(String content, String keyValue, String charset) {
    if (keyValue != null) {
        content = content + keyValue;
    }
    byte[] src;
    try {
        src = MD5(content, charset).getBytes(charset);
        return Base64Utils.encodeToString(src);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

18 View Source File : BasicAuthHttpHeaderProvider.java
License : Apache License 2.0
Project Creator : SpringCloud

protected String encode(String username, String preplacedword) {
    String token = Base64Utils.encodeToString((username + ":" + preplacedword).getBytes(StandardCharsets.UTF_8));
    return "Basic " + token;
}

18 View Source File : VaultTransformTemplate.java
License : Apache License 2.0
Project Creator : spring-projects

private static void applyTransformOptions(VaultTransformContext context, Map<String, String> request) {
    if (!ObjectUtils.isEmpty(context.getTransformation())) {
        request.put("transformation", context.getTransformation());
    }
    if (!ObjectUtils.isEmpty(context.getTweak())) {
        request.put("tweak", Base64Utils.encodeToString(context.getTweak()));
    }
}

18 View Source File : HttpIT.java
License : Apache License 2.0
Project Creator : snowdrop

@Test
public void testBasicAuth() {
    startServer(SessionController.clreplaced, AuthConfiguration.clreplaced);
    getWebTestClient().get().exchange().expectStatus().isUnauthorized();
    String authHash = Base64Utils.encodeToString("user:preplacedword".getBytes(StandardCharsets.UTF_8));
    getWebTestClient().get().header(HttpHeaders.AUTHORIZATION, "Basic " + authHash).exchange().expectStatus().isOk().expectBody(String.clreplaced).value(not(emptyOrNullString()));
}

18 View Source File : ProductResourceIntTest.java
License : MIT License
Project Creator : PacktPublishing

@Test
@Transactional
public void getProduct() throws Exception {
    // Initialize the database
    productRepository.saveAndFlush(product);
    // Get the product
    restProductMockMvc.perform(get("/api/products/{id}", product.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(product.getId().intValue())).andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.imageContentType").value(DEFAULT_IMAGE_CONTENT_TYPE)).andExpect(jsonPath("$.image").value(Base64Utils.encodeToString(DEFAULT_IMAGE))).andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue())).andExpect(jsonPath("$.size").value(DEFAULT_SIZE.toString()));
}

18 View Source File : ProductResourceIntTest.java
License : MIT License
Project Creator : PacktPublishing

@Test
@Transactional
public void getAllProducts() throws Exception {
    // Initialize the database
    productRepository.saveAndFlush(product);
    // Get all the productList
    restProductMockMvc.perform(get("/api/products?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(product.getId().intValue()))).andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].imageContentType").value(hasItem(DEFAULT_IMAGE_CONTENT_TYPE))).andExpect(jsonPath("$.[*].image").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE)))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue()))).andExpect(jsonPath("$.[*].size").value(hasItem(DEFAULT_SIZE.toString())));
}

18 View Source File : ImageResourceIntTest.java
License : Apache License 2.0
Project Creator : otto-de

@Test
@Transactional
public void getAllImages() throws Exception {
    // Initialize the database
    imageRepository.saveAndFlush(image);
    // Get all the imageList
    restImageMockMvc.perform(get("/api/images?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(image.getId().intValue()))).andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))).andExpect(jsonPath("$.[*].smallContentType").value(hasItem(DEFAULT_SMALL_CONTENT_TYPE))).andExpect(jsonPath("$.[*].small").value(hasItem(Base64Utils.encodeToString(DEFAULT_SMALL)))).andExpect(jsonPath("$.[*].mediumContentType").value(hasItem(DEFAULT_MEDIUM_CONTENT_TYPE))).andExpect(jsonPath("$.[*].medium").value(hasItem(Base64Utils.encodeToString(DEFAULT_MEDIUM)))).andExpect(jsonPath("$.[*].largeContentType").value(hasItem(DEFAULT_LARGE_CONTENT_TYPE))).andExpect(jsonPath("$.[*].large").value(hasItem(Base64Utils.encodeToString(DEFAULT_LARGE))));
}

18 View Source File : ImageResourceIntTest.java
License : Apache License 2.0
Project Creator : otto-de

@Test
@Transactional
public void getImage() throws Exception {
    // Initialize the database
    imageRepository.saveAndFlush(image);
    // Get the image
    restImageMockMvc.perform(get("/api/images/{id}", image.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(image.getId().intValue())).andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())).andExpect(jsonPath("$.smallContentType").value(DEFAULT_SMALL_CONTENT_TYPE)).andExpect(jsonPath("$.small").value(Base64Utils.encodeToString(DEFAULT_SMALL))).andExpect(jsonPath("$.mediumContentType").value(DEFAULT_MEDIUM_CONTENT_TYPE)).andExpect(jsonPath("$.medium").value(Base64Utils.encodeToString(DEFAULT_MEDIUM))).andExpect(jsonPath("$.largeContentType").value(DEFAULT_LARGE_CONTENT_TYPE)).andExpect(jsonPath("$.large").value(Base64Utils.encodeToString(DEFAULT_LARGE)));
}

18 View Source File : ProductExtraResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

/**
 * Executes the search, and checks that the default enreplacedy is returned
 */
private void defaultProductExtraShouldBeFound(String filter) throws Exception {
    restProductExtraMockMvc.perform(get("/api/product-extras?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productExtra.getId().intValue()))).andExpect(jsonPath("$.[*].extraName").value(hasItem(DEFAULT_EXTRA_NAME.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].extraValue").value(hasItem(DEFAULT_EXTRA_VALUE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString())));
    // Check, that the count call also returns 1
    restProductExtraMockMvc.perform(get("/api/product-extras/count?sort=id,desc&" + filter)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(content().string("1"));
}

18 View Source File : ProductCategoryResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getAllProductCategories() throws Exception {
    // Initialize the database
    productCategoryRepository.saveAndFlush(productCategory);
    // Get all the productCategoryList
    restProductCategoryMockMvc.perform(get("/api/product-categories?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(productCategory.getId().intValue()))).andExpect(jsonPath("$.[*].category").value(hasItem(DEFAULT_CATEGORY.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].imageFullContentType").value(hasItem(DEFAULT_IMAGE_FULL_CONTENT_TYPE))).andExpect(jsonPath("$.[*].imageFull").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE_FULL)))).andExpect(jsonPath("$.[*].imageFullUrl").value(hasItem(DEFAULT_IMAGE_FULL_URL.toString()))).andExpect(jsonPath("$.[*].imageThumbContentType").value(hasItem(DEFAULT_IMAGE_THUMB_CONTENT_TYPE))).andExpect(jsonPath("$.[*].imageThumb").value(hasItem(Base64Utils.encodeToString(DEFAULT_IMAGE_THUMB)))).andExpect(jsonPath("$.[*].imageThumbUrl").value(hasItem(DEFAULT_IMAGE_THUMB_URL.toString())));
}

18 View Source File : ProductCategoryResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getProductCategory() throws Exception {
    // Initialize the database
    productCategoryRepository.saveAndFlush(productCategory);
    // Get the productCategory
    restProductCategoryMockMvc.perform(get("/api/product-categories/{id}", productCategory.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(productCategory.getId().intValue())).andExpect(jsonPath("$.category").value(DEFAULT_CATEGORY.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.imageFullContentType").value(DEFAULT_IMAGE_FULL_CONTENT_TYPE)).andExpect(jsonPath("$.imageFull").value(Base64Utils.encodeToString(DEFAULT_IMAGE_FULL))).andExpect(jsonPath("$.imageFullUrl").value(DEFAULT_IMAGE_FULL_URL.toString())).andExpect(jsonPath("$.imageThumbContentType").value(DEFAULT_IMAGE_THUMB_CONTENT_TYPE)).andExpect(jsonPath("$.imageThumb").value(Base64Utils.encodeToString(DEFAULT_IMAGE_THUMB))).andExpect(jsonPath("$.imageThumbUrl").value(DEFAULT_IMAGE_THUMB_URL.toString()));
}

18 View Source File : OrdersLineVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getOrdersLineVariant() throws Exception {
    // Initialize the database
    ordersLineVariantRepository.saveAndFlush(ordersLineVariant);
    // Get the ordersLineVariant
    restOrdersLineVariantMockMvc.perform(get("/api/orders-line-variants/{id}", ordersLineVariant.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(ordersLineVariant.getId().intValue())).andExpect(jsonPath("$.variantName").value(DEFAULT_VARIANT_NAME.toString())).andExpect(jsonPath("$.variantValue").value(DEFAULT_VARIANT_VALUE.toString())).andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())).andExpect(jsonPath("$.percentage").value(DEFAULT_PERCENTAGE.doubleValue())).andExpect(jsonPath("$.fullPhotoContentType").value(DEFAULT_FULL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.fullPhoto").value(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO))).andExpect(jsonPath("$.fullPhotoUrl").value(DEFAULT_FULL_PHOTO_URL.toString())).andExpect(jsonPath("$.thumbnailPhotoContentType").value(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.thumbnailPhoto").value(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO))).andExpect(jsonPath("$.thumbnailPhotoUrl").value(DEFAULT_THUMBNAIL_PHOTO_URL.toString())).andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue()));
}

18 View Source File : OrdersLineVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getAllOrdersLineVariants() throws Exception {
    // Initialize the database
    ordersLineVariantRepository.saveAndFlush(ordersLineVariant);
    // Get all the ordersLineVariantList
    restOrdersLineVariantMockMvc.perform(get("/api/orders-line-variants?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(ordersLineVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME.toString()))).andExpect(jsonPath("$.[*].variantValue").value(hasItem(DEFAULT_VARIANT_VALUE.toString()))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
}

18 View Source File : OrdersLineVariantResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void searchOrdersLineVariant() throws Exception {
    // Initialize the database
    ordersLineVariantRepository.saveAndFlush(ordersLineVariant);
    when(mockOrdersLineVariantSearchRepository.search(queryStringQuery("id:" + ordersLineVariant.getId()), PageRequest.of(0, 20))).thenReturn(new PageImpl<>(Collections.singletonList(ordersLineVariant), PageRequest.of(0, 1), 1));
    // Search the ordersLineVariant
    restOrdersLineVariantMockMvc.perform(get("/api/_search/orders-line-variants?query=id:" + ordersLineVariant.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(ordersLineVariant.getId().intValue()))).andExpect(jsonPath("$.[*].variantName").value(hasItem(DEFAULT_VARIANT_NAME))).andExpect(jsonPath("$.[*].variantValue").value(hasItem(DEFAULT_VARIANT_VALUE))).andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION))).andExpect(jsonPath("$.[*].percentage").value(hasItem(DEFAULT_PERCENTAGE.doubleValue()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL))).andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.intValue())));
}

18 View Source File : OrdersLineExtraResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getOrdersLineExtra() throws Exception {
    // Initialize the database
    ordersLineExtraRepository.saveAndFlush(ordersLineExtra);
    // Get the ordersLineExtra
    restOrdersLineExtraMockMvc.perform(get("/api/orders-line-extras/{id}", ordersLineExtra.getId())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.id").value(ordersLineExtra.getId().intValue())).andExpect(jsonPath("$.ordersLineExtraName").value(DEFAULT_ORDERS_LINE_EXTRA_NAME.toString())).andExpect(jsonPath("$.ordersLineExtraValue").value(DEFAULT_ORDERS_LINE_EXTRA_VALUE.toString())).andExpect(jsonPath("$.ordersLineExtraPrice").value(DEFAULT_ORDERS_LINE_EXTRA_PRICE.doubleValue())).andExpect(jsonPath("$.ordersOptionDescription").value(DEFAULT_ORDERS_OPTION_DESCRIPTION.toString())).andExpect(jsonPath("$.fullPhotoContentType").value(DEFAULT_FULL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.fullPhoto").value(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO))).andExpect(jsonPath("$.fullPhotoUrl").value(DEFAULT_FULL_PHOTO_URL.toString())).andExpect(jsonPath("$.thumbnailPhotoContentType").value(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE)).andExpect(jsonPath("$.thumbnailPhoto").value(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO))).andExpect(jsonPath("$.thumbnailPhotoUrl").value(DEFAULT_THUMBNAIL_PHOTO_URL.toString()));
}

18 View Source File : OrdersLineExtraResourceIntTest.java
License : Apache License 2.0
Project Creator : luulsolutions

@Test
@Transactional
public void getAllOrdersLineExtras() throws Exception {
    // Initialize the database
    ordersLineExtraRepository.saveAndFlush(ordersLineExtra);
    // Get all the ordersLineExtraList
    restOrdersLineExtraMockMvc.perform(get("/api/orders-line-extras?sort=id,desc")).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.[*].id").value(hasItem(ordersLineExtra.getId().intValue()))).andExpect(jsonPath("$.[*].ordersLineExtraName").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_NAME.toString()))).andExpect(jsonPath("$.[*].ordersLineExtraValue").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_VALUE.toString()))).andExpect(jsonPath("$.[*].ordersLineExtraPrice").value(hasItem(DEFAULT_ORDERS_LINE_EXTRA_PRICE.doubleValue()))).andExpect(jsonPath("$.[*].ordersOptionDescription").value(hasItem(DEFAULT_ORDERS_OPTION_DESCRIPTION.toString()))).andExpect(jsonPath("$.[*].fullPhotoContentType").value(hasItem(DEFAULT_FULL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].fullPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_FULL_PHOTO)))).andExpect(jsonPath("$.[*].fullPhotoUrl").value(hasItem(DEFAULT_FULL_PHOTO_URL.toString()))).andExpect(jsonPath("$.[*].thumbnailPhotoContentType").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_CONTENT_TYPE))).andExpect(jsonPath("$.[*].thumbnailPhoto").value(hasItem(Base64Utils.encodeToString(DEFAULT_THUMBNAIL_PHOTO)))).andExpect(jsonPath("$.[*].thumbnailPhotoUrl").value(hasItem(DEFAULT_THUMBNAIL_PHOTO_URL.toString())));
}

18 View Source File : Codes.java
License : Apache License 2.0
Project Creator : luckymorning

/**
 * Description 根据键值进行加密
 *
 * @param data
 * @param key 加密键byte数组
 * @return
 * @throws Exception
 */
@SuppressWarnings("restriction")
public static String encrypt(String data, String key) throws Exception {
    byte[] bt = encrypt(data.getBytes(), key.getBytes());
    return Base64Utils.encodeToString(bt);
}

18 View Source File : Base64SecurityAction.java
License : MIT License
Project Creator : liuhuiAndroid

@Override
public String doAction(String beProtected) {
    return Base64Utils.encodeToString(beProtected.getBytes());
}

18 View Source File : RsaUtil.java
License : GNU Lesser General Public License v3.0
Project Creator : lets-mica

/**
 * 公钥加密
 *
 * @param publicKey PublicKey
 * @param data      待加密的内容
 * @return 加密后的内容
 */
@Nullable
public static String encryptToBase64(PublicKey publicKey, @Nullable String data) {
    if (StringUtil.isBlank(data)) {
        return null;
    }
    return Base64Utils.encodeToString(encrypt(publicKey, data.getBytes(Charsets.UTF_8)));
}

18 View Source File : ExpressService.java
License : Apache License 2.0
Project Creator : kick7788

/**
 * Sign签名生成
 *
 * @param content 内容
 * @param keyValue Appkey
 * @param charset 编码方式
 * @return DataSign签名
 */
private String encrypt(String content, String keyValue, String charset) {
    if (keyValue != null) {
        content = content + keyValue;
    }
    byte[] src;
    try {
        src = MD5(content, charset).getBytes(charset);
        return Base64Utils.encodeToString(src);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

See More Examples