8
8
import org .picketlink .internal .CDIEventBridge ;
9
9
import org .picketlink .internal .EEJPAContextInitializer ;
10
10
11
- import javax .enterprise .context .ApplicationScoped ;
12
11
import javax .enterprise .inject .Instance ;
13
12
import javax .inject .Inject ;
14
13
import javax .persistence .EntityManager ;
36
35
* @author Shane Bryzak
37
36
* @author Pedro Igor
38
37
*/
39
- @ ApplicationScoped
40
38
public class IdentityManagementConfiguration {
41
39
42
40
private static final String DEFAULT_CONFIGURATION_NAME = "default" ;
@@ -60,57 +58,52 @@ public class IdentityManagementConfiguration {
60
58
61
59
private List <IdentityConfiguration > identityConfiguration ;
62
60
63
- @ Inject
64
- public void init () {
65
- if (this .identityConfiguration != null ) {
66
- throw new RuntimeException ("Identity Management Configuration already initialized." );
67
- }
68
-
69
- if (ROOT_LOGGER .isDebugEnabled ()) {
70
- ROOT_LOGGER .debugf ("Building identity management configuration." );
71
- }
61
+ /**
62
+ * <p>Returns all configurations produced by the application.</p>
63
+ *
64
+ * @return
65
+ */
66
+ List <IdentityConfiguration > getIdentityConfiguration () {
67
+ if (this .identityConfiguration == null ) {
68
+ if (ROOT_LOGGER .isDebugEnabled ()) {
69
+ ROOT_LOGGER .debugf ("Building identity management configuration." );
70
+ }
72
71
73
- List <IdentityConfiguration > configurations = new ArrayList <IdentityConfiguration >();
72
+ List <IdentityConfiguration > configurations = new ArrayList <IdentityConfiguration >();
74
73
75
- if (!this .identityConfigInstance .isUnsatisfied ()) {
76
- for (Iterator <IdentityConfiguration > iterator = this .identityConfigInstance .iterator (); iterator .hasNext (); ) {
77
- configurations .add (iterator .next ());
74
+ if (!this .identityConfigInstance .isUnsatisfied ()) {
75
+ for (Iterator <IdentityConfiguration > iterator = this .identityConfigInstance .iterator (); iterator .hasNext (); ) {
76
+ configurations .add (iterator .next ());
77
+ }
78
+ } else {
79
+ configurations .addAll (this .picketLinkExtension .getSecurityConfiguration ().getIdentityConfigurations ());
78
80
}
79
- } else {
80
- configurations .addAll (this .picketLinkExtension .getSecurityConfiguration ().getIdentityConfigurations ());
81
- }
82
81
83
- IdentityConfigurationBuilder builder ;
82
+ IdentityConfigurationBuilder builder ;
84
83
85
- if (configurations .isEmpty ()) {
86
- if (ROOT_LOGGER .isDebugEnabled ()) {
87
- ROOT_LOGGER .debugf ("IdentityConfiguration not provided by the application, creating a default IdentityConfigurationBuilder." );
88
- }
84
+ if (configurations .isEmpty ()) {
85
+ if (ROOT_LOGGER .isDebugEnabled ()) {
86
+ ROOT_LOGGER .debugf ("IdentityConfiguration not provided by the application, creating a default IdentityConfigurationBuilder." );
87
+ }
89
88
90
- builder = new IdentityConfigurationBuilder ();
91
- } else {
92
- if (ROOT_LOGGER .isDebugEnabled ()) {
93
- ROOT_LOGGER .debugf ("Found IdentityConfiguration from the environment. Creating a IdentityConfigurationBuilder with them." );
89
+ builder = new IdentityConfigurationBuilder ();
90
+ } else {
91
+ if (ROOT_LOGGER .isDebugEnabled ()) {
92
+ ROOT_LOGGER .debugf ("Found IdentityConfiguration from the environment. Creating a IdentityConfigurationBuilder with them." );
93
+ }
94
+
95
+ builder = new IdentityConfigurationBuilder (configurations );
94
96
}
95
97
96
- builder = new IdentityConfigurationBuilder (configurations );
97
- }
98
+ this .eventBridge .fireEvent (new IdentityConfigurationEvent (builder ));
98
99
99
- this .eventBridge .fireEvent (new IdentityConfigurationEvent (builder ));
100
+ if (!builder .isConfigured ()) {
101
+ configureDefaults (builder );
102
+ }
100
103
101
- if (!builder .isConfigured ()) {
102
- configureDefaults (builder );
104
+ this .identityConfiguration = builder .buildAll ();
103
105
}
104
106
105
- this .identityConfiguration = builder .buildAll ();
106
- }
107
-
108
- /**
109
- * <p>Returns all configurations produced by the application.</p>
110
- *
111
- * @return
112
- */
113
- List <IdentityConfiguration > getIdentityConfiguration () {
114
107
return this .identityConfiguration ;
115
108
}
116
109
0 commit comments