Java Code Examples for org.springframework.util.Base64Utils#decodeFromUrlSafeString()
The following examples show how to use
org.springframework.util.Base64Utils#decodeFromUrlSafeString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MDSUrlService.java From fido2 with GNU Lesser General Public License v2.1 | 5 votes |
private MetadataStatement retrieveMetadataStatement(URI uri, String entryHash, MessageDigest digest, boolean forceUpdate) throws Exception { String filename = filenameFromURI(uri); String data = null; if (!forceUpdate) { data = storage.loadData(namespace, filename); } if (data == null) { String url = URLDecoder.decode(uri.toString(), StandardCharsets.UTF_8.name()); url = addToken(url); url = url.replaceAll("#", "%23"); URI realURI = URI.create(url); ResponseEntity<String> responseEntity = restTemplate.getForEntity(realURI, String.class); data = responseEntity.getBody(); if(data == null){ logger.severe("Null hash."); throw new Exception("Null hash"); } String hash = Base64.getUrlEncoder().withoutPadding().encodeToString(digest.digest(data.getBytes())); if (!hash.equals(entryHash)) { logger.log(Level.SEVERE, "Bad hash. {0} != {1} Skipping ", new Object[]{hash, entryHash}); throw new Exception("Bad hash"); } storage.saveData(namespace, filename, data); } String decoded; try { decoded = new String(Base64Utils.decodeFromUrlSafeString(data), StandardCharsets.UTF_8); } catch (Exception e) { // TODO: known bug: test server does not base64 this info decoded = data; } return objectMapper.readValue(decoded, MetadataStatement.class); }
Example 2
Source File: StringToChallengeConverter.java From webauthn4j-spring-security with Apache License 2.0 | 4 votes |
@Override protected Challenge convert(String source) { byte[] challenge = Base64Utils.decodeFromUrlSafeString(source); return new DefaultChallenge(challenge); }
Example 3
Source File: StringToChallengeConverter.java From webauthn4j-spring-security with Apache License 2.0 | 4 votes |
@Override protected Challenge convert(String source) { byte[] challenge = Base64Utils.decodeFromUrlSafeString(source); return new DefaultChallenge(challenge); }