commit
25bc147f30
@ -71,5 +71,4 @@ public class LoginController {
|
||||
|
||||
return "loginSuccess";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package org.baeldung.web.controller;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.baeldung.web.dto.Bar;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -28,4 +32,13 @@ public class BarController {
|
||||
return new Bar();
|
||||
}
|
||||
|
||||
public HttpHeaders createHeaders(String username, String password){
|
||||
return new HttpHeaders() {{
|
||||
String auth = username + ":" + password;
|
||||
byte[] encodedAuth = Base64.encodeBase64(
|
||||
auth.getBytes(Charset.forName("US-ASCII")) );
|
||||
String authHeader = "Basic " + new String( encodedAuth );
|
||||
set( "Authorization", authHeader );
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user