@@ -153,7 +153,7 @@ private void updatePassword(EntityStore entityStore) {
153153 Trace .info ("Pem file alias name :" + alias );
154154 connectToURLConfigureP12 (entityStore , filterName , alias );
155155 } catch (Exception e ) {
156- Trace .error ("Unable to add the pem key, ca and certificate from Environment variable" , e );
156+ Trace .error ("Unable to add the key and certificate from Environment variable" , e );
157157 }
158158 } else if (key .startsWith ("jwtsigncert_" )) {
159159 try {
@@ -164,7 +164,7 @@ private void updatePassword(EntityStore entityStore) {
164164 Trace .info ("Pem file alias name :" + alias );
165165 jwtSignConfigureP12 (entityStore , filterName , alias );
166166 } catch (Exception e ) {
167- Trace .error ("Unable to add the p12 from Environment variable" , e );
167+ Trace .error ("Unable to add the key and certificate from Environment variable" , e );
168168 }
169169 } else if (key .startsWith ("jwtverifycert_" )) {
170170 try {
@@ -173,7 +173,7 @@ private void updatePassword(EntityStore entityStore) {
173173 String alias = importPublicCertificate (certificate , entityStore );
174174 jwtVerifyConfigureCertificate (entityStore , filterName , alias );
175175 } catch (Exception e ) {
176- Trace .error ("Unable to add the p12 from Environment variable" , e );
176+ Trace .error ("Unable to add the certificate from Environment variable" , e );
177177 }
178178 }else if (key .startsWith ("gatewaytoplogycertandkey_" )) {
179179 try {
@@ -199,7 +199,7 @@ private void updatePassword(EntityStore entityStore) {
199199 }
200200 }
201201
202- Map <String , Map <String , String >> httpBasicObjs = parseCred (httpBasic );
202+ Map <String , Map <String , String >> httpBasicObjs = Util . parseCred (httpBasic );
203203 if (!httpBasicObjs .isEmpty ()) {
204204 for (Map .Entry <String , Map <String , String >> entry : httpBasicObjs .entrySet ()) {
205205 String filterName = entry .getKey ();
@@ -210,23 +210,23 @@ private void updatePassword(EntityStore entityStore) {
210210 }
211211 }
212212
213- Map <String , Map <String , String >> ldapObjs = parseCred (ldap );
213+ Map <String , Map <String , String >> ldapObjs = Util . parseCred (ldap );
214214 if (!ldapObjs .isEmpty ()) {
215215 for (Map .Entry <String , Map <String , String >> entry : ldapObjs .entrySet ()) {
216216 String filterName = entry .getKey ();
217217 Map <String , String > attributes = entry .getValue ();
218218 updateLdap (entityStore , attributes , filterName );
219219 }
220220 }
221- Map <String , Map <String , String >> jmsObjs = parseCred (jms );
221+ Map <String , Map <String , String >> jmsObjs = Util . parseCred (jms );
222222 if (!jmsObjs .isEmpty ()) {
223223 for (Map .Entry <String , Map <String , String >> entry : jmsObjs .entrySet ()) {
224224 String filterName = entry .getKey ();
225225 Map <String , String > attributes = entry .getValue ();
226226 updateJMS (entityStore , attributes , filterName );
227227 }
228228 }
229- Map <String , Map <String , String >> smtpObjs = parseCred (smtp );
229+ Map <String , Map <String , String >> smtpObjs = Util . parseCred (smtp );
230230 if (!smtpObjs .isEmpty ()) {
231231 for (Map .Entry <String , Map <String , String >> entry : smtpObjs .entrySet ()) {
232232 String filterName = entry .getKey ();
@@ -265,30 +265,7 @@ private Map<String, String> groupEnvVariables(Map<String, String> envValues, Str
265265 }
266266
267267
268- public Map <String , Map <String , String >> parseCred (Map <String , String > envMap ) {
269-
270- Map <String , Map <String , String >> values = new HashMap <>();
271- if (envMap != null && !envMap .isEmpty ()) {
272- Iterator <String > keyIterator = envMap .keySet ().iterator ();
273- while (keyIterator .hasNext ()) {
274- String key = keyIterator .next ();
275- String [] delimitedKeys = key .split ("_" );
276- String filterName ;
277- if (delimitedKeys .length == 3 ) {
278- filterName = delimitedKeys [1 ];
279- String attribute = delimitedKeys [2 ];
280- String value = envMap .get (key );
281- Map <String , String > attributes = values .get (filterName );
282- if (attributes == null ) {
283- attributes = new HashMap <>();
284- values .put (filterName , attributes );
285- }
286- attributes .put (attribute , value );
287- }
288- }
289- }
290- return values ;
291- }
268+
292269
293270 private void updatePasswordField (EntityStore entityStore , String shorthandKey , String fieldName , String
294271 value , Object secret ) {
@@ -683,6 +660,9 @@ private PKCS12 importCertAndKeyAndCA(EntityStore entityStore, String cert, Strin
683660 alias = certObj .getSerialNumber ().toString ();
684661 }
685662 PrivateKey privateKey = certHelper .parsePrivateKey (key );
663+ if ( privateKey == null ){
664+ throw new Exception ("Unable to parse a private key" );
665+ }
686666 Trace .info ("Certificate alias name : " + alias );
687667 String escapedAlias = ShorthandKeyFinder .escapeFieldValue (alias );
688668 Entity certEntity = getCertEntity (entityStore , escapedAlias );
@@ -717,7 +697,6 @@ private PKCS12 importCertAndKeyAndCA(EntityStore entityStore, String cert, Strin
717697 importPublicCertificate (x509Certificate , entityStore );
718698 Trace .info ("Imported root / intermediate certificate" );
719699 }
720- //handle CA Certificate chain
721700 }
722701 pkcs12 .setAlias (alias );
723702 pkcs12 .setPrivateKey (privateKey );
@@ -735,20 +714,14 @@ private void updateCassandraConsistencyLevel(EntityStore entityStore, String rea
735714 // Update KPS table consistency level
736715 updateCassandraConsistencyLevel (shorthandKeyFinder , "/[KPSRoot]name=Key Property Stores/[KPSPackage]**/[KPSDataSourceGroup]**/[KPSCassandraDataSource]name=Cassandra Storage" ,
737716 "readConsistencyLevel" , readConsistencyLevel , "writeConsistencyLevel" , writeConsistencyLevel );
738- // Update OAUTH table consistency level
739- // updateCassandraConsistencyLevel(shorthandKeyFinder, "/[KPSRoot]name=Key Property Stores/[KPSPackage]**/[KPSDataSourceGroup]name=DataSources/[KPSCassandraDataSource]name=Cassandra Storage",
740- // "readConsistencyLevel", readConsistencyLevel, "writeConsistencyLevel", writeConsistencyLevel);
741- // Update Quota table consistency level
742717 updateCassandraConsistencyLevel (shorthandKeyFinder , "/[PortalConfiguration]name=Portal Config" ,
743718 "quotaReadConsistency" , readConsistencyLevel , "quotaWriteConsistency" , writeConsistencyLevel );
744719 //Update throttling consistency level
745720 updateCassandraConsistencyLevel (shorthandKeyFinder , "/[CassandraSettings]name=Cassandra Settings" ,
746721 "throttlingReadConsistencyLevel" , readConsistencyLevel , "throttlingWriteConsistencyLevel" , writeConsistencyLevel );
747-
748722 //Update access token consistency level
749723 updateCassandraConsistencyLevel (shorthandKeyFinder , "/[OAuth2StoresGroup]name=OAuth2 Stores/[AccessTokenStoreGroup]name=Access Token Stores/[AccessTokenPersist]**" ,
750724 "readConsistencyLevel" , readConsistencyLevel , "writeConsistencyLevel" , writeConsistencyLevel );
751-
752725 //Update auth code consistency level
753726 updateCassandraConsistencyLevel (shorthandKeyFinder , "/[OAuth2StoresGroup]name=OAuth2 Stores/[AuthzCodeStoreGroup]name=Authorization Code Stores/[AuthzCodePersist]**" ,
754727 "readConsistencyLevel" , readConsistencyLevel , "writeConsistencyLevel" , writeConsistencyLevel );
@@ -764,15 +737,9 @@ private void updateCassandraConsistencyLevel(ShorthandKeyFinder shorthandKeyFind
764737 Trace .info ("Total number of KPS Store: " + kpsEntities .size () + " in entity : " + shorthandKey );
765738 EntityStore entityStore = shorthandKeyFinder .getEntityStore ();
766739 for (Entity entity : kpsEntities ) {
767- // Trace.info(entity.toString());
768- // Trace.info("Read "+ entity.getStringValue(readConsistencyLevelFieldName));
769- // Trace.info("Write "+ entity.getStringValue(readConsistencyLevelFieldName));
770740 entity .setStringField (readConsistencyLevelFieldName , readConsistencyLevel );
771741 entity .setStringField (writeConsistencyLevelFieldName , writeConsistencyLevel );
772742 entityStore .updateEntity (entity );
773- // Trace.info("Update Read "+ entity.getStringValue(readConsistencyLevelFieldName));
774- // Trace.info("Update Write "+ entity.getStringValue(readConsistencyLevelFieldName));
775-
776743 }
777744 }
778745 }
0 commit comments