You can add authentication infomation like this :

protected void addHttpHeaders(HttpMethodBase method) {
        method.addRequestHeader("Accept", "application/json, text/plain,
*/*");
        method.addRequestHeader("Content-Type", "application/json");

        String basicAuth =
DatatypeConverter.printBase64Binary((this.username + ":" +
this.password).getBytes());
        method.addRequestHeader("Authorization", "Basic " + basicAuth);
}

In curl command, you can execute command like this : curl -H
"Authorization:Basic auth-information-content"  -H "Content-Type:
application/json" "http://localhost:7070/kylin/api/xxx";, and
auth-information-content
is value of username + ":" + password encoding with base64. for example
"ADMIN:KYLIN" will encode to "QURNSU46S1lMSU4="

2016-01-08 17:37 GMT+08:00 王琳 <wang...@britecloudtech.com>:

> hi
>      I have a restful interface problems need to consult about:
>
>      Java call restful interface for user authentication how to control
> this piece?
>
>
> Thanks

Reply via email to