Created
December 13, 2018 15:19
-
-
Save eldermoraes/07450835f628142e99bb427139c584a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Stateless | |
public class AuthImpl implements Auth { | |
private String URL = "http://localhost:8080/javaEE8ExampleSSOAppService/resources/auth"; | |
@Override | |
public boolean isLogged(String token) { | |
return prepareWebTarget().path("/" + token) | |
.request() | |
.head().getStatus() == 200; | |
} | |
@Override | |
public String login(String login, String password) { | |
return prepareWebTarget() | |
.request() | |
.post(Entity.form(new Form("login", login) | |
.param("password", password)), | |
String.class); | |
} | |
@Override | |
public String logout(String token) { | |
return prepareWebTarget().path("/" + token) | |
.request() | |
.delete(String.class); | |
} | |
protected WebTarget prepareWebTarget() { | |
return ClientBuilder.newClient().target(URL); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment