当前位置: 首页>>代码示例>>Java>>正文


Java Base64Utils类代码示例

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


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

示例1: getComments

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@HystrixCommand(fallbackMethod = "defaultComments")
public List<Comment> getComments(Image image, String sessionId) {

	ResponseEntity<List<Comment>> results = restTemplate.exchange(
		"http://COMMENTS/comments/{imageId}",
		HttpMethod.GET,
		new HttpEntity<>(new HttpHeaders() {{
			String credentials = imagesConfiguration.getCommentsUser() + ":" +
				imagesConfiguration.getCommentsPassword();
			String token = new String(Base64Utils.encode(credentials.getBytes()));
			set(AUTHORIZATION, "Basic " + token);
			set("Cookie", "SESSION=" + sessionId);
		}}),
		new ParameterizedTypeReference<List<Comment>>() {},
		image.getId());
	return results.getBody();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:18,代码来源:CommentHelper.java

示例2: setSigningKey

import org.springframework.util.Base64Utils; //导入依赖的package包/类
public void setSigningKey(String key) throws Exception {
	this.signingKey = key;
	key = key.trim();

	key = key.replace("-----BEGIN RSA PRIVATE KEY-----\n", "")
			.replace("-----END RSA PRIVATE KEY-----", "").trim().replace("\n", "");
	byte[] encoded = Base64Utils.decodeFromString(key);
	DerInputStream derInputStream = new DerInputStream(encoded);
	DerValue[] seq = derInputStream.getSequence(0);

	BigInteger modulus = seq[1].getBigInteger();
	BigInteger publicExp = seq[2].getBigInteger();
	BigInteger privateExp = seq[3].getBigInteger();
	BigInteger prime1 = seq[4].getBigInteger();
	BigInteger prime2 = seq[5].getBigInteger();
	BigInteger exp1 = seq[6].getBigInteger();
	BigInteger exp2 = seq[7].getBigInteger();
	BigInteger crtCoef = seq[8].getBigInteger();

	RSAPrivateCrtKeySpec keySpec = new RSAPrivateCrtKeySpec(modulus, publicExp,
			privateExp, prime1, prime2, exp1, exp2, crtCoef);
	KeyFactory kf = KeyFactory.getInstance("RSA");
	this.signer = new RSASSASigner(kf.generatePrivate(keySpec));
}
 
开发者ID:making,项目名称:spring-boot-actuator-dashboard,代码行数:25,代码来源:JwtTokenConverter.java

示例3: getComments

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@HystrixCommand(fallbackMethod = "defaultComments")
public List<Comment> getComments(Image image, String sessionId) {

	ResponseEntity<List<Comment>> results = restTemplate.exchange(
		"http://COMMENTS/comments/{imageId}",
		HttpMethod.GET,
		new HttpEntity<>(new HttpHeaders() {{
			String credentials = imagesConfiguration.getCommentsUser() + ":" +
				imagesConfiguration.getCommentsPassword();
			String token = new String(Base64Utils.encode(credentials.getBytes()));
			set(AUTHORIZATION, "Basic " + token);
			set("SESSION", sessionId);
		}}),
		new ParameterizedTypeReference<List<Comment>>() {},
		image.getId());
	return results.getBody();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:18,代码来源:CommentHelper.java

示例4: getAllUserProfiles

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Test
@Transactional
public void getAllUserProfiles() throws Exception {
    // Initialize the database
    userProfileRepository.saveAndFlush(userProfile);

    // Get all the userProfiles
    restUserProfileMockMvc.perform(get("/api/userProfiles"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andExpect(jsonPath("$.[*].id").value(hasItem(userProfile.getId().intValue())))
            .andExpect(jsonPath("$.[*].phones").value(hasItem(DEFAULT_PHONES.toString())))
            .andExpect(jsonPath("$.[*].address").value(hasItem(DEFAULT_ADDRESS.toString())))
            .andExpect(jsonPath("$.[*].pictureContentType").value(hasItem(DEFAULT_PICTURE_CONTENT_TYPE)))
            .andExpect(jsonPath("$.[*].picture").value(hasItem(Base64Utils.encodeToString(DEFAULT_PICTURE))));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:17,代码来源:UserProfileResourceTest.java

示例5: getUserProfile

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Test
@Transactional
public void getUserProfile() throws Exception {
    // Initialize the database
    userProfileRepository.saveAndFlush(userProfile);

    // Get the userProfile
    restUserProfileMockMvc.perform(get("/api/userProfiles/{id}", userProfile.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(userProfile.getId().intValue()))
        .andExpect(jsonPath("$.phones").value(DEFAULT_PHONES.toString()))
        .andExpect(jsonPath("$.address").value(DEFAULT_ADDRESS.toString()))
        .andExpect(jsonPath("$.pictureContentType").value(DEFAULT_PICTURE_CONTENT_TYPE))
        .andExpect(jsonPath("$.picture").value(Base64Utils.encodeToString(DEFAULT_PICTURE)));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:17,代码来源:UserProfileResourceTest.java

示例6: getAllImageResources

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Test
@Transactional
public void getAllImageResources() throws Exception {
    // Initialize the database
    imageResourceRepository.saveAndFlush(imageResource);

    // Get all the imageResources
    restImageResourceMockMvc.perform(get("/api/imageResources"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON))
            .andExpect(jsonPath("$.[*].id").value(hasItem(imageResource.getId().intValue())))
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString())))
            .andExpect(jsonPath("$.[*].loResImageContentType").value(hasItem(DEFAULT_LO_RES_IMAGE_CONTENT_TYPE)))
            .andExpect(jsonPath("$.[*].loResImage").value(hasItem(Base64Utils.encodeToString(DEFAULT_LO_RES_IMAGE))))
            .andExpect(jsonPath("$.[*].hiResImageContentType").value(hasItem(DEFAULT_HI_RES_IMAGE_CONTENT_TYPE)))
            .andExpect(jsonPath("$.[*].hiResImage").value(hasItem(Base64Utils.encodeToString(DEFAULT_HI_RES_IMAGE))));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:18,代码来源:ImageResourceResourceTest.java

示例7: getImageResource

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Test
@Transactional
public void getImageResource() throws Exception {
    // Initialize the database
    imageResourceRepository.saveAndFlush(imageResource);

    // Get the imageResource
    restImageResourceMockMvc.perform(get("/api/imageResources/{id}", imageResource.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(imageResource.getId().intValue()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
        .andExpect(jsonPath("$.loResImageContentType").value(DEFAULT_LO_RES_IMAGE_CONTENT_TYPE))
        .andExpect(jsonPath("$.loResImage").value(Base64Utils.encodeToString(DEFAULT_LO_RES_IMAGE)))
        .andExpect(jsonPath("$.hiResImageContentType").value(DEFAULT_HI_RES_IMAGE_CONTENT_TYPE))
        .andExpect(jsonPath("$.hiResImage").value(Base64Utils.encodeToString(DEFAULT_HI_RES_IMAGE)));
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:18,代码来源:ImageResourceResourceTest.java

示例8: exceptionHandler

import org.springframework.util.Base64Utils; //导入依赖的package包/类
public void exceptionHandler(HttpServletRequest request, HttpServletResponse response,
                              Object handler, Exception e) throws Throwable {

    logger.debug("exceptionHandler->" + e + ",handler->" + handler);

    logger.debug("getAttribute -> " + request.getAttribute(Constants.defaultResponseHeader));
    if (Constants.defaultResponseHeader.equals(request.getAttribute(Constants.defaultResponseHeader))) {
        response.setHeader(Constants.defaultResponseHeader, Constants.defaultResponseHeader);
    } else {
        logger.debug(e.getMessage());
        String localizedMessage = e.getLocalizedMessage();
        String msg = e.getMessage();
        String className = e.getClass().getName();
        ExcepModel excepModel = new ExcepModel(localizedMessage, msg, className);
        response.setHeader(Constants.exceptionHeader, Base64Utils.encodeToString(excepModel.toJsonString().getBytes()));
    }

}
 
开发者ID:codingapi,项目名称:filter,代码行数:19,代码来源:DefFilterExceptionHandler.java

示例9: getAllProducts

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@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())))
        .andExpect(jsonPath("$.[*].availableUntil").value(hasItem(DEFAULT_AVAILABLE_UNTIL.toString())));
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:20,代码来源:ProductResourceIntTest.java

示例10: getProduct

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@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()))
        .andExpect(jsonPath("$.availableUntil").value(DEFAULT_AVAILABLE_UNTIL.toString()));
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:20,代码来源:ProductResourceIntTest.java

示例11: searchProduct

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Test
@Transactional
public void searchProduct() throws Exception {
    // Initialize the database
    productService.save(product);

    // Search the product
    restProductMockMvc.perform(get("/api/_search/products?query=id:" + product.getId()))
        .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())))
        .andExpect(jsonPath("$.[*].availableUntil").value(hasItem(DEFAULT_AVAILABLE_UNTIL.toString())));
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:20,代码来源:ProductResourceIntTest.java

示例12: executeSignUp

import org.springframework.util.Base64Utils; //导入依赖的package包/类
@Override
@Transactional
public JsonResult executeSignUp(String account, String email, String cipher) throws Exception {
    account = new String(Base64Utils.decodeFromString(account), AppConstants.CHARSET_UTF8);
    email = new String(Base64Utils.decodeFromString(email), AppConstants.CHARSET_UTF8);
    cipher = new String(Base64Utils.decodeFromString(cipher), AppConstants.CHARSET_UTF8);

    SystemUserModel userModel = systemUserRepository.findByAccount(account);
    if (userModel != null && userModel.getId() != null) {
        return new JsonResult(400, "此用户账号已被注册!");
    }
    userModel = systemUserRepository.findByEmail(email);
    if (userModel != null && userModel.getId() != null) {
        return new JsonResult(400, "此邮箱地址已被注册!");
    }

    userModel = new SystemUserModel(IdWorker.INSTANCE.nextId(), account, cipher, email);
    systemUserRepository.save(userModel);
    return new JsonResult();
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:21,代码来源:UserServiceImpl.java

示例13: getKeys

import org.springframework.util.Base64Utils; //导入依赖的package包/类
public static HashMap<String, String> getKeys() {
	try {
		HashMap<String, String> map = new HashMap<>();
		KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(SIGN_ALGORITHM);
		keyPairGen.initialize(1024);
		KeyPair keyPair = keyPairGen.generateKeyPair();
		RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
		RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
		map.put(PUBLIC_KEY, new String(Base64Utils.encode(publicKey.getEncoded())));
		map.put(PRIVATE_KEY, new String(Base64Utils.encode(privateKey.getEncoded())));
		return map;
	} catch (Exception e) {
		e.printStackTrace();
		throw new CustomException("生成秘钥对失败");
	}
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:17,代码来源:RSAUtils.java

示例14: findGroupMessageList

import org.springframework.util.Base64Utils; //导入依赖的package包/类
private List<MessageEntity> findGroupMessageList(List<? extends IMGroupMessageEntity> messageList) {
    List<MessageEntity> resultList = new ArrayList<>();
    for (IMGroupMessageEntity message : messageList) {
        MessageEntity messageEntity = new MessageEntity();
        messageEntity.setId(message.getId());
        messageEntity.setMsgId(message.getMsgId());
        if (message.getType() == IMBaseDefine.MsgType.MSG_TYPE_GROUP_AUDIO_VALUE) {
            // 语音Base64
            byte[] audioData = audioInternalService.readAudioInfo(Long.valueOf(message.getContent()));
            messageEntity.setContent(Base64Utils.encodeToString(audioData));
        } else {
            messageEntity.setContent(message.getContent());
        }
        messageEntity.setFromId(message.getUserId());
        messageEntity.setCreated(message.getCreated());
        messageEntity.setStatus(message.getStatus());
        messageEntity.setMsgType(message.getType());

        resultList.add(messageEntity);
    }
    return resultList;
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:23,代码来源:MessageServiceController.java

示例15: findMessageList

import org.springframework.util.Base64Utils; //导入依赖的package包/类
private List<MessageEntity> findMessageList(List<? extends IMMessageEntity> messageList) {
    List<MessageEntity> resultList = new ArrayList<>();
    for (IMMessageEntity message : messageList) {
        MessageEntity messageEntity = new MessageEntity();
        messageEntity.setId(message.getId());
        messageEntity.setMsgId(message.getMsgId());
        if (message.getType() == IMBaseDefine.MsgType.MSG_TYPE_SINGLE_AUDIO_VALUE) {
            // 语音Base64
            byte[] audioData = audioInternalService.readAudioInfo(Long.valueOf(message.getContent()));
            messageEntity.setContent(Base64Utils.encodeToString(audioData));
        } else {
            messageEntity.setContent(message.getContent());
        }
        messageEntity.setFromId(message.getUserId());
        messageEntity.setCreated(message.getCreated());
        messageEntity.setStatus(message.getStatus());
        messageEntity.setMsgType(message.getType());
        resultList.add(messageEntity);
    }
    return resultList;
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:22,代码来源:MessageServiceController.java


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