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
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
version="3.0"> | |
<security-constraint> | |
<web-resource-collection> | |
<web-resource-name>HtmlAuth</web-resource-name> | |
<description>application security constraints</description> | |
<url-pattern>/*</url-pattern> |
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
MacBook-Markus:~ Markus$ wildfly-10.0.0.Final/bin/add-user.sh | |
What type of user do you wish to add? | |
a) Management User (mgmt-users.properties) | |
b) Application User (application-users.properties) | |
(a): b | |
Enter the details of the new user to add. | |
Using realm 'ApplicationRealm' as discovered from the existing property files. | |
Username : markus |
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
@Path("/auth") | |
@RequestScoped | |
@Produces(MediaType.APPLICATION_JSON) | |
public class AuthResource { | |
@GET | |
@Path("/login") | |
public Response login() { | |
// Do the login stuff and generate the token |
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
@Path("/users") | |
public class UserResource { | |
... | |
@GET | |
@Path("/username-unique") | |
public Response isEmailUnique( | |
@QueryParam("name") | |
@NotNull | |
@Size(min=3, max=10, message="Der Name muss zwischen {min} und {max} Zeichen lang sein") | |
String username) { |
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
Markus$ curl -i http://localhost:8080/jee-jaxrs-validation/resources/users/username-unique | |
HTTP/1.1 400 Bad Request | |
[PARAMETER] | |
[isEmailUnique.arg0] | |
[darf nicht null sein] | |
[] |
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
Markus$ curl -i http://localhost:8080/jee-jaxrs-validation/resources/users/username-unique?name=d | |
HTTP/1.1 400 Bad Request | |
[PARAMETER] | |
[isEmailUnique.arg0] | |
[Der Name muss zwischen 3 und 10 Zeichen lang sein] | |
[d] |
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
public class User { | |
@NotNull(message="Der Name muss angegeben werden") | |
@Size(min=3, max=10, message="Der Name muss zwischen {min} und {max} Zeichen lang sein") | |
private String name; | |
@NotNull(message="Die E-Mail Adresse ist ein Pflichtfeld") | |
private String email; | |
} |
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
@Path("/users") | |
public class UserResource { | |
@POST | |
@Path("/") | |
public User createUser(@Valid User user) { | |
user.setId(1l); | |
return user; | |
} | |
} |
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
curl -i -XPOST -H "Content-Type: application/json" -d "{\"name\": null,\"email\": null}" http://localhost:8080/jee-jaxrs-validation/resources/users | |
HTTP/1.1 400 Bad Request | |
{ | |
"exception": null, | |
"fieldViolations": [], | |
"propertyViolations": [], | |
"classViolations": [], | |
"parameterViolations": [ | |
{ |
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
curl -i -XPOST -H "Content-Type: application/json" -d "{\"name\": \"d\",\"email\": \"[email protected]\"}" http://localhost:8080/jee-jaxrs-validation/resources/users | |
HTTP/1.1 400 Bad Request | |
{ | |
"exception": null, | |
"fieldViolations": [], | |
"propertyViolations": [], | |
"classViolations": [], | |
"parameterViolations": [ | |
{ |
OlderNewer