.
6 | */
7 | package org.demoiselle.jee.core.lifecycle.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Retention;
14 | import java.lang.annotation.Target;
15 |
16 | /**
17 | * Used to prioritize methods annotated with {@link Startup} or {@link Shutdown}
18 | *
19 | * @author SERPRO
20 | */
21 | @Target({ TYPE, METHOD })
22 | @Retention(RUNTIME)
23 | public @interface DemoiselleLifecyclePriority {
24 |
25 | /**
26 | * The higher priority
27 | */
28 | final int LEVEL_1 = 100;
29 |
30 | /**
31 | * Second higher priority
32 | */
33 | final int LEVEL_2 = LEVEL_1 + 100;
34 |
35 | /**
36 | * Third higher priority
37 | */
38 | final int LEVEL_3 = LEVEL_2 + 100;
39 |
40 | /**
41 | * The lower priority
42 | */
43 | final int LEVEL_4 = LEVEL_3 + 100;
44 |
45 | /**
46 | *
47 | * An integer value defines the priority order. The lower the value, the greater priority.
48 | *
49 | *
50 | * @return Priority value, lower values have higher priority.
51 | */
52 | int value();
53 | }
54 |
--------------------------------------------------------------------------------
/demoiselle-core/src/main/java/org/demoiselle/jee/core/lifecycle/annotation/Shutdown.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.core.lifecycle.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
11 |
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.Target;
14 |
15 | /**
16 | * Identifies a method eligible to be executed automatically during application finalization .
17 | *
18 | * Take a look at the following usage sample:
19 | *
20 | *
21 | *
22 | * public class MyClass {
23 | *
24 | * @Shutdown
25 | * @Priority(Priority.MIN_PRIORITY)
26 | * public void finalize() {
27 | * ...
28 | * }
29 | * }
30 | *
31 | *
32 | * See {@link DemoiselleLifecyclePriority}
33 | *
34 | * @author SERPRO
35 | */
36 | @Target(METHOD)
37 | @Retention(RUNTIME)
38 | public @interface Shutdown {
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/demoiselle-core/src/main/java/org/demoiselle/jee/core/lifecycle/annotation/Startup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.core.lifecycle.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
11 |
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.Target;
14 |
15 | /**
16 | * Identifies a method eligible to be executed automatically during application initialization .
17 | *
18 | * Take a look at the following usage sample:
19 | *
20 | *
21 | *
22 | * public class MyClass {
23 | *
24 | * @Startup
25 | * @Priority(Priority.MAX_PRIORITY)
26 | * public void init() {
27 | * ...
28 | * }
29 | * }
30 | *
31 | *
32 | * See {@link DemoiselleLifecyclePriority}
33 | *
34 | * @author SERPRO
35 | */
36 | @Target(METHOD)
37 | @Retention(RUNTIME)
38 | public @interface Startup {
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/demoiselle-core/src/main/java/org/demoiselle/jee/core/lifecycle/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | /**
8 | * Provide Lifecycle feature
9 | *
10 | * @author SERPRO
11 | */
12 | package org.demoiselle.jee.core.lifecycle;
--------------------------------------------------------------------------------
/demoiselle-core/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | org.demoiselle.jee.core.lifecycle.LifecycleBootstrap
--------------------------------------------------------------------------------
/demoiselle-core/src/main/resources/demoiselle.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-core/src/main/resources/demoiselle.properties
--------------------------------------------------------------------------------
/demoiselle-core/src/main/resources/org/demoiselle/jee/core/message/DemoiselleMessage.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-core/src/main/resources/org/demoiselle/jee/core/message/DemoiselleMessage.properties
--------------------------------------------------------------------------------
/demoiselle-core/src/test/java/org/demoiselle/jee/core/CoreTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.core;
8 |
9 | /**
10 | *
11 | * @author SERPRO
12 | */
13 | public class CoreTest {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/demoiselle-core/src/test/java/org/demoiselle/jee/core/lifecycle/LifecyclePriorityTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.core.lifecycle;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import javax.enterprise.context.ApplicationScoped;
15 | import javax.enterprise.context.Destroyed;
16 | import javax.enterprise.context.Initialized;
17 | import javax.enterprise.event.Event;
18 | import javax.inject.Inject;
19 |
20 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
21 | import org.demoiselle.jee.core.lifecycle.model.PriorityLifecycleModelTest;
22 | import org.junit.Before;
23 | import org.junit.Test;
24 | import org.junit.runner.RunWith;
25 |
26 | @RunWith(CdiTestRunner.class)
27 | public class LifecyclePriorityTest {
28 |
29 | @Inject
30 | private PriorityLifecycleModelTest model;
31 |
32 | @Inject
33 | @Destroyed(ApplicationScoped.class)
34 | private Event eventDestroyed;
35 |
36 | @Inject
37 | @Initialized(ApplicationScoped.class)
38 | private Event eventInitialized;
39 |
40 | @Before
41 | public void setUp() {
42 | this.model.getNumbers().clear();
43 | }
44 |
45 | @Test
46 | public void methodWithStartupAnnotationsShouldBeExecutated() {
47 |
48 | this.eventInitialized.fire(new Object());
49 |
50 | List numbers = new ArrayList<>();
51 | numbers.add(1);
52 | numbers.add(2);
53 | numbers.add(3);
54 | numbers.add(4);
55 |
56 | assertEquals(numbers, this.model.getNumbers());
57 | }
58 |
59 | @Test
60 | public void methodWithShutdownAnnotationShouldBeExecutated() {
61 |
62 | this.eventDestroyed.fire(new Object());
63 |
64 | List numbers = new ArrayList<>();
65 | numbers.add(4);
66 | numbers.add(5);
67 | numbers.add(6);
68 |
69 | assertEquals(numbers, this.model.getNumbers());
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/demoiselle-core/src/test/java/org/demoiselle/jee/core/lifecycle/model/PriorityLifecycleModelTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.core.lifecycle.model;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | import javax.enterprise.context.ApplicationScoped;
13 |
14 | import org.demoiselle.jee.core.lifecycle.annotation.DemoiselleLifecyclePriority;
15 | import org.demoiselle.jee.core.lifecycle.annotation.Shutdown;
16 | import org.demoiselle.jee.core.lifecycle.annotation.Startup;
17 |
18 | @ApplicationScoped
19 | public class PriorityLifecycleModelTest {
20 |
21 | private List numbers = new ArrayList<>();
22 |
23 | @Startup
24 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_1)
25 | public void startupMethod1() {
26 | this.numbers.add(1);
27 | }
28 |
29 | @Startup
30 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_2)
31 | public void startupMethod2() {
32 | this.numbers.add(2);
33 | }
34 |
35 | @Startup
36 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_3)
37 | public void startupMethod3() {
38 | this.numbers.add(3);
39 | }
40 |
41 | @Startup
42 | public void startupMethod4() {
43 | this.numbers.add(4);
44 | }
45 |
46 | @Shutdown
47 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_1)
48 | public void shutdownMethod1() {
49 | this.numbers.add(4);
50 | }
51 |
52 | @Shutdown
53 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_2)
54 | public void shutdownMethod2() {
55 | this.numbers.add(5);
56 | }
57 |
58 | @Shutdown
59 | @DemoiselleLifecyclePriority(DemoiselleLifecyclePriority.LEVEL_3)
60 | public void shutdownMethod3() {
61 | this.numbers.add(6);
62 | }
63 |
64 | public List getNumbers() {
65 | return this.numbers;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/demoiselle-core/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-crud/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/AbstractBusiness.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import javax.inject.Inject;
10 |
11 | import org.demoiselle.jee.core.api.crud.Crud;
12 | import org.demoiselle.jee.core.api.crud.Result;
13 |
14 | public abstract class AbstractBusiness implements Crud {
15 |
16 | @Inject
17 | protected AbstractDAO dao;
18 |
19 | @Override
20 | public T persist(T entity) {
21 | return dao.persist(entity);
22 | }
23 |
24 | @Override
25 | public T mergeFull(T entity) {
26 | return dao.mergeFull(entity);
27 | }
28 |
29 | @Override
30 | public T mergeHalf(I id, T entity) {
31 | return dao.mergeHalf(id, entity);
32 | }
33 |
34 | @Override
35 | public void remove(I id) {
36 | dao.remove(id);
37 | }
38 |
39 | @Override
40 | public Result find() {
41 | return dao.find();
42 | }
43 |
44 | @Override
45 | public T find(I id) {
46 | return dao.find(id);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/AbstractREST.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
10 |
11 | import javax.inject.Inject;
12 | import javax.transaction.Transactional;
13 | import javax.validation.Valid;
14 | import javax.ws.rs.Consumes;
15 | import javax.ws.rs.DELETE;
16 | import javax.ws.rs.GET;
17 | import javax.ws.rs.POST;
18 | import javax.ws.rs.PUT;
19 | import javax.ws.rs.Path;
20 | import javax.ws.rs.PathParam;
21 | import javax.ws.rs.Produces;
22 | import javax.ws.rs.core.Response.Status;
23 |
24 | import org.demoiselle.jee.core.api.crud.Crud;
25 | import org.demoiselle.jee.core.api.crud.Result;
26 | import org.demoiselle.jee.rest.exception.DemoiselleRestException;
27 |
28 | import io.swagger.annotations.ApiOperation;
29 | import io.swagger.jaxrs.PATCH;
30 |
31 | /**
32 | * TODO CLF JAVADOC
33 | *
34 | * @author SERPRO
35 | *
36 | */
37 | @Produces(APPLICATION_JSON)
38 | @Consumes(APPLICATION_JSON)
39 | public abstract class AbstractREST implements Crud {
40 |
41 | @Inject
42 | protected AbstractBusiness bc;
43 |
44 | @Inject
45 | private CrudMessage crudMessage;
46 |
47 | @POST
48 | @Transactional
49 | @ApiOperation(value = "persist entity")
50 | @Override
51 | public T persist(@Valid T entity) {
52 | return bc.persist(entity);
53 | }
54 |
55 | @PUT
56 | @Transactional
57 | @ApiOperation(value = "full update entity")
58 | @Override
59 | public T mergeFull(@Valid T entity) {
60 | return bc.mergeFull(entity);
61 | }
62 |
63 | @PATCH
64 | @Path("{id}")
65 | @Transactional
66 | @ApiOperation(value = "partial update entity")
67 | @Override
68 | public T mergeHalf(@PathParam("id") final I id, T entity) {
69 | return bc.mergeHalf(id, entity);
70 | }
71 |
72 | @DELETE
73 | @Path("{id}")
74 | @Transactional
75 | @ApiOperation(value = "remove entity")
76 | @Override
77 | public void remove(@PathParam("id") final I id) {
78 | bc.remove(id);
79 | }
80 |
81 | @GET
82 | @Path("{id}")
83 | @Transactional
84 | @ApiOperation(value = "find by ID")
85 | @Override
86 | public T find(@PathParam("id") final I id) {
87 | return bc.find(id);
88 | }
89 |
90 | @GET
91 | @Transactional
92 | @Override
93 | public Result find() {
94 | /*
95 | * For security reasons we opted to throw the exception below so that the developer who is
96 | * extending this class overrides its own find() method using the @Search annotation (...)
97 | * defining the field fields.
98 | *
99 | * TODO CLF definir link de documentação
100 | */
101 | throw new DemoiselleRestException(crudMessage.methodFindNotImplemented(), Status.NOT_IMPLEMENTED.getStatusCode());
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/CrudMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * Messages used to inform user about CRUD feature
15 | *
16 | * @author SERPRO
17 | */
18 | @MessageBundle
19 | public interface CrudMessage {
20 |
21 | @MessageTemplate("{method-find-not-implemented}")
22 | String methodFindNotImplemented();
23 |
24 | @MessageTemplate("{field-request-does-not-exists-on-search-field}")
25 | String fieldRequestDoesNotExistsOnSearchField(String field);
26 |
27 | @MessageTemplate("{field-request-does-not-exists-on-object}")
28 | String fieldRequestDoesNotExistsOnObject(String field, String className);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/DemoiselleRequestContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import java.util.List;
10 | import java.util.Set;
11 |
12 | import org.demoiselle.jee.crud.sort.SortModel;
13 |
14 | /**
15 | * Class used to make a Context of the Request and Response of CRUD feature.
16 | *
17 | * @author SERPRO
18 | */
19 | public interface DemoiselleRequestContext {
20 |
21 | Integer getLimit();
22 | void setLimit(Integer limit);
23 |
24 | Integer getOffset();
25 | void setOffset(Integer offset);
26 |
27 | Long getCount();
28 | void setCount(Long count);
29 |
30 | Class> getEntityClass();
31 | void setEntityClass(Class> entityClass);
32 |
33 | TreeNodeField> getFilters();
34 | void setFilters(TreeNodeField> filters);
35 |
36 | List getSorts();
37 | void setSorts(List sorts);
38 |
39 | TreeNodeField> getFields();
40 | void setFields(TreeNodeField> fields);
41 |
42 | Boolean isPaginationEnabled();
43 | void setPaginationEnabled(Boolean isPaginationEnabled);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/ReservedHTTPHeaders.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | /**
10 | * Hold the reserved HTTP Headers.
11 | *
12 | * @author SERPRO
13 | *
14 | */
15 | public enum ReservedHTTPHeaders {
16 |
17 | // Pagination
18 | HTTP_HEADER_CONTENT_RANGE("Content-Range"),
19 | HTTP_HEADER_ACCEPT_RANGE("Accept-Range"),
20 | HTTP_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS("Access-Control-Expose-Headers");
21 |
22 | private final String key;
23 |
24 | ReservedHTTPHeaders(String key){
25 | this.key = key;
26 | }
27 |
28 | public String getKey(){
29 | return this.key;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/ReservedKeyWords.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | /**
10 | * Hold the reserved keywords.
11 | *
12 | * @author SERPRO
13 | *
14 | */
15 | public enum ReservedKeyWords {
16 |
17 | // Pagination
18 | DEFAULT_RANGE_KEY("range"),
19 |
20 | // Sort
21 | DEFAULT_SORT_DESC_KEY("desc"),
22 | DEFAULT_SORT_KEY("sort"),
23 |
24 | // Fields
25 | DEFAULT_FIELD_KEY("fields");
26 |
27 | private final String key;
28 |
29 | ReservedKeyWords(String key){
30 | this.key = key;
31 | }
32 |
33 | public String getKey(){
34 | return this.key;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/Search.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 |
11 | import java.lang.annotation.Documented;
12 | import java.lang.annotation.Retention;
13 | import java.lang.annotation.RetentionPolicy;
14 | import java.lang.annotation.Target;
15 |
16 | /**
17 | * Annotation to be used in methods that want to change the
18 | * default paging behavior and determine the fields that can be used by the
19 | * request and in the return of the result.
20 | *
21 | * Ex.
22 | *
23 | *
24 | * @GET
25 | * @Search(fields={"field1", "field2"}, withPagination = true, quantityPerPage = 2)
26 | * public Result myNewMethod(){
27 | * ...
28 | * }
29 | *
30 | *
31 | * The method above will filter just 'field1' and 'field2' and the default pagination page will be 2
32 | * register per page.
33 | *
34 | * @author SERPRO
35 | */
36 | @Documented
37 | @Retention(RetentionPolicy.RUNTIME)
38 | @Target(METHOD)
39 | public @interface Search {
40 | String[] fields();
41 | boolean withPagination() default true;
42 | int quantityPerPage() default 20;
43 | }
44 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/TreeNodeField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import java.util.LinkedList;
10 | import java.util.List;
11 |
12 | /**
13 | *
14 | * This class helps the CRUD feature to hold the fields on a Tree structure.
15 | *
16 | * @author SERPRO
17 | */
18 | public class TreeNodeField {
19 |
20 | private T key;
21 | private K value;
22 | private TreeNodeField parent;
23 | private List> children;
24 |
25 | public TreeNodeField(T key, K value) {
26 | this.key = key;
27 | this.value = value;
28 | this.children = new LinkedList<>();
29 | }
30 |
31 | public TreeNodeField addChild(T key, K value) {
32 | TreeNodeField childNode = new TreeNodeField(key, value);
33 | childNode.parent = this;
34 | this.children.add(childNode);
35 | return childNode;
36 | }
37 |
38 | public TreeNodeField getParent() {
39 | return this.parent;
40 | }
41 |
42 | public T getKey() {
43 | return this.key;
44 | }
45 |
46 | public K getValue() {
47 | return this.value;
48 | }
49 |
50 | public List> getChildren() {
51 | return this.children;
52 | }
53 |
54 | public TreeNodeField getChildByKey(T key){
55 | return getChildren().stream()
56 | .filter( (child) -> child.getKey().equals(key))
57 | .findAny()
58 | .orElse(null);
59 | }
60 |
61 | public Boolean containsKey(T key){
62 | return getChildren().stream()
63 | .filter( (child) -> child.getKey().equals(key)).count() > 0;
64 | }
65 |
66 | @Override
67 | public String toString() {
68 | return "TreeNodeField [key=" + key + ", value=" + value + ", children=" + children + "]";
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/bootstrap/PersistenceBootstrap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.bootstrap;
8 |
9 | import javax.enterprise.event.Observes;
10 | import javax.enterprise.inject.spi.AnnotatedType;
11 | import javax.enterprise.inject.spi.ProcessAnnotatedType;
12 | import javax.persistence.Entity;
13 |
14 | /**
15 | *
16 | * Adding the @Vetoed annotation to all persistent entities is considered a best
17 | * practice in most cases. The purpose of this annotation is to prevent the
18 | * BeanManager from managing an entity as a CDI Bean.
19 | *
20 | * http://www.cdi-spec.org/faq/ Why is @Vetoed a best practice for persistent
21 | * (JPA) entities?
22 | *
23 | * @author SERPRO
24 | *
25 | */
26 | public class PersistenceBootstrap implements javax.enterprise.inject.spi.Extension {
27 |
28 | @SuppressWarnings({ "rawtypes", "unchecked" })
29 | public void processAnnotatedType(@Observes final ProcessAnnotatedType pat) {
30 | final AnnotatedType annotatedType = pat.getAnnotatedType();
31 | if (annotatedType.getJavaClass().isAnnotationPresent(Entity.class)) {
32 | pat.veto();
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/bootstrap/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes as Bootstrap (SPI) Demoiselle CRUD Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.bootstrap;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/exception/DemoiselleCrudException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.exception;
8 |
9 | import org.demoiselle.jee.rest.exception.DemoiselleRestException;
10 |
11 | /**
12 | *
13 | * Exception for all persistence errors in CRUD.
14 | *
15 | * @author SERPRO
16 | */
17 | public class DemoiselleCrudException extends DemoiselleRestException {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | public DemoiselleCrudException() {
22 | }
23 |
24 | public DemoiselleCrudException(String message) {
25 | super(message);
26 | }
27 |
28 | public DemoiselleCrudException(Throwable cause) {
29 | super(cause);
30 | }
31 |
32 | public DemoiselleCrudException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes as Exceptions of the CRUD Demoiselle Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.exception;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/field/FieldHelperMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.field;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | * Messages used to inform user about Field feature
14 | *
15 | * @author SERPRO
16 | */
17 | @MessageBundle
18 | public interface FieldHelperMessage {
19 |
20 | @MessageTemplate("{field-request-malformed}")
21 | String fieldRequestMalFormed(String fieldName, String field);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/field/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes about Field feature of Demoiselle CRUD Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.field;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/filter/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes about Filter feature of Demoiselle CRUD Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.filter;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes of CRUD Demoiselle Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/pagination/PaginationHelperConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.pagination;
8 |
9 | import org.demoiselle.jee.configuration.annotation.Configuration;
10 |
11 | /**
12 | * Class responsible for hold configuration about Pagination feature.
13 | *
14 | * @author SERPRO
15 | */
16 | @Configuration(prefix = "demoiselle.crud.pagination")
17 | public class PaginationHelperConfig {
18 |
19 | private Boolean isGlobalEnabled = Boolean.TRUE;
20 | private Integer defaultPagination = new Integer(20);
21 |
22 | public Integer getDefaultPagination() {
23 | return defaultPagination;
24 | }
25 |
26 | public Boolean getIsGlobalEnabled() {
27 | return isGlobalEnabled;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/pagination/PaginationHelperMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.pagination;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * Messages used to inform user about Pagination feature
15 | *
16 | * @author SERPRO
17 | */
18 | @MessageBundle
19 | public interface PaginationHelperMessage {
20 |
21 | @MessageTemplate("{invalid-range-parameters}")
22 | String invalidRangeParameters();
23 |
24 | @MessageTemplate("{default-pagination-number-exceed}")
25 | String defaultPaginationNumberExceed(Integer defaultPaginationNumber);
26 |
27 | @MessageTemplate("{pagination-is-not-enabled}")
28 | String paginationIsNotEnabled();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/pagination/ResultSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.pagination;
8 |
9 | import java.util.LinkedList;
10 | import java.util.List;
11 |
12 | import org.demoiselle.jee.core.api.crud.Result;
13 | import org.demoiselle.jee.crud.AbstractDAO;
14 |
15 | /**
16 | * This classes implements {@link org.demoiselle.jee.core.api.crud.Result} to hold the results came from {@link AbstractDAO}
17 | *
18 | * @author SERPRO
19 | */
20 | public class ResultSet implements Result{
21 |
22 | private List> content = new LinkedList<>();
23 |
24 | @Override
25 | public List> getContent() {
26 | return content;
27 | }
28 |
29 | @Override
30 | public void setContent(List> content) {
31 | this.content = (List>) content;
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/pagination/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes about Pagination feature of Demoiselle CRUD Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.pagination;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/sort/CrudSort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.sort;
8 |
9 | /**
10 | * Enum to hold types supported by Sort feature
11 | *
12 | * @author SERPRO
13 | */
14 | public enum CrudSort {
15 |
16 | ASC,
17 | DESC
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/sort/SortHelperMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.sort;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * Messages used to inform user about Sort feature
15 | *
16 | * @author SERPRO
17 | */
18 | @MessageBundle
19 | public interface SortHelperMessage {
20 |
21 | @MessageTemplate("{sort-request-malformed}")
22 | String sortRequestMalFormed(String sort);
23 |
24 | @MessageTemplate("{desc-parameter-without-sort-parameter}")
25 | String descParameterWithoutSortParameter();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/sort/SortModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.sort;
8 |
9 | /**
10 | * This class helps the Sort feature to hold the type for sort ({@link CrudSort#ASC} or {@link CrudSort#DESC})
11 | * and the field that will be used to sort
12 | *
13 | * @author SERPRO
14 | */
15 | public class SortModel {
16 |
17 | private CrudSort type;
18 | private String field;
19 |
20 | public SortModel(CrudSort type, String field){
21 | this.type = type;
22 | this.field = field;
23 | }
24 |
25 | public CrudSort getType() {
26 | return type;
27 | }
28 |
29 | public String getField() {
30 | return field;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return "SortModel [type=" + type + ", field=" + field + "]";
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/java/org/demoiselle/jee/crud/sort/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 |
8 | /**
9 | * This package is intended to contain as related classes about Sort feature of Demoiselle CRUD Framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.crud.sort;
14 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | org.demoiselle.jee.crud.bootstrap.PersistenceBootstrap
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.crud.pagination.defaultPagination = 20
2 | demoiselle.crud.pagination.isGlobalEnabled = true
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/CrudMessage.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/CrudMessage.properties
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/field/FieldHelperMessage.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/field/FieldHelperMessage.properties
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/pagination/PaginationHelperMessage.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/pagination/PaginationHelperMessage.properties
--------------------------------------------------------------------------------
/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/sort/SortHelperMessage.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/demoiselle/framework/096baf60f3c2cac7b6abe56d574af1226763210f/demoiselle-crud/src/main/resources/org/demoiselle/jee/crud/sort/SortHelperMessage.properties
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/ErrorMsgForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | /**
10 | * @author SERPRO
11 | *
12 | */
13 | public class ErrorMsgForTest {
14 |
15 | public String msg = "";
16 | public String debbug = "";
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/UserRestForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import org.demoiselle.jee.core.api.crud.Result;
10 | import org.demoiselle.jee.crud.AbstractREST;
11 | import org.demoiselle.jee.crud.entity.UserModelForTest;
12 |
13 | import javax.ws.rs.GET;
14 |
15 | /**
16 | *
17 | * @author SERPRO
18 | *
19 | */
20 | public class UserRestForTest extends AbstractREST {
21 |
22 | @Override
23 | @GET
24 | public Result find() {
25 | return null;
26 | }
27 |
28 | @GET
29 | @Search(fields={"name", "address"}, quantityPerPage = 10, withPagination = true)
30 | public Result findWithSearch() {
31 | return null;
32 | }
33 |
34 | @GET
35 | @Search(fields={"name"}, withPagination = false)
36 | public Result findWithSearchAnnotationAndPaginationDisabled(){
37 | return null;
38 | }
39 |
40 | @GET
41 | @Search(fields={"id", "name", "mail"})
42 | public Result findWithSearchAndFields(){
43 | return null;
44 | }
45 |
46 | @GET
47 | @Search(fields={"id", "name", "address(street)"})
48 | public Result findWithSearchAndFieldsWithSubFields(){
49 | return null;
50 | }
51 |
52 | @GET
53 | @Search(fields={"*"})
54 | public Result findWithSearchAndAllFields(){
55 | return null;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/UserRestWithoutAbstractRESTForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud;
8 |
9 | import javax.ws.rs.GET;
10 | import javax.ws.rs.core.Response;
11 |
12 | import org.demoiselle.jee.core.api.crud.Result;
13 |
14 | /**
15 | *
16 | * @author SERPRO
17 | *
18 | */
19 | public class UserRestWithoutAbstractRESTForTest {
20 |
21 | @GET
22 | public Result find() {
23 | return null;
24 | }
25 |
26 | @GET
27 | public Response findWithException() {
28 | ErrorMsgForTest entity = new ErrorMsgForTest();
29 | return Response.status(400).entity(entity).type("application/json").build();
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/entity/AddressModelForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.entity;
8 |
9 | /**
10 | * @author SERPRO
11 | *
12 | */
13 | public class AddressModelForTest {
14 |
15 | private Long id;
16 | private String address;
17 | private String street;
18 | private CountryModelForTest country;
19 |
20 | public Long getId() {
21 | return id;
22 | }
23 | public void setId(Long id) {
24 | this.id = id;
25 | }
26 | public String getAddress() {
27 | return address;
28 | }
29 | public void setAddress(String address) {
30 | this.address = address;
31 | }
32 | public CountryModelForTest getCountry() {
33 | return country;
34 | }
35 | public void setCountry(CountryModelForTest country) {
36 | this.country = country;
37 | }
38 | public String getStreet() {
39 | return street;
40 | }
41 | public void setStreet(String street) {
42 | this.street = street;
43 | }
44 | @Override
45 | public String toString() {
46 | return "AddressModelForTest [id=" + id + ", address=" + address + ", street=" + street + ", country=" + country
47 | + "]";
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/entity/CountryModelForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.entity;
8 |
9 | /**
10 | * @author SERPRO
11 | *
12 | */
13 | public class CountryModelForTest {
14 |
15 | private Long id;
16 | private String name;
17 |
18 | public Long getId() {
19 | return id;
20 | }
21 | public void setId(Long id) {
22 | this.id = id;
23 | }
24 | public String getName() {
25 | return name;
26 | }
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 | @Override
31 | public String toString() {
32 | return "CountryModelForTest [id=" + id + ", name=" + name + "]";
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/java/org/demoiselle/jee/crud/entity/UserModelForTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.crud.entity;
8 |
9 | /**
10 | *
11 | * @author SERPRO
12 | *
13 | */
14 | public class UserModelForTest {
15 |
16 | private Long id;
17 | private String name;
18 | private String mail;
19 | private Integer age;
20 | private AddressModelForTest address;
21 |
22 | public Long getId() {
23 | return id;
24 | }
25 |
26 | public void setId(Long id) {
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public String getMail() {
39 | return mail;
40 | }
41 |
42 | public void setMail(String mail) {
43 | this.mail = mail;
44 | }
45 |
46 | public Integer getAge() {
47 | return age;
48 | }
49 |
50 | public void setAge(Integer age) {
51 | this.age = age;
52 | }
53 |
54 | public AddressModelForTest getAddress() {
55 | return address;
56 | }
57 |
58 | public void setAddress(AddressModelForTest address) {
59 | this.address = address;
60 | }
61 |
62 | @Override
63 | public String toString() {
64 | return "UserModelForTest [id=" + id + ", name=" + name + ", mail=" + mail + ", age=" + age + ", address="
65 | + address + "]";
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | org.demoiselle.jee.crud.bootstrap.PersistenceBootstrap
--------------------------------------------------------------------------------
/demoiselle-crud/src/test/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.crud.acceptRange=20
2 | demoiselle.crud.patternsEnabled=true
3 |
--------------------------------------------------------------------------------
/demoiselle-parent-bom/.gitignore:
--------------------------------------------------------------------------------
1 | /.settings/
2 | /.project
3 | /target/
4 |
--------------------------------------------------------------------------------
/demoiselle-parent-rest/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-parent/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-parent/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | demoiselle-parent
5 | pom
6 | 4.0.0
7 |
8 | Demoiselle JEE Parent
9 | http://demoiselle.io
10 |
11 |
12 | org.demoiselle.jee
13 | demoiselle-build
14 | 3.0.6-SNAPSHOT
15 |
16 |
17 |
18 | ../licence-lgpl
19 |
20 |
21 |
22 |
23 |
24 | org.demoiselle.jee
25 | demoiselle-parent-bom
26 | 3.0.6-SNAPSHOT
27 | import
28 | pom
29 |
30 |
31 |
32 |
33 |
34 |
35 | junit
36 | junit
37 | test
38 |
39 |
40 |
41 | org.hamcrest
42 | hamcrest-core
43 | test
44 |
45 |
46 |
47 | org.apache.deltaspike.modules
48 | deltaspike-test-control-module-api
49 | test
50 |
51 |
52 |
53 | org.apache.deltaspike.modules
54 | deltaspike-test-control-module-impl
55 | test
56 |
57 |
58 |
59 | org.apache.deltaspike.cdictrl
60 | deltaspike-cdictrl-weld
61 | test
62 |
63 |
64 |
65 | org.jboss.weld.se
66 | weld-se-core
67 | test
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/demoiselle-rest/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-rest/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | demoiselle-rest
5 | jar
6 |
7 | Demoiselle JEE Rest
8 |
9 | Demoiselle Rest
10 |
11 | http://demoiselle.io
12 |
13 |
14 | org.demoiselle.jee
15 | demoiselle-parent
16 | 3.0.6-SNAPSHOT
17 | ../demoiselle-parent
18 |
19 |
20 |
21 |
22 |
23 | org.demoiselle.jee
24 | demoiselle-core
25 |
26 |
27 |
28 | org.demoiselle.jee
29 | demoiselle-configuration
30 |
31 |
32 |
33 | javax.ws.rs
34 | javax.ws.rs-api
35 |
36 |
37 |
38 | javax.json
39 | javax.json-api
40 |
41 |
42 |
43 | io.swagger
44 | swagger-jaxrs
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/DemoiselleRestConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | /*
8 | * To change this license header, choose License Headers in Project Properties.
9 | * To change this template file, choose Tools | Templates
10 | * and open the template in the editor.
11 | */
12 | package org.demoiselle.jee.rest;
13 |
14 | import java.util.HashMap;
15 | import java.util.Map;
16 |
17 | import org.demoiselle.jee.configuration.annotation.Configuration;
18 |
19 | /**
20 | * Configurations of REST module.
21 | *
22 | * @author SERPRO
23 | */
24 | @Configuration(prefix = "demoiselle.rest")
25 | public class DemoiselleRestConfig {
26 |
27 | private Map sqlError = new HashMap();
28 |
29 | private boolean showErrorDetails = true;
30 |
31 | /**
32 | * Return true or false if the detailed errors should return to user.
33 | *
34 | * @return true or false
35 | */
36 | public boolean isShowErrorDetails() {
37 | return showErrorDetails;
38 | }
39 |
40 | /**
41 | * Set if the detailed errors should return to user.
42 | *
43 | * @param showErrorDetails
44 | */
45 | public void setShowErrorDetails(boolean showErrorDetails) {
46 | this.showErrorDetails = showErrorDetails;
47 | }
48 |
49 | /**
50 | * Set the map of custom database error messages
51 | *
52 | * @param sqlError
53 | */
54 | public void setSqlError(Map sqlError) {
55 | this.sqlError = sqlError;
56 | }
57 |
58 | /**
59 | * Return the map of custom Sql Error messages from demoiselle.properties loaded by configuration module.
60 | *
61 | * @return mapped sql Errors
62 | */
63 | public Map getSqlError() {
64 | return this.sqlError;
65 | }
66 |
67 | }
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/LogExceptionMappers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest;
8 |
9 | import java.util.logging.Logger;
10 |
11 | import javax.enterprise.event.Observes;
12 | import javax.enterprise.inject.spi.Extension;
13 | import javax.enterprise.inject.spi.ProcessAnnotatedType;
14 | import javax.ws.rs.ext.ExceptionMapper;
15 |
16 | /**
17 | *
18 | *
19 | * @author SERPRO
20 | *
21 | */
22 | public class LogExceptionMappers implements Extension {
23 |
24 | private static final Logger logger = Logger.getLogger(LogExceptionMappers.class.getName());
25 |
26 | /**
27 | * Process all classes that extends {@link ExceptionMapper} to log for
28 | * analysis.
29 | *
30 | * @param pat
31 | * ProcessAnnotatedType used by CDI
32 | */
33 | public void processAnnotatedType(@Observes final ProcessAnnotatedType extends ExceptionMapper>> pat) {
34 | Class extends ExceptionMapper>> pcsClass = pat.getAnnotatedType().getJavaClass();
35 | if (pcsClass.isAnnotationPresent(javax.ws.rs.ext.Provider.class)) {
36 | logger.warning(pcsClass.getCanonicalName());
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/annotation/CacheControl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import java.lang.annotation.Inherited;
12 | import java.lang.annotation.Retention;
13 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
14 | import java.lang.annotation.Target;
15 | import javax.enterprise.util.Nonbinding;
16 | import javax.interceptor.InterceptorBinding;
17 |
18 | /**
19 | *
20 | * @author SERPRO
21 | */
22 | @Inherited
23 | @InterceptorBinding
24 | @Target({ METHOD, TYPE })
25 | @Retention(RUNTIME)
26 | public @interface CacheControl {
27 |
28 | @Nonbinding
29 | String value() default "max-age=0";
30 | }
31 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/exception/DemoiselleRestException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.exception;
8 |
9 | import java.util.HashSet;
10 |
11 | import javax.ws.rs.core.Response.Status;
12 |
13 | import org.demoiselle.jee.core.exception.DemoiselleException;
14 |
15 | public class DemoiselleRestException extends DemoiselleException {
16 |
17 | private static final long serialVersionUID = 519_965_615_171_844_237L;
18 |
19 | protected HashSet messages = new HashSet();
20 |
21 | protected int statusCode = Status.INTERNAL_SERVER_ERROR.getStatusCode();
22 |
23 | public DemoiselleRestException() {
24 | }
25 |
26 | public DemoiselleRestException(int statusCode) {
27 | this.statusCode = statusCode;
28 | }
29 |
30 | public DemoiselleRestException(String string) {
31 | super(string);
32 | }
33 |
34 | public DemoiselleRestException(String string, int statusCode) {
35 | super(string);
36 | this.statusCode = statusCode;
37 | }
38 |
39 | public DemoiselleRestException(Throwable cause) {
40 | super(cause);
41 | }
42 |
43 | public DemoiselleRestException(String message, Throwable cause) {
44 | super(message, cause);
45 | }
46 |
47 | public int getStatusCode() {
48 | return statusCode;
49 | }
50 |
51 | public void addMessage(String field, String msg) {
52 | messages.add(new DemoiselleRestExceptionMessage(field, msg, null));
53 | }
54 |
55 | public void addMessage(String error, String error_description, String error_link) {
56 | messages.add(new DemoiselleRestExceptionMessage(error, error_description, error_link));
57 | }
58 |
59 | public HashSet getMessages() {
60 | return messages;
61 | }
62 |
63 | public void setMessages(HashSet msgs) {
64 | this.messages = msgs;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/exception/DemoiselleRestExceptionMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.exception;
8 |
9 | /**
10 | * Message Exception class intended to be used by REST DemoiselleFramework
11 | * exceptions.
12 | *
13 | * @author SERPRO
14 | */
15 | public class DemoiselleRestExceptionMessage {
16 |
17 | private String error;
18 | private String error_description;
19 |
20 | private String error_link;
21 |
22 | public DemoiselleRestExceptionMessage(String error, String error_description, String error_link) {
23 | this.error = error;
24 | this.error_description = error_description;
25 | this.error_link = error_link;
26 | }
27 |
28 | public String getError() {
29 | return error;
30 | }
31 |
32 | public void setError(String error) {
33 | this.error = error;
34 | }
35 |
36 | public String getError_description() {
37 | return error_description;
38 | }
39 |
40 | public void setError_description(String error_description) {
41 | this.error_description = error_description;
42 | }
43 |
44 | public String getError_link() {
45 | return error_link;
46 | }
47 |
48 | public void setError_link(String error_link) {
49 | this.error_link = error_link;
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/exception/mapper/AnyOtherExceptionMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.exception.mapper;
8 |
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 |
12 | import javax.inject.Inject;
13 | import javax.servlet.http.HttpServletRequest;
14 | import javax.ws.rs.core.Context;
15 | import javax.ws.rs.core.Response;
16 | import javax.ws.rs.ext.ExceptionMapper;
17 | import javax.ws.rs.ext.Provider;
18 |
19 | import org.demoiselle.jee.core.exception.ExceptionTreatment;
20 |
21 | /**
22 | * Any other exception is mapped by this class and when toResponse method is
23 | * called then sends to @ExceptionTreatment to treat error and return the
24 | * correct format in @Response object.
25 | *
26 | * @author SERPRO
27 | *
28 | */
29 | @Provider
30 | public class AnyOtherExceptionMapper implements ExceptionMapper {
31 |
32 | private static final Logger logger = Logger.getLogger(AnyOtherExceptionMapper.class.getName());
33 |
34 | @Context
35 | protected HttpServletRequest httpRequest;
36 |
37 | @Inject
38 | protected ExceptionTreatment exceptionTreatment;
39 |
40 | @Override
41 | public Response toResponse(Throwable exception) {
42 | logger.log(Level.SEVERE, "Using AnyOtherExceptionMapper", exception);
43 | return exceptionTreatment.getFormatedError(exception, httpRequest);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/exception/mapper/ValidationExceptionMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.exception.mapper;
8 |
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 |
12 | import javax.inject.Inject;
13 | import javax.servlet.http.HttpServletRequest;
14 | import javax.validation.ValidationException;
15 | import javax.ws.rs.core.Context;
16 | import javax.ws.rs.core.Response;
17 | import javax.ws.rs.ext.ExceptionMapper;
18 | import javax.ws.rs.ext.Provider;
19 |
20 | import org.demoiselle.jee.core.exception.ExceptionTreatment;
21 |
22 | /**
23 | * When an exception is thrown, JAX-RS will first try to find an ExceptionMapper
24 | * for that exception’s type. If it cannot find one, it will look for a mapper
25 | * that can handle the exception’s superclass. It will continue this process
26 | * until there are no more superclasses to match against.
27 | *
28 | * { @link
29 | * https://dennis-xlc.gitbooks.io/restful-java-with-jax-rs-2-0-2rd-edition/content/en/part1/chapter7/exception_handling.html
30 | * }
31 | *
32 | * @author SERPRO
33 | *
34 | */
35 | @Provider
36 | public class ValidationExceptionMapper implements ExceptionMapper {
37 |
38 | private static final Logger logger = Logger.getLogger(AnyOtherExceptionMapper.class.getName());
39 |
40 | @Context
41 | protected HttpServletRequest httpRequest;
42 |
43 | @Inject
44 | protected ExceptionTreatment exceptionTreatment;
45 |
46 | @Override
47 | public Response toResponse(ValidationException exception) {
48 | logger.log(Level.SEVERE, "Using ValidationExceptionMapper", exception);
49 | return exceptionTreatment.getFormatedError(exception, httpRequest);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/filter/CacheControlFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.filter;
8 |
9 | import java.io.IOException;
10 | import java.lang.reflect.Method;
11 | import javax.annotation.Priority;
12 | import static javax.ws.rs.Priorities.HEADER_DECORATOR;
13 | import javax.ws.rs.container.ContainerRequestContext;
14 | import javax.ws.rs.container.ContainerResponseContext;
15 | import javax.ws.rs.container.ContainerResponseFilter;
16 | import javax.ws.rs.container.ResourceInfo;
17 | import javax.ws.rs.core.Context;
18 | import javax.ws.rs.ext.Provider;
19 | import org.demoiselle.jee.rest.annotation.CacheControl;
20 |
21 | /**
22 | *
23 | * @author SERPRO
24 | */
25 | @Provider
26 | @Priority(HEADER_DECORATOR)
27 | public class CacheControlFilter implements ContainerResponseFilter {
28 |
29 | @Context
30 | private ResourceInfo info;
31 |
32 | @Override
33 | public void filter(ContainerRequestContext req, ContainerResponseContext res) throws IOException {
34 | if (req.getMethod().equals("GET")) {
35 | Method method = info.getResourceMethod();
36 | if (method != null) {
37 | CacheControl max = method.getAnnotation(CacheControl.class);
38 | if (max != null) {
39 | res.getHeaders().putSingle("Cache-Control", max.value());
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/filter/RestFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.filter;
8 |
9 | import javax.annotation.Priority;
10 | import javax.inject.Inject;
11 | import static javax.ws.rs.Priorities.HEADER_DECORATOR;
12 | import javax.ws.rs.container.ContainerRequestContext;
13 | import javax.ws.rs.container.ContainerResponseContext;
14 | import javax.ws.rs.container.ContainerResponseFilter;
15 | import javax.ws.rs.ext.Provider;
16 |
17 | import org.demoiselle.jee.core.message.DemoiselleMessage;
18 |
19 | /**
20 | *
21 | * @author SERPRO
22 | *
23 | */
24 | @Provider
25 | @Priority(HEADER_DECORATOR)
26 | public class RestFilter implements ContainerResponseFilter {
27 |
28 | @Inject
29 | private DemoiselleMessage demoiselleMessage;
30 |
31 | @Override
32 | public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
33 | responseContext.getHeaders().putSingle("Demoiselle-Version", demoiselleMessage.frameworkName());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/java/org/demoiselle/jee/rest/message/DemoiselleRESTMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest.message;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | * Message class intended to be used by REST module.
14 | *
15 | * @author SERPRO
16 | */
17 | @MessageBundle
18 | public interface DemoiselleRESTMessage {
19 |
20 | @MessageTemplate("{unhandled-database-exception}")
21 | String unhandledDatabaseException();
22 |
23 | @MessageTemplate("{unhandled-malformed-input-output-exception}")
24 | String unhandledMalformedInputOutputException();
25 |
26 | @MessageTemplate("{http-exception}")
27 | String httpException();
28 |
29 | @MessageTemplate("{unhandled-server-exception}")
30 | String unhandledServerException();
31 |
32 | }
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | org.demoiselle.jee.rest.LogExceptionMappers
--------------------------------------------------------------------------------
/demoiselle-rest/src/main/resources/org/demoiselle/jee/rest/message/DemoiselleRESTMessage.properties:
--------------------------------------------------------------------------------
1 | unhandled-database-exception=Unhandled database exception
2 | unhandled-malformed-input-output-exception=Unhandled malformed input/output exception
3 | http-exception=Http exception
4 | unhandled-server-exception=Unhandled server exception
--------------------------------------------------------------------------------
/demoiselle-rest/src/test/java/org/demoiselle/jee/rest/DemoiselleRestConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.rest;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import javax.inject.Inject;
12 |
13 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
14 | import org.junit.After;
15 | import org.junit.AfterClass;
16 | import org.junit.Before;
17 | import org.junit.BeforeClass;
18 | import org.junit.Test;
19 | import org.junit.runner.RunWith;
20 |
21 | /**
22 | *
23 | * @author SERPRO
24 | */
25 | @RunWith(CdiTestRunner.class)
26 | public class DemoiselleRestConfigTest {
27 |
28 | @BeforeClass
29 | public static void setUpClass() {
30 | }
31 |
32 | @AfterClass
33 | public static void tearDownClass() {
34 | }
35 |
36 | @Inject
37 | private DemoiselleRestConfig instance;
38 |
39 | public DemoiselleRestConfigTest() {
40 | }
41 |
42 | @Before
43 | public void setUp() {
44 | }
45 |
46 | @After
47 | public void tearDown() {
48 | }
49 |
50 | /**
51 | * Test of isErrorDetails method, of class DemoiselleRestConfig.
52 | */
53 | @Test
54 | public void test1() {
55 |
56 | boolean expResult = instance.isShowErrorDetails();
57 | assertEquals(expResult, true);
58 | }
59 |
60 | /**
61 | * Test of setshowErrorDetails method, of class DemoiselleRestConfig.
62 | */
63 | @Test
64 | public void test2() {
65 | instance.setShowErrorDetails(false);
66 | boolean expResult = instance.isShowErrorDetails();
67 |
68 | assertEquals(expResult, false);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/demoiselle-script/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-script/README.md:
--------------------------------------------------------------------------------
1 |
2 | DynamicManager
3 | -------------------------------------------------- -------------------------------------------------
4 | Responsible for Managing Scripts, its compilation and execution.
5 |
6 | The implementation of this component is for the use of the facilities provided by the Java Scripting API to build dynamic and scripting languages in which implement compatible engine with JSR-223.
7 |
8 | Using Compiled and Invocable interfaces JSR-223 (implemented in engines) the manager can access the generically methods to compile the code and save the bytecode cache.
9 |
10 | The script allows execution is passed a context with objects that will be accessible to the script code can be manipulated / altered by the same and made available via the same context for the calling code.
11 |
12 | -------------------------------------------------- -------------------------------------------------
13 | Example of use:
14 |
15 | @Inject DynamicManager dm;
16 |
17 | ...
18 |
19 |
20 | try {
21 | String scriptSource = "int a = X; X= a + a;"; //sourcecode to be compiled .
22 | String scriptName = "test.groovy"; //id to scriptCache
23 | Integer valueX = 1; //value to be passed to script
24 | if( dm.getScript(scriptName) == null ) { //verify if is a cached script
25 | dm.loadEngine("groovy"); //the name of JSR-223 engine to load.
26 | dm.loadScript ( "test.groovy", scriptSource); //load the script into dynamicManager cache.
27 | }
28 | Bindings context = new SimpleBindings(); //create the context to script where 'X' is a key in script to a dynamic variable.
29 | context.put("X", valueX ); //The value can be a class too.
30 | System.out.println("The value of X is " + valueX + " before script execution.");
31 | System.out.println("Running script...");
32 | dm.eval ( "test.groovy",context); //run the script.
33 | valueX = (Integer) context.get("X");
34 | System.out.println("The value of X is " + valueX + " after script execution.");
35 | Assert.assertTrue(true);
36 | } catch (ScriptException e) {
37 | e.printStackTrace();
38 | }
39 |
40 | ...
--------------------------------------------------------------------------------
/demoiselle-script/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | demoiselle-script
6 | jar
7 |
8 | Demoiselle JEE Script
9 |
10 | Demoiselle JEE Script
11 |
12 | http://demoiselle.io
13 |
14 |
15 | org.demoiselle.jee
16 | demoiselle-parent
17 | 3.0.6-SNAPSHOT
18 | ../demoiselle-parent
19 |
20 |
21 |
22 |
23 | org.demoiselle.jee
24 | demoiselle-core
25 |
26 |
27 |
28 | org.codehaus.groovy
29 | groovy-all
30 |
31 |
32 |
--------------------------------------------------------------------------------
/demoiselle-script/src/main/java/org/demoiselle/jee/script/DynamicManagerCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.script;
8 |
9 | import java.io.Serializable;
10 | import java.util.Map;
11 | import java.util.concurrent.ConcurrentHashMap;
12 |
13 | import javax.enterprise.context.ApplicationScoped;
14 |
15 | /**
16 | * Dynamic Manage Cache - Responsible for Script Cache
17 | *
18 | * @author SERPRO
19 | */
20 | @ApplicationScoped
21 | public class DynamicManagerCache implements Serializable {
22 |
23 | private static final long serialVersionUID = 2305168056315491913L;
24 |
25 | static Map> scriptCache = new ConcurrentHashMap>();
26 | static Map engineList = new ConcurrentHashMap();
27 | }
28 |
--------------------------------------------------------------------------------
/demoiselle-script/src/main/java/org/demoiselle/jee/script/exception/DemoiselleScriptException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.script.exception;
8 |
9 | import org.demoiselle.jee.core.exception.DemoiselleException;
10 |
11 | /**
12 | *
13 | * Main exception Demoiselle Script feature
14 | *
15 | * @author SERPRO
16 | */
17 | public class DemoiselleScriptException extends DemoiselleException{
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | public DemoiselleScriptException(String message) {
22 | super(message);
23 | }
24 |
25 | public DemoiselleScriptException(String message, Throwable cause) {
26 | super(message, cause);
27 | }
28 | }
--------------------------------------------------------------------------------
/demoiselle-script/src/main/java/org/demoiselle/jee/script/message/DemoiselleScriptMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.script.message;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * @author SERPRO
15 | */
16 | @MessageBundle
17 | public interface DemoiselleScriptMessage {
18 |
19 | @MessageTemplate("{error-engine-cannot-load}")
20 | String cannotLoadEngine(String engineName);
21 |
22 | @MessageTemplate("{error-engine-not-loaded}")
23 | String engineNotLoaded();
24 |
25 | @MessageTemplate("{error-engine-not-compilable}")
26 | String engineNotCompilable();
27 |
28 | @MessageTemplate("{error-script-not-loaded}")
29 | String scriptNotLoaded(String scriptName);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/demoiselle-script/src/main/java/org/demoiselle/jee/script/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | /**
8 | * This package is intended to contain as classes related to
9 | * DynamicScriptManager of the Demoiselle framework.
10 | *
11 | * @author SERPRO
12 | */
13 | package org.demoiselle.jee.script;
--------------------------------------------------------------------------------
/demoiselle-script/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-script/src/main/resources/org/demoiselle/jee/script/message/DemoiselleScriptMessage.properties:
--------------------------------------------------------------------------------
1 | error-engine-not-loaded=Script Engine not loaded
2 | error-engine-cannot-load=Cannot load the engine [%s]
3 | error-engine-not-compilable=Engine can't compile code. Interface Compilable not implemented by engine.
4 | error-script-not-loaded=Script not loaded [%s]
--------------------------------------------------------------------------------
/demoiselle-script/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-script/src/test/resources/org/demoiselle/jee/script/message/DemoiselleScriptMessage.properties:
--------------------------------------------------------------------------------
1 | error-engine-not-loaded=Script Engine not loaded
2 | error-engine-cannot-load=Cannot load the engine [%s]
3 | error-engine-not-compilable=Engine can't compile code. Interface Compilable not implemented by engine.
4 | error-script-not-loaded=Script not loaded [%s]
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | demoiselle-security-hashcash
5 | jar
6 |
7 | Demoiselle JEE Security HashCash
8 |
9 | Demoiselle Security HashCash
10 |
11 | http://demoiselle.io
12 |
13 |
14 | org.demoiselle.jee
15 | demoiselle-parent
16 | 3.0.0-SNAPSHOT
17 | ../demoiselle-parent
18 |
19 |
20 |
21 | org.demoiselle.jee
22 | demoiselle-security-jwt
23 |
24 |
25 |
26 | org.bitbucket.b_c
27 | jose4j
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/main/java/org/demoiselle/jee/security/hashcash/DemoiselleSecurityHashCashConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.hashcash;
8 |
9 | import java.io.Serializable;
10 | import org.demoiselle.jee.configuration.annotation.Configuration;
11 | import org.demoiselle.jee.configuration.annotation.ConfigurationSuppressLogger;
12 |
13 | /**
14 | *
15 | * @author SERPRO
16 | */
17 | @Configuration(prefix = "demoiselle.security.hashcash")
18 | public class DemoiselleSecurityHashCashConfig implements Serializable {
19 |
20 | @ConfigurationSuppressLogger
21 | private String hashcashKey;
22 |
23 | private Long timetoLiveMilliseconds;
24 |
25 | public String getHashcashKey() {
26 | return hashcashKey;
27 | }
28 |
29 | public Long getTimetoLiveMilliseconds() {
30 | return timetoLiveMilliseconds;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/main/java/org/demoiselle/jee/security/hashcash/annotation/HashCash.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.hashcash.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Inherited;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | import javax.interceptor.InterceptorBinding;
18 |
19 | @Inherited
20 | @InterceptorBinding
21 | @Target({METHOD, TYPE})
22 | @Retention(RUNTIME)
23 | public @interface HashCash {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/main/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.security.hashcash.hashcashKey=Demoiselle
2 | demoiselle.security.hashcash.timetoLiveMilliseconds=5000
3 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/test/java/org/demoiselle/jee/security/hashcash/execution/HashCashTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.hashcash.execution;
8 |
9 | import javax.inject.Inject;
10 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
11 | import org.junit.After;
12 | import org.junit.AfterClass;
13 | import org.junit.Before;
14 | import org.junit.BeforeClass;
15 | import org.junit.Test;
16 | import static org.junit.Assert.*;
17 | import org.junit.runner.RunWith;
18 |
19 | /**
20 | *
21 | * @author SERPRO
22 | */
23 | @RunWith(CdiTestRunner.class)
24 | public class HashCashTest {
25 |
26 | @Inject
27 | private Generator gera;
28 |
29 | public HashCashTest() {
30 | }
31 |
32 | @BeforeClass
33 | public static void setUpClass() {
34 | }
35 |
36 | @AfterClass
37 | public static void tearDownClass() {
38 | }
39 |
40 | @Before
41 | public void setUp() {
42 | }
43 |
44 | @After
45 | public void tearDown() {
46 | }
47 |
48 | @Test
49 | public void testMintCash_String_int() throws Exception {
50 | System.out.println("mintCash");
51 | System.out.println(gera.token());
52 |
53 | assertEquals(" ", " ");
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security-hashcash/src/test/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.security.hashcash.hashcashKey=Demoiselle
2 | demoiselle.security.hashcash.timetoLiveMilliseconds=5000
3 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | demoiselle-security-jwt
5 | jar
6 |
7 | Demoiselle JEE Security JWT
8 |
9 | Demoiselle Security JWT
10 |
11 | http://demoiselle.io
12 |
13 |
14 | org.demoiselle.jee
15 | demoiselle-parent
16 | 3.0.6-SNAPSHOT
17 | ../demoiselle-parent
18 |
19 |
20 |
21 |
22 | org.demoiselle.jee
23 | demoiselle-security
24 |
25 |
26 |
27 | org.bitbucket.b_c
28 | jose4j
29 |
30 |
31 |
32 | org.hibernate
33 | hibernate-validator
34 | test
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/main/java/org/demoiselle/jee/security/jwt/impl/DemoiselleSecurityJWTConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.jwt.impl;
8 |
9 | import java.io.Serializable;
10 | import org.demoiselle.jee.configuration.annotation.Configuration;
11 | import org.demoiselle.jee.configuration.annotation.ConfigurationSuppressLogger;
12 |
13 | /**
14 | *
15 | * @author SERPRO
16 | */
17 | @Configuration(prefix = "demoiselle.security.jwt")
18 | public class DemoiselleSecurityJWTConfig implements Serializable {
19 |
20 | private static final long serialVersionUID = 638_435_989_235_076_782L;
21 |
22 | private String type;
23 |
24 | @ConfigurationSuppressLogger
25 | private String privateKey;
26 |
27 | private String publicKey;
28 |
29 | private Long timetoLiveMilliseconds;
30 |
31 | private String issuer;
32 |
33 | private String audience;
34 |
35 | private String algorithmIdentifiers;
36 |
37 | public String getType() {
38 | return type;
39 | }
40 |
41 | public String getPrivateKey() {
42 | return privateKey;
43 | }
44 |
45 | public String getPublicKey() {
46 | return publicKey;
47 | }
48 |
49 | public Long getTimetoLiveMilliseconds() {
50 | return timetoLiveMilliseconds;
51 | }
52 |
53 | public String getIssuer() {
54 | return issuer;
55 | }
56 |
57 | public String getAudience() {
58 | return audience;
59 | }
60 |
61 | public String getAlgorithmIdentifiers() {
62 | return algorithmIdentifiers;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/main/java/org/demoiselle/jee/security/message/DemoiselleSecurityJWTMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.message;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * @author SERPRO
15 | */
16 | @MessageBundle
17 | public interface DemoiselleSecurityJWTMessages {
18 |
19 | @MessageTemplate("{general}")
20 | String general();
21 |
22 | @MessageTemplate("{expired}")
23 | String expired();
24 |
25 | @MessageTemplate("{master}")
26 | String master();
27 |
28 | @MessageTemplate("{slave}")
29 | String slave();
30 |
31 | @MessageTemplate("{error}")
32 | String error();
33 |
34 | @MessageTemplate("{choose-type}")
35 | String chooseType();
36 |
37 | @MessageTemplate("{not-type}")
38 | String notType();
39 |
40 | @MessageTemplate("{put-key}")
41 | String putKey();
42 |
43 | @MessageTemplate("{not-jwt}")
44 | String notJwt();
45 |
46 | @MessageTemplate("{type-server}")
47 | String typeServer(String text);
48 |
49 | @MessageTemplate("{primary-key}")
50 | String primaryKey(String text);
51 |
52 | @MessageTemplate("{public-key}")
53 | String publicKey(String text);
54 |
55 | @MessageTemplate("{age-token}")
56 | String ageToken(String text);
57 |
58 | @MessageTemplate("{issuer}")
59 | String issuer(String text);
60 |
61 | @MessageTemplate("{audience}")
62 | String audience(String text);
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/main/resources/org/demoiselle/jee/security/message/DemoiselleSecurityJWTMessages.properties:
--------------------------------------------------------------------------------
1 | general=Erro na gera\u00e7\u00e3o do token, verifique as configura\u00e7\u00f5es, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
2 | expired=Token inv\u00e1lido
3 | error=Erro
4 | master=master
5 | slave=slave
6 | not-jwt=Opera\u00e7\u00e3o n\u00e3o utilizada para JWT, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
7 | type-server=Type server: %s
8 | primary-key=Primary key: %s
9 | public-key=Public key: %s
10 | age-token=Age token in minutes: %s
11 | issuer=Issuer: %s
12 | audience=Audience: %s
13 | put-key=Coloque as chaves no arquivo demoiselle.properties, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
14 | choose-type=Escolha comportamento do servidor, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
15 | not-type=Os tipos de comportamento n\u00e3o encontrado, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/java/org/demoiselle/jee/security/jwt/impl/DemoiselleSecurityJWTMock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.jwt.impl;
8 |
9 | import java.io.Serializable;
10 | import org.demoiselle.jee.configuration.annotation.Configuration;
11 | import org.demoiselle.jee.configuration.annotation.ConfigurationSuppressLogger;
12 |
13 | /**
14 | *
15 | * @author SERPRO
16 | */
17 | @Configuration(prefix = "demoiselle.security.jwt", resource = "demoiselle")
18 | public class DemoiselleSecurityJWTMock implements Serializable {
19 |
20 | private static final long serialVersionUID = 638_435_989_235_076_782L;
21 |
22 | private String type;
23 |
24 | @ConfigurationSuppressLogger
25 | private String privateKey;
26 |
27 | private String publicKey;
28 |
29 | private Long timetoLiveMilliseconds;
30 |
31 | private String issuer;
32 |
33 | private String audience;
34 |
35 | private String algorithmIdentifiers;
36 |
37 | public String getType() {
38 | return type;
39 | }
40 |
41 | public String getPrivateKey() {
42 | return privateKey;
43 | }
44 |
45 | public String getPublicKey() {
46 | return publicKey;
47 | }
48 |
49 | public Long getTimetoLiveMilliseconds() {
50 | return timetoLiveMilliseconds;
51 | }
52 |
53 | public String getIssuer() {
54 | return issuer;
55 | }
56 |
57 | public String getAudience() {
58 | return audience;
59 | }
60 |
61 | public String getAlgorithmIdentifiers() {
62 | return algorithmIdentifiers;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/java/org/demoiselle/jee/security/jwt/impl/DemoiselleSecurityJWTMockError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.jwt.impl;
8 |
9 | import java.io.Serializable;
10 | import org.demoiselle.jee.configuration.annotation.Configuration;
11 | import org.demoiselle.jee.configuration.annotation.ConfigurationSuppressLogger;
12 |
13 | /**
14 | *
15 | * @author SERPRO
16 | */
17 | @Configuration(prefix = "demoiselle.security.jwt", resource = "demoiselleError")
18 | public class DemoiselleSecurityJWTMockError implements Serializable {
19 |
20 | private static final long serialVersionUID = 638_435_989_235_076_782L;
21 |
22 | private String type;
23 |
24 | @ConfigurationSuppressLogger
25 | private String privateKey;
26 |
27 | private String publicKey;
28 |
29 | private Long timetoLiveMilliseconds;
30 |
31 | private String issuer;
32 |
33 | private String audience;
34 |
35 | private String algorithmIdentifiers;
36 |
37 | public String getType() {
38 | return type;
39 | }
40 |
41 | public String getPrivateKey() {
42 | return privateKey;
43 | }
44 |
45 | public String getPublicKey() {
46 | return publicKey;
47 | }
48 |
49 | public Long getTimetoLiveMilliseconds() {
50 | return timetoLiveMilliseconds;
51 | }
52 |
53 | public String getIssuer() {
54 | return issuer;
55 | }
56 |
57 | public String getAudience() {
58 | return audience;
59 | }
60 |
61 | public String getAlgorithmIdentifiers() {
62 | return algorithmIdentifiers;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | # To change this license header, choose License Headers in Project Properties.
2 | # To change this template file, choose Tools | Templates
3 | # and open the template in the editor.
4 | demoiselle.security.jwt.type=master
5 | demoiselle.security.jwt.privateKey=-----BEGIN PRIVATE KEY-----MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDT0DXVlqqanlkFM4LGAnyqq0eFvpv5470LyABfcNcUiV9yXQVTsVXB9C0da43cpTzdzWxKP3A8y6+Ia9l5JXuhSnYNcwvvoSwQp/2v7ok1lF2dMKRdmSVBISZ65+1LGcy0DCjuT54iA+k4itikwm/kbNWO7TNvK5yfBtCcO+ga/TykyttZoY7FycdcJrOytFMjtQpD6O8wMHduxRwgjRdL73ZktCSIyQofzkdJKWbgAUq5SWNGHn1GWkmsINz5NRlZC44LouL8f3/vy0BbyQkgd8BImGQqCRx0aLEEk2CCn4r7SExa/Eu3l+LUFe9aLL8xrdA0e3E4KitFr7g0EH4rAgMBAAECggEABhUilqGfAJWvhMC37qu/nL8SbLrOi9yIX0A9EoCRDJvtS8F0F7Ut+0Xhzch66G0uVEhD5dXwiS5oOgiu1BXJeRZEUZqOKzF7rHbGiDjXY9yA27S745w0P6yOCFWEsPVqtXjr6/wJVHy8Q81o70JOKEcf0tzo7zZXZxGxB+uIfM3ffGNixX/tOHOERSViBvJsBp7sPZOPdgFQy1yQzYHDHob3V7BoG3bL/6ZXBIKMovBcKPoZuHDSyU1w3UbkFpPf8NbElPeMVoPxSwT1e3gfkKwBdp3bXucUnWBJE/aEkpUuIPTHiI4oGJDapmybLx+UACqp3eid48IDC25qXIq/8QKBgQD2yuECo9mKvP6CAZTl9LUUqYqwf4HLqgzOcCzDdigJaF08jLkI+9c7kMhq5C3R+VpRXCMJVHQSOEyUaOEj/m4QrF2JmfGcLxhqnDm8kZ84nX5anBxASCVcyiM2A37fpXmohczzu+Re8VFbFIMC1qJa5r/7/whmc5UL2jBVbQ7kPwKBgQDbtz6RlZWWnlJh1Dk6PuNczhmjbNRctrsVc2RcvIuZrw3BPGbeFanJVDa9Q9n2owxMs6BoSgIfrf0XGnl71yTSKtCliMyTgxg27g8iVlLA5YPaTIsazScCzLMOJmfzP2RcDBMVg+42Zu2tHhOoRAyNIpM7PQBDk1rLbpBH/HL7FQKBgGwvSW3317BK4yKogNZBbHPvUn3Gl2ZpWA3S/Lx+elSNbHnTknWOuK5C7Kh2+GMYdPA/fJhlbjBif6d7Rl6Z9TPX63Ubh9+YgZKSg3jXOT3/RFmCH5xKRB6l+cN+yspNZsRqSwr5bcX08V4E4t2Gq0s/5h8YkF0hA9BbSF7aXPHPAoGBAJ8m7TunjuO7axFSGOIIC8l9wTSP8IP4GSxAmcJTEQwRsXT3u8vDBWnAhqYyMABnutEUjGz+rusjrOC/XKBIB3P1b414ujdgDno7ltrYjLkNh6TpLRoM4OU2Qb1ONJ4OnTPPy0MafcMKa7+qubJ5GF5jXSLb3QUWB/6z5+88/kzBAoGAWzcBjuAYmRa+Q9GpGRyml1SgS0foaKwycN9Az0IGaNmN+hvKBgoJtUvY5V/sDdNAbLz+1Hpc0s3TJpghmHTVxUrC0VKqhEyXpHIUN2IOjiqoiQbB1stW0GS3N9U4akQfYQrR7u+IcUizfs6OQTmTR3Xp6LryES/rLn0vwZKZIvo=-----END PRIVATE KEY-----
6 | demoiselle.security.jwt.publicKey=-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA09A11Zaqmp5ZBTOCxgJ8qqtHhb6b+eO9C8gAX3DXFIlfcl0FU7FVwfQtHWuN3KU83c1sSj9wPMuviGvZeSV7oUp2DXML76EsEKf9r+6JNZRdnTCkXZklQSEmeuftSxnMtAwo7k+eIgPpOIrYpMJv5GzVju0zbyucnwbQnDvoGv08pMrbWaGOxcnHXCazsrRTI7UKQ+jvMDB3bsUcII0XS+92ZLQkiMkKH85HSSlm4AFKuUljRh59RlpJrCDc+TUZWQuOC6Li/H9/78tAW8kJIHfASJhkKgkcdGixBJNggp+K+0hMWvxLt5fi1BXvWiy/Ma3QNHtxOCorRa+4NBB+KwIDAQAB-----END PUBLIC KEY-----
7 | demoiselle.security.jwt.timetoLiveMilliseconds=9999999999
8 | demoiselle.security.jwt.issuer=STORE
9 | demoiselle.security.jwt.audience=web
10 | demoiselle.security.jwt.algorithmIdentifiers=RS256
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/resources/demoiselleError.properties:
--------------------------------------------------------------------------------
1 | # To change this license header, choose License Headers in Project Properties.
2 | # To change this template file, choose Tools | Templates
3 | # and open the template in the editor.
4 | demoiselle.security.jwt.type=master
5 | demoiselle.security.jwt.privateKey=-----BEGIN PRIVATE KEY-----MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDT0DXVlqqanlkFM4LGAnyqq0eFvpv5470LyABfcNcUiV9yXQVTsVXB9C0da43cpTzdzWxKP3A8y6+Ia9l5JXuhSnYNcwvvoSwQp/2v7ok1lF2dMKRdmSVBISZ65+1LGcy0DCjuT54iA+k4itikwm/kbNWO7TNvK5yfBtCcO+ga/TykyttZoY7FycdcJrOytFMjtQpD6O8wMHduxRwgjRdL73ZktCSIyQofzkdJKWbgAUq5SWNGHn1GWkmsINz5NRlZC44LouL8f3/vy0BbyQkgd8BImGQqCRx0aLEEk2CCn4r7SExa/Eu3l+LUFe9aLL8xrdA0e3E4KitFr7g0EH4rAgMBAAECggEABhUilqGfAJWvhMC37qu/nL8SbLrOi9yIX0A9EoCRDJvtS8F0F7Ut+0Xhzch66G0uVEhD5dXwiS5oOgiu1BXJeRZEUZqOKzF7rHbGiDjXY9yA27S745w0P6yOCFWEsPVqtXjr6/wJVHy8Q81o70JOKEcf0tzo7zZXZxGxB+uIfM3ffGNixX/tOHOERSViBvJsBp7sPZOPdgFQy1yQzYHDHob3V7BoG3bL/6ZXBIKMovBcKPoZuHDSyU1w3UbkFpPf8NbElPeMVoPxSwT1e3gfkKwBdp3bXucUnWBJE/aEkpUuIPTHiI4oGJDapmybLx+UACqp3eid48IDC25qXIq/8QKBgQD2yuECo9mKvP6CAZTl9LUUqYqwf4HLqgzOcCzDdigJaF08jLkI+9c7kMhq5C3R+VpRXCMJVHQSOEyUaOEj/m4QrF2JmfGcLxhqnDm8kZ84nX5anBxASCVcyiM2A37fpXmohczzu+Re8VFbFIMC1qJa5r/7/whmc5UL2jBVbQ7kPwKBgQDbtz6RlZWWnlJh1Dk6PuNczhmjbNRctrsVc2RcvIuZrw3BPGbeFanJVDa9Q9n2owxMs6BoSgIfrf0XGnl71yTSKtCliMyTgxg27g8iVlLA5YPaTIsazScCzLMOJmfzP2RcDBMVg+42Zu2tHhOoRAyNIpM7PQBDk1rLbpBH/HL7FQKBgGwvSW3317BK4yKogNZBbHPvUn3Gl2ZpWA3S/Lx+elSNbHnTknWOuK5C7Kh2+GMYdPA/fJhlbjBif6d7Rl6Z9TPX63Ubh9+YgZKSg3jXOT3/RFmCH5xKRB6l+cN+yspNZsRqSwr5bcX08V4E4t2Gq0s/5h8YkF0hA9BbSF7aXPHPAoGBAJ8m7TunjuO7axFSGOIIC8l9wTSP8IP4GSxAmcJTEQwRsXT3u8vDBWnAhqYyMABnutEUjGz+rusjrOC/XKBIB3P1b414ujdgDno7ltrYjLkNh6TpLRoM4OU2Qb1ONJ4OnTPPy0MafcMKa7+qubJ5GF5jXSLb3QUWB/6z5+88/kzBAoGAWzcBjuAYmRa+Q9GpGRyml1SgS0foaKwycN9Az0IGaNmN+hvKBgoJtUvY5V/sDdNAbLz+1Hpc0s3TJpghmHTVxUrC0VKqhEyXpHIUN2IOjiqoiQbB1stW0GS3N9U4akQfYQrR7u+IcUizfs6OQTmTR3Xp6LryES/rLn0vwZKZIvo=-----END PRIVATE KEY-----
6 | demoiselle.security.jwt.publicKey=-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA09A11Zaqmp5ZBTOCxgJ8qqtHhb6b+eO9C8gAX3DXFIlfcl0FU7FVwfQtHWuN3KU83c1sSj9wPMuviGvZeSV7oUp2DXML76EsEKf9r+6JNZRdnTCkXZklQSEmeuftSxnMtAwo7k+eIgPpOIrYpMJv5GzVju0zbyucnwbQnDvoGv08pMrbWaGOxcnHXCazsrRTI7UKQ+jvMDB3bsUcII0XS+92ZLQkiMkKH85HSSlm4AFKuUljRh59RlpJrCDc+TUZWQuOC6Li/H9/78tAW8kJIHfASJhkKgkcdGixBJNggp+K+0hMWvxLt5fi1BXvWiy/Ma3QNHtxOCorRa+4NBB+KwIDAQAB-----END PUBLIC KEY-----
7 | demoiselle.security.jwt.timetoLiveMilliseconds=9999999999
8 | demoiselle.security.jwt.issuer=STORE
9 | demoiselle.security.jwt.audience=web
10 | demoiselle.security.jwt.algorithmIdentifiers=RS256
--------------------------------------------------------------------------------
/demoiselle-security-jwt/src/test/resources/org/demoiselle/jee/security/message/DemoiselleSecurityJWTMessages.properties:
--------------------------------------------------------------------------------
1 | general=Erro na gera\u00e7\u00e3o do token, verifique as configura\u00e7\u00f5es, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
2 | expired=Token inv\u00e1lido
3 | error=Erro
4 | master=master
5 | slave=slave
6 | not-jwt=Opera\u00e7\u00e3o n\u00e3o utilizada para JWT, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
7 | type-server=Type server: %s
8 | primary-key=Primary key: %s
9 | public-key=Public key: %s
10 | age-token=Age token in minutes: %s
11 | issuer=Issuer: %s
12 | audience=Audience: %s
13 | put-key=Coloque as chaves no arquivo demoiselle.properties, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
14 | choose-type=Escolha comportamento do servidor, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
15 | not-type=Os tipos de comportamento n\u00e3o encontrado, https://demoiselle.gitbooks.io/documentacao-jee/content/jwt.html
--------------------------------------------------------------------------------
/demoiselle-security-token/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | .iml
5 | /target/
6 | /bin/
7 |
--------------------------------------------------------------------------------
/demoiselle-security-token/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | demoiselle-security-token
5 | jar
6 |
7 | Demoiselle JEE Security Token
8 |
9 | Demoiselle Security Token
10 |
11 | http://demoiselle.io
12 |
13 |
14 | org.demoiselle.jee
15 | demoiselle-parent
16 | 3.0.6-SNAPSHOT
17 | ../demoiselle-parent
18 |
19 |
20 |
21 | org.demoiselle.jee
22 | demoiselle-security
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/demoiselle-security-token/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security-token/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .classpath
3 | .project
4 | /target/
5 | /bin/
6 |
--------------------------------------------------------------------------------
/demoiselle-security/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | demoiselle-security
5 | jar
6 |
7 | Demoiselle JEE Security
8 |
9 | Demoiselle Security
10 |
11 | http://demoiselle.io
12 |
13 |
14 | org.demoiselle.jee
15 | demoiselle-parent
16 | 3.0.6-SNAPSHOT
17 | ../demoiselle-parent
18 |
19 |
20 |
21 | org.demoiselle.jee
22 | demoiselle-rest
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/DemoiselleSecurityConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security;
8 |
9 | import java.util.Map;
10 | import java.util.concurrent.ConcurrentHashMap;
11 |
12 | import org.demoiselle.jee.configuration.annotation.Configuration;
13 |
14 | /**
15 | *
16 | * @author SERPRO
17 | */
18 | @Configuration(prefix = "demoiselle.security")
19 | public class DemoiselleSecurityConfig {
20 |
21 | private boolean corsEnabled;
22 |
23 | private final Map paramsHeaderSecuriry = new ConcurrentHashMap<>();
24 | private final Map paramsHeaderCors = new ConcurrentHashMap<>();
25 |
26 | public boolean isCorsEnabled() {
27 | return corsEnabled;
28 | }
29 |
30 | public Map getParamsHeaderSecuriry() {
31 | return paramsHeaderSecuriry;
32 | }
33 |
34 | public Map getParamsHeaderCors() {
35 | return paramsHeaderCors;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/annotation/Authenticated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Inherited;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | import javax.enterprise.util.Nonbinding;
18 | import javax.interceptor.InterceptorBinding;
19 |
20 | /**
21 | *
22 | * Indicates that a authentication is required
23 | *
24 | * @see Documentation
25 | *
26 | * @author SERPRO
27 | */
28 | @Inherited
29 | @InterceptorBinding
30 | @Target({METHOD, TYPE})
31 | @Retention(RUNTIME)
32 | public @interface Authenticated {
33 |
34 | @Nonbinding
35 | boolean enable() default true;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/annotation/Cors.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Inherited;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | import javax.enterprise.util.Nonbinding;
18 | import javax.interceptor.InterceptorBinding;
19 |
20 | /**
21 | *
22 | * Server cors handling
23 | *
24 | *
25 | * @see Documentation
26 | * @author SERPRO
27 | */
28 | @Inherited
29 | @InterceptorBinding
30 | @Target({METHOD, TYPE})
31 | @Retention(RUNTIME)
32 | public @interface Cors {
33 |
34 | @Nonbinding
35 | boolean enable() default true;
36 | }
37 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/annotation/RequiredPermission.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Inherited;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | import javax.enterprise.util.Nonbinding;
18 | import javax.interceptor.InterceptorBinding;
19 |
20 | /**
21 | *
22 | * Indicates that a specific permission is required in order to invocate the
23 | * annotated method or class.
24 | *
25 | *
26 | * @see Documentation
27 | * @author SERPRO
28 | */
29 | @Inherited
30 | @InterceptorBinding
31 | @Target({METHOD, TYPE})
32 | @Retention(RUNTIME)
33 | public @interface RequiredPermission {
34 |
35 | @Nonbinding
36 | String resource() default "";
37 |
38 | @Nonbinding
39 | String operation() default "";
40 | }
41 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/annotation/RequiredRole.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.annotation;
8 |
9 | import static java.lang.annotation.ElementType.METHOD;
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | import java.lang.annotation.Inherited;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | import javax.enterprise.util.Nonbinding;
18 | import javax.interceptor.InterceptorBinding;
19 |
20 | /**
21 | *
22 | * Indicates that the annotated method or class requires the user to have one or
23 | * more roles associated in order to be invocated.
24 | *
25 | *
26 | * @see Documentation
27 | * @author SERPRO
28 | */
29 | @Inherited
30 | @InterceptorBinding
31 | @Target({METHOD, TYPE})
32 | @Retention(RUNTIME)
33 | public @interface RequiredRole {
34 |
35 | @Nonbinding
36 | String[] value();
37 | }
38 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/exception/DemoiselleSecurityException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.exception;
8 |
9 | import javax.ws.rs.core.Response.Status;
10 |
11 | import org.demoiselle.jee.rest.exception.DemoiselleRestException;
12 |
13 | /**
14 | *
15 | * @author SERPRO
16 | */
17 | public class DemoiselleSecurityException extends DemoiselleRestException {
18 |
19 | private static final long serialVersionUID = 519_965_615_171_844_237L;
20 |
21 | public DemoiselleSecurityException(String string) {
22 | super(string);
23 | this.statusCode = Status.INTERNAL_SERVER_ERROR.getStatusCode();
24 | }
25 |
26 | public DemoiselleSecurityException(String string, int statusCode) {
27 | super(string);
28 | this.statusCode = statusCode;
29 | }
30 |
31 | public DemoiselleSecurityException(String string, int statusCode, Exception ex) {
32 | super(string);
33 | this.statusCode = statusCode;
34 | }
35 |
36 | @Override
37 | public int getStatusCode() {
38 | return statusCode;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/filter/CorsFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.filter;
8 |
9 | import java.io.IOException;
10 | import java.lang.reflect.Method;
11 | import javax.annotation.Priority;
12 |
13 | import javax.inject.Inject;
14 | import static javax.ws.rs.Priorities.AUTHORIZATION;
15 | import javax.ws.rs.container.ContainerRequestContext;
16 | import javax.ws.rs.container.ContainerResponseContext;
17 | import javax.ws.rs.container.ContainerResponseFilter;
18 | import javax.ws.rs.container.ResourceInfo;
19 | import javax.ws.rs.core.Context;
20 | import javax.ws.rs.ext.Provider;
21 |
22 | import org.demoiselle.jee.security.DemoiselleSecurityConfig;
23 | import org.demoiselle.jee.security.annotation.Cors;
24 |
25 | /**
26 | *
27 | * Server cors handling
28 | *
29 | *
30 | * @see
31 | * Documentation
32 | *
33 | * @author SERPRO
34 | */
35 | @Provider
36 | @Priority(AUTHORIZATION)
37 | public class CorsFilter implements ContainerResponseFilter {
38 |
39 | @Inject
40 | private DemoiselleSecurityConfig config;
41 |
42 | @Context
43 | private ResourceInfo info;
44 |
45 | @Override
46 | public void filter(ContainerRequestContext req, ContainerResponseContext res) throws IOException {
47 | Method method = info.getResourceMethod();
48 | Class> classe = info.getResourceClass();
49 | boolean corsEnable = config.isCorsEnabled();
50 |
51 | res.getHeaders().putSingle("Demoiselle-security", "Enable");
52 |
53 | config.getParamsHeaderSecuriry().entrySet().stream().forEach((entry) -> {
54 | res.getHeaders().putSingle(entry.getKey(), entry.getValue());
55 | });
56 |
57 | if (method != null && classe != null && method.getAnnotation(Cors.class) != null) {
58 | corsEnable = method.getAnnotation(Cors.class).enable();
59 | }
60 |
61 | if (config.isCorsEnabled() && corsEnable) {
62 | config.getParamsHeaderCors().entrySet().stream().forEach((entry) -> {
63 | res.getHeaders().putSingle(entry.getKey(), entry.getValue());
64 | });
65 | } else {
66 | res.getHeaders().remove("Access-Control-Allow-Origin");
67 | res.getHeaders().remove("Access-Control-Allow-Methods");
68 | }
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/filter/SecurityFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.filter;
8 |
9 | import static javax.ws.rs.core.Response.ok;
10 |
11 | import java.io.IOException;
12 | import java.util.logging.Logger;
13 |
14 | import javax.annotation.Priority;
15 | import javax.inject.Inject;
16 | import static javax.ws.rs.Priorities.AUTHORIZATION;
17 | import javax.ws.rs.container.ContainerRequestContext;
18 | import javax.ws.rs.container.ContainerRequestFilter;
19 | import javax.ws.rs.container.PreMatching;
20 | import javax.ws.rs.core.Response;
21 | import javax.ws.rs.ext.Provider;
22 |
23 | import org.demoiselle.jee.core.api.security.Token;
24 | import org.demoiselle.jee.core.api.security.TokenType;
25 | import org.demoiselle.jee.security.DemoiselleSecurityConfig;
26 |
27 | /**
28 | *
29 | * Server cors handling
30 | *
31 | *
32 | * @see
33 | * Documentation
34 | *
35 | * @author SERPRO
36 | */
37 | @Provider
38 | @PreMatching
39 | @Priority(AUTHORIZATION)
40 | public class SecurityFilter implements ContainerRequestFilter {
41 |
42 | private static final Logger logger = Logger.getLogger(SecurityFilter.class.getName());
43 |
44 | @Inject
45 | private DemoiselleSecurityConfig config;
46 |
47 | @Inject
48 | private Token token;
49 |
50 | @Override
51 | public void filter(ContainerRequestContext req) throws IOException {
52 | if (req.getMethod().equals("OPTIONS")) {
53 | Response.ResponseBuilder responseBuilder = ok();
54 | if (config.isCorsEnabled()) {
55 | config.getParamsHeaderSecuriry().entrySet().stream().forEach((entry) -> {
56 | responseBuilder.header(entry.getKey(), entry.getValue());
57 | });
58 | }
59 | req.abortWith(responseBuilder.build());
60 | }
61 |
62 | try {
63 | if (req.getHeaders().containsKey("Authorization")) {
64 | String chave = req.getHeaders().get("Authorization").toString().replace("[", "").replace("]", "");
65 | if (!chave.isEmpty()) {
66 | token.setType(TokenType.valueOf(chave.split(" ")[0].toUpperCase()));
67 | token.setKey(chave.split(" ")[1]);
68 | }
69 | }
70 | } catch (Exception e) {
71 | logger.severe(e.getMessage());
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/impl/SecurityContextImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.impl;
8 |
9 | import java.util.List;
10 |
11 | import javax.enterprise.context.RequestScoped;
12 | import javax.inject.Inject;
13 |
14 | import org.demoiselle.jee.core.api.security.DemoiselleUser;
15 | import org.demoiselle.jee.core.api.security.SecurityContext;
16 | import org.demoiselle.jee.core.api.security.TokenManager;
17 |
18 | /**
19 | *
20 | * It manages the security features and serves as a hub for specific
21 | * imlementations, look at JWT and Token
22 | *
23 | *
24 | * @see Documentation
25 | *
26 | * @author SERPRO
27 | */
28 | @RequestScoped
29 | public class SecurityContextImpl implements SecurityContext {
30 |
31 | @Inject
32 | private TokenManager tm;
33 |
34 | @Override
35 | public boolean hasPermission(String resource, String operation) {
36 |
37 | List list = getUser().getPermissions().get(resource);
38 |
39 | if (list != null && !list.isEmpty()) {
40 | return list.contains(operation);
41 | }
42 |
43 | return false;
44 | }
45 |
46 | @Override
47 | public boolean hasRole(String role) {
48 | return getUser().getRoles().contains(role);
49 | }
50 |
51 | @Override
52 | public boolean isLoggedIn() {
53 | return tm.validate();
54 | }
55 |
56 | @Override
57 | public DemoiselleUser getUser() {
58 | return tm.getUser();
59 | }
60 |
61 | @Override
62 | public void setUser(DemoiselleUser loggedUser) {
63 | tm.setUser(loggedUser);
64 | }
65 |
66 | @Override
67 | public DemoiselleUser getUser(String issuer, String audience) {
68 | return tm.getUser(issuer, audience);
69 | }
70 |
71 | @Override
72 | public void setUser(DemoiselleUser loggedUser, String issuer, String audience) {
73 | tm.setUser(loggedUser, issuer, audience);
74 | }
75 |
76 | @Override
77 | public void removeUser(DemoiselleUser loggedUser) {
78 | tm.removeUser(loggedUser);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/impl/TokenImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.impl;
8 |
9 | import java.util.Objects;
10 |
11 | import javax.enterprise.context.RequestScoped;
12 |
13 | import org.demoiselle.jee.core.api.security.Token;
14 | import org.demoiselle.jee.core.api.security.TokenType;
15 |
16 | /**
17 | *
18 | * Object loaded to each request containing the token sent in http header
19 | *
20 | *
21 | * @see
22 | * Documentation
23 | *
24 | * @author SERPRO
25 | */
26 | @RequestScoped
27 | public class TokenImpl implements Token {
28 |
29 | private String key;
30 | private TokenType type;
31 |
32 | @Override
33 | public String getKey() {
34 | return key;
35 | }
36 |
37 | @Override
38 | public void setKey(String key) {
39 | this.key = key;
40 | }
41 |
42 | @Override
43 | public TokenType getType() {
44 | return type;
45 | }
46 |
47 | @Override
48 | public void setType(TokenType type) {
49 | this.type = type;
50 | }
51 |
52 | @Override
53 | public int hashCode() {
54 | int hash = 5;
55 | hash = 23 * hash + Objects.hashCode(this.key);
56 | return hash;
57 | }
58 |
59 | @Override
60 | public boolean equals(Object obj) {
61 | if (this == obj) {
62 | return true;
63 | }
64 | if (obj == null) {
65 | return false;
66 | }
67 | if (getClass() != obj.getClass()) {
68 | return false;
69 | }
70 | final TokenImpl other = (TokenImpl) obj;
71 | return Objects.equals(this.key, other.key);
72 | }
73 |
74 | @Override
75 | public String toString() {
76 | return "{" + "\"key\":\"" + key + "\", \"type\":\"" + type.toString() + "\"}";
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/interceptor/AuthenticatedInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.interceptor;
8 |
9 | import java.io.Serializable;
10 |
11 | import javax.annotation.Priority;
12 | import javax.inject.Inject;
13 | import javax.interceptor.AroundInvoke;
14 | import javax.interceptor.Interceptor;
15 | import javax.interceptor.InvocationContext;
16 | import static javax.ws.rs.core.Response.Status.FORBIDDEN;
17 |
18 | import org.demoiselle.jee.core.api.security.SecurityContext;
19 | import org.demoiselle.jee.security.annotation.Authenticated;
20 | import org.demoiselle.jee.security.exception.DemoiselleSecurityException;
21 | import org.demoiselle.jee.security.message.DemoiselleSecurityMessages;
22 |
23 | /**
24 | *
25 | * Intercepts calls with {@link Authenticated} annotations.
26 | *
27 | *
28 | * @author SERPRO
29 | */
30 | @Authenticated
31 | @Interceptor
32 | @Priority(Interceptor.Priority.APPLICATION)
33 | public class AuthenticatedInterceptor implements Serializable {
34 |
35 | private static final long serialVersionUID = 1L;
36 |
37 | @Inject
38 | private SecurityContext securityContext;
39 |
40 | @Inject
41 | private DemoiselleSecurityMessages bundle;
42 |
43 | @AroundInvoke
44 | public Object manage(final InvocationContext ic) throws Exception {
45 | Authenticated logged = ic.getMethod().getAnnotation(Authenticated.class);
46 |
47 | if (logged != null && !logged.enable()) {
48 | return ic.proceed();
49 | }
50 |
51 | if (!securityContext.isLoggedIn()) {
52 | throw new DemoiselleSecurityException(bundle.userNotAuthenticated(), FORBIDDEN.getStatusCode());
53 | }
54 |
55 | return ic.proceed();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/java/org/demoiselle/jee/security/message/DemoiselleSecurityMessages.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.message;
8 |
9 | import org.apache.deltaspike.core.api.message.MessageBundle;
10 | import org.apache.deltaspike.core.api.message.MessageTemplate;
11 |
12 | /**
13 | *
14 | * @author SERPRO
15 | */
16 | @MessageBundle
17 | public interface DemoiselleSecurityMessages {
18 |
19 | @MessageTemplate("{access-checking-permission}")
20 | String accessCheckingPermission(String operacao, String recurso);
21 |
22 | @MessageTemplate("{access-denied}")
23 | String accessDenied(String usuario, String operacao, String recurso);
24 |
25 | @MessageTemplate("{user-not-authenticated}")
26 | String userNotAuthenticated();
27 |
28 | @MessageTemplate("{invalid-credentials}")
29 | String invalidCredentials();
30 |
31 | @MessageTemplate("{does-not-have-role}")
32 | String doesNotHaveRole(String role);
33 |
34 | @MessageTemplate("{does-not-have-permission}")
35 | String doesNotHavePermission(String operacao, String recurso);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.security.corsEnabled=false
2 |
--------------------------------------------------------------------------------
/demoiselle-security/src/main/resources/org/demoiselle/jee/security/message/DemoiselleSecurityMessages.properties:
--------------------------------------------------------------------------------
1 | access-checking-permission=O usu\u00e1rio n\u00e3o tem permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
2 | access-checking-role=Verificando permiss\u00e3o do usu\u00e1rio %s para a role %s
3 | access-allowed=O usu\u00e1rio %s acessou o recurso %s com a a\u00e7\u00e3o %s
4 | access-denied=O usu\u00e1rio n\u00e3o possui permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
5 | user-not-authenticated=Usu\u00e1rio n\u00e3o autenticado
6 | invalid-credentials=Usu\u00e1rio ou senha inv\u00e1lidos
7 | does-not-have-role=O Usu\u00e1rio n\u00e3o possui a role\:%s
8 | does-not-have-permission=O Usu\u00e1rio n\u00e3o possui a permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
9 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/DemoiselleSecurityConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import javax.inject.Inject;
12 |
13 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
14 | import org.junit.After;
15 | import org.junit.AfterClass;
16 | import org.junit.Before;
17 | import org.junit.BeforeClass;
18 | import org.junit.Test;
19 | import org.junit.runner.RunWith;
20 |
21 | /**
22 | *
23 | * @author SERPRO
24 | */
25 | @RunWith(CdiTestRunner.class)
26 | public class DemoiselleSecurityConfigTest {
27 |
28 | @Inject
29 | private DemoiselleSecurityConfig instance;
30 |
31 | @BeforeClass
32 | public static void setUpClass() {
33 | }
34 |
35 | @AfterClass
36 | public static void tearDownClass() {
37 | }
38 |
39 | public DemoiselleSecurityConfigTest() {
40 | }
41 |
42 | @Before
43 | public void setUp() {
44 | }
45 |
46 | @After
47 | public void tearDown() {
48 | }
49 |
50 | /**
51 | * Test of isCorsEnabled method, of class DemoiselleSecurityConfig.
52 | */
53 | @Test
54 | public void test11() {
55 | boolean expResult = true;
56 | boolean result = instance.isCorsEnabled();
57 | assertEquals(expResult, result);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/exception/DemoiselleSecurityExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.exception;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import java.util.HashSet;
12 |
13 | import org.demoiselle.jee.rest.exception.DemoiselleRestExceptionMessage;
14 | import org.junit.After;
15 | import org.junit.AfterClass;
16 | import org.junit.Before;
17 | import org.junit.BeforeClass;
18 | import org.junit.Test;
19 |
20 | /**
21 | *
22 | * @author SERPRO
23 | */
24 | public class DemoiselleSecurityExceptionTest {
25 |
26 | @BeforeClass
27 | public static void setUpClass() {
28 | }
29 |
30 | @AfterClass
31 | public static void tearDownClass() {
32 | }
33 | private DemoiselleSecurityException instance;
34 |
35 | public DemoiselleSecurityExceptionTest() {
36 | }
37 |
38 | @Before
39 | public void setUp() {
40 | instance = new DemoiselleSecurityException("Teste");
41 | }
42 |
43 | @After
44 | public void tearDown() {
45 | }
46 |
47 | /**
48 | * Test of getStatusCode method, of class DemoiselleSecurityException.
49 | */
50 | @Test
51 | public void testGetStatusCode() {
52 | int expResult = 500;
53 | int result = instance.getStatusCode();
54 | assertEquals(expResult, result);
55 | }
56 |
57 | /**
58 | * Test of addMessage method, of class DemoiselleSecurityException.
59 | */
60 | @Test
61 | public void testAddMessage() {
62 | instance = new DemoiselleSecurityException("Teste", 500);
63 | String field = "Teste";
64 | String msg = "Teste";
65 | instance.addMessage(field, msg);
66 | }
67 |
68 | /**
69 | * Test of getMessages method, of class DemoiselleSecurityException.
70 | */
71 | @Test
72 | public void testGetMessages() {
73 | HashSet expResult = new HashSet<>();
74 | HashSet result = instance.getMessages();
75 | assertEquals(expResult, result);
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/impl/TokenImplTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.impl;
8 |
9 | import static org.junit.Assert.assertEquals;
10 | import static org.junit.Assert.assertNotEquals;
11 |
12 | import javax.enterprise.context.RequestScoped;
13 | import javax.inject.Inject;
14 |
15 | import org.apache.deltaspike.testcontrol.api.TestControl;
16 | import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
17 | import org.demoiselle.jee.core.api.security.Token;
18 | import org.demoiselle.jee.core.api.security.TokenType;
19 | import org.junit.After;
20 | import org.junit.AfterClass;
21 | import org.junit.Before;
22 | import org.junit.BeforeClass;
23 | import org.junit.Test;
24 | import org.junit.runner.RunWith;
25 |
26 | /**
27 | *
28 | * @author SERPRO
29 | */
30 | @RunWith(CdiTestRunner.class)
31 | @TestControl(startScopes = RequestScoped.class)
32 | public class TokenImplTest {
33 |
34 | @BeforeClass
35 | public static void setUpClass() {
36 | }
37 |
38 | @AfterClass
39 | public static void tearDownClass() {
40 | }
41 |
42 | @Inject
43 | private Token instance;
44 |
45 | public TokenImplTest() {
46 | }
47 |
48 | @Before
49 | public void setUp() {
50 | }
51 |
52 | @After
53 | public void tearDown() {
54 | }
55 |
56 | @Test
57 | public void test11() {
58 | String key = "123456789";
59 | instance.setKey(key);
60 | }
61 |
62 | @Test
63 | public void test12() {
64 | String expResult = "123456789";
65 | String result = instance.getKey();
66 | assertEquals(expResult, result);
67 | }
68 |
69 | @Test
70 | public void test13() {
71 | instance.setType(TokenType.JWT);
72 | }
73 |
74 | @Test
75 | public void test14() {
76 | TokenType expResult = TokenType.JWT;
77 | TokenType result = instance.getType();
78 | assertEquals(expResult, result);
79 | }
80 |
81 | @Test
82 | public void test15() {
83 | int expResult = 0;
84 | int result = instance.hashCode();
85 | assertNotEquals(expResult, result);
86 | }
87 |
88 | @Test
89 | public void test16() {
90 | Object obj = null;
91 | boolean expResult = false;
92 | boolean result = instance.equals(obj);
93 | assertEquals(expResult, result);
94 | }
95 |
96 | @Test
97 | public void test17() {
98 | String expResult = "{\"key\":\"123456789\", \"type\":\"JWT\"}";
99 | String result = instance.toString();
100 | assertEquals(expResult, result);
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/interceptor/LoggedInInterceptorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.interceptor;
8 |
9 |
10 | import org.junit.After;
11 | import org.junit.AfterClass;
12 | import org.junit.Before;
13 | import org.junit.BeforeClass;
14 |
15 |
16 | /**
17 | *
18 | * @author SERPRO
19 | */
20 | //@RunWith(CdiTestRunner.class)
21 | public class LoggedInInterceptorTest {
22 |
23 | // @Inject
24 | // private LoggedInInterceptor instance;
25 | @BeforeClass
26 | public static void setUpClass() {
27 | }
28 |
29 | @AfterClass
30 | public static void tearDownClass() {
31 | }
32 |
33 | public LoggedInInterceptorTest() {
34 | }
35 |
36 | @Before
37 | public void setUp() {
38 | }
39 |
40 | @After
41 | public void tearDown() {
42 | }
43 |
44 | //@Test
45 | public void testManage() throws Exception {
46 | // InvocationContext ic = null;
47 | // Object expResult = null;
48 | // Object result = instance.manage(ic);
49 | // assertEquals(expResult, result);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/interceptor/RequiredPermissionInterceptorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.interceptor;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import javax.interceptor.InvocationContext;
12 |
13 | import org.junit.After;
14 | import org.junit.AfterClass;
15 | import org.junit.Before;
16 | import org.junit.BeforeClass;
17 |
18 |
19 | /**
20 | *
21 | * @author SERPRO
22 | */
23 | //@RunWith(CdiTestRunner.class)
24 | public class RequiredPermissionInterceptorTest {
25 |
26 | @BeforeClass
27 | public static void setUpClass() {
28 | }
29 |
30 | @AfterClass
31 | public static void tearDownClass() {
32 | }
33 |
34 | public RequiredPermissionInterceptorTest() {
35 | }
36 |
37 | @Before
38 | public void setUp() {
39 | }
40 |
41 | @After
42 | public void tearDown() {
43 | }
44 |
45 | /**
46 | * Test of manage method, of class RequiredPermissionInterceptor.
47 | */
48 | //@Test
49 | public void testManage() throws Exception {
50 | InvocationContext ic = null;
51 | RequiredPermissionInterceptor instance = new RequiredPermissionInterceptor();
52 | Object expResult = null;
53 | Object result = instance.manage(ic);
54 | assertEquals(expResult, result);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/java/org/demoiselle/jee/security/interceptor/RequiredRoleInterceptorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Demoiselle Framework
3 | *
4 | * License: GNU Lesser General Public License (LGPL), version 3 or later.
5 | * See the lgpl.txt file in the root directory or .
6 | */
7 | package org.demoiselle.jee.security.interceptor;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | import javax.interceptor.InvocationContext;
12 |
13 | import org.junit.After;
14 | import org.junit.AfterClass;
15 | import org.junit.Before;
16 | import org.junit.BeforeClass;
17 |
18 |
19 |
20 | /**
21 | *
22 | * @author SERPRO
23 | */
24 | //@RunWith(CdiTestRunner.class)
25 | public class RequiredRoleInterceptorTest {
26 |
27 | @BeforeClass
28 | public static void setUpClass() {
29 | }
30 |
31 | @AfterClass
32 | public static void tearDownClass() {
33 | }
34 |
35 | public RequiredRoleInterceptorTest() {
36 | }
37 |
38 | @Before
39 | public void setUp() {
40 | }
41 |
42 | @After
43 | public void tearDown() {
44 | }
45 |
46 | /**
47 | * Test of manage method, of class RequiredRoleInterceptor.
48 | */
49 | //@Test
50 | public void testManage() throws Exception {
51 | InvocationContext ic = null;
52 | RequiredRoleInterceptor instance = new RequiredRoleInterceptor();
53 | Object expResult = null;
54 | Object result = instance.manage(ic);
55 | assertEquals(expResult, result);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/resources/demoiselle.properties:
--------------------------------------------------------------------------------
1 | demoiselle.security.corsEnabled=true
2 | demoiselle.security.paramsHeaderSecuriry= x-content-type-options=nosniff, x-frame-options=SAMEORIGIN, x-xss-protection=1; mode=block
3 |
--------------------------------------------------------------------------------
/demoiselle-security/src/test/resources/org/demoiselle/jee/security/message/DemoiselleSecurityMessages.properties:
--------------------------------------------------------------------------------
1 | access-checking-permission=O usu\u00e1rio n\u00e3o tem permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
2 | access-checking-role=Verificando permiss\u00e3o do usu\u00e1rio %s para a role %s
3 | access-allowed=O usu\u00e1rio %s acessou o recurso %s com a a\u00e7\u00e3o %s
4 | access-denied=O usu\u00e1rio n\u00e3o possui permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
5 | user-not-authenticated=Usu\u00e1rio n\u00e3o autenticado
6 | invalid-credentials=Usu\u00e1rio ou senha inv\u00e1lidos
7 | does-not-have-role=O Usu\u00e1rio n\u00e3o possui a role\:%s
8 | does-not-have-permission=O Usu\u00e1rio n\u00e3o possui a permiss\u00e3o para executar a a\u00e7\u00e3o %s no recurso %s
9 |
--------------------------------------------------------------------------------
/licence-lgpl/header-definitions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /*
6 | *
7 | */
8 | (\s|\t)*/\*.*$
9 | .*\*/(\s|\t)*$
10 | false
11 | true
12 | false
13 |
14 |
--------------------------------------------------------------------------------
/licence-lgpl/header.txt:
--------------------------------------------------------------------------------
1 | Demoiselle Framework
2 |
3 | License: GNU Lesser General Public License (LGPL), version 3 or later.
4 | See the lgpl.txt file in the root directory or .
--------------------------------------------------------------------------------