List of usage examples for org.springframework.util Base64Utils decodeFromString
public static byte[] decodeFromString(String src)
From source file:io.spring.initializr.actuate.stat.MainControllerStatsIntegrationTests.java
@Test public void authorizationHeaderIsSet() { downloadArchive("/starter.zip"); assertEquals("No stat got generated", 1, statsMockController.stats.size()); StatsMockController.Content content = statsMockController.stats.get(0); String authorization = content.authorization; assertNotNull("Authorization header must be set", authorization); assertTrue("Wrong value for authorization header", authorization.startsWith("Basic ")); String token = authorization.substring("Basic ".length(), authorization.length()); String[] data = new String(Base64Utils.decodeFromString(token)).split(":"); assertEquals("Wrong user from " + token, "test-user", data[0]); assertEquals("Wrong password " + token, "test-password", data[1]); }
From source file:org.kaaproject.kaa.server.control.service.DefaultControlService.java
@Override public CredentialsDto provisionCredentials(String applicationId, String credentialsBody) throws ControlServiceException { CredentialsDto credentials = new CredentialsDto(Base64Utils.decodeFromString(credentialsBody), CredentialsStatus.AVAILABLE); try {/*w w w . j av a2s .c om*/ return this.credentialsServiceLocator.getCredentialsService(applicationId) .provideCredentials(credentials); } catch (CredentialsServiceException cause) { String message = MessageFormat.format("An unexpected exception occured while saving credentials [{0}]", credentials); LOG.error(message, cause); throw new ControlServiceException(cause); } }