简体   繁体   中英

Parse an ResponseStatus into Response

I need to return something into Response class format but I have an SAMLResult variable so when I get the Status ( ResponseStatus ) I don't find any way to parse it to a Response variable.

Has someone any idea how to do this ?

If i understand your problem correctly, you are only interested in the numeric SAMLResponse status and need to return this as a new value of type Response .

So you can simply build a new Response with the SAMLResponse status value:

int samlStatus = SAMLResponse.ResponseStatus;
Response response = Response.status(samlStatus).build();
return response;

Or you can intantiate a new Response object (by implementing all methods from the abstract Response class eg with default values) and set the SAMLResponse.ResponseStatus value in the getStatus() method. For example:

Response response = new Response() {
    @Override
    public int getStatus() {
        int samlStatus = SAMLResult.ResponseStatus;
        return samlStatus;
    }
    // override all other Response methods ...
}
return response;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM