Index by: file name | procedure name | procedure call | annotation
installKeystore_proc.tcl (annotations | original source)

# 
# Install Keystore. 
# Delete and recreate if required. 
####################################################################
# Patrick Finnegan 30/01/2007.  V1. 
####################################################################

######################################
# List current keystore settings. 
######################################
proc installKeystore { propertiesFile } {

   global AdminConfig 
   global AdminTask 

   # display procedure arguments.

   putsLog "proc - [info level 0 ]"

   foreach i [ info args installLdap ]  {

      upvar 0 $i ilocal

      set propertiesArray($i) $ilocal 

   }

   putsLog "procedure arguments are.................."

   foreach { a b } [ array get propertiesArray ] {

       putsLog [ format "%-35s %s" "$a" "$b" ]

   }

   # get and display the existing keystores. 

   putsLog "existing keystores are:............" 

   if { [ catch { $AdminConfig list KeyStore } r ] == 0 } {

         set keyStoreList $r

         foreach i $keyStoreList { 
	     
	     set keyStoreName [ $AdminConfig showAttribute $i name ]

	     putsLog [ format "%-5s %s" " " $keyStoreName ]

	 }

   } else {

       return -code error $r

   }

   # call the hashMapList proc which returns a sorted list from the Property object loaded from the properties file.

   putsLog "new keystore properties are:............" 

   if { [ catch { hashMapList $propertiesFile } r ] == 0 } {
     
       set propertiesList $r 

       foreach a $propertiesList {

           putsLog [ format "%-5s %-40s %-s" " " [ lindex $a 0 ] [ lindex $a 1 ] ] 

       }

   } else {

       return -code error $r 

   }

   # call the hashMap proc which returns a Property object populated with property file values.  

   if { [ catch { hashMap $propertiesFile } r ] == 0 } {
     
       set PropertyI $r 

   } else {

       return -code error $r 

   }

   # check if the target keystore already exists.
   # if so delete.

   set keyStoreName [ $PropertyI getProperty KeyStore.name ]

   if { [ catch { $AdminConfig getid /KeyStore:$keyStoreName/ } r ] == 0 } {
	   
        if { $r != {} } {

	    set keyStoreId $r  

            putsLog "WARNING: $keyStoreName already exists."

            if { [ catch { $AdminConfig remove $keyStoreId } r ] == 0 } {

		putsLog "Keystore removed successfully: $keyStoreName"

	    } else {

		putsLog "ERROR: error removing Keystore: $keyStoreName"
		return -code error $r 

	    }

	}

   }

   #set the keystore properties.

   set attrList [ setKeystoreProperties $PropertyI ]

   #find the parent security object. 

   set securityId [ $AdminConfig list Security ] 

   if { [ catch { $AdminConfig create KeyStore $securityId $attrList } r ] == 0 } {

       putsLog "************************************"
       putsLog "KeyStore created successfully:"
       putsLog $r 
       putsLog "************************************"

       } else {

       putsLog "************************************"
       putsLog "ERROR: problem creating KeyStore"
       putsLog $r 
       putsLog "************************************"
       return -code error $r

   }
}
######################################
# set keystore attributes. 
######################################
proc setKeystoreProperties { PropertyI } {

   global AdminConfig 

   putsLog "proc - [info level 0 ]"

   foreach i [ info args setProperties ]  {

      upvar 0 $i ilocal

      set propertiesArray($i) $ilocal 

   }

   putsLog "procedure arguments are: .................."

   foreach { a b } [ array get propertiesArray ] {

       putsLog [ format "%-35s %s" "$a" "$b" ]

   }
    
   # build the attribute array. 

   set attrArray(createStashFileForCMS)  [ $PropertyI getProperty  KeyStore.createStashFileForCMS ]  
   set attrArray(fileBased)              [ $PropertyI getProperty  KeyStore.fileBased             ]  
   set attrArray(initializeAtStartup)    [ $PropertyI getProperty  KeyStore.initializeAtStartup   ]  
   set attrArray(location)               [ $PropertyI getProperty  KeyStore.location              ]  
   set attrArray(name)                   [ $PropertyI getProperty  KeyStore.name                  ]  
   set attrArray(password)               [ $PropertyI getProperty  KeyStore.password              ]  
   set attrArray(provider)               [ $PropertyI getProperty  KeyStore.provider              ]  
   set attrArray(readOnly)               [ $PropertyI getProperty  KeyStore.readOnly              ]  
   set attrArray(slot)                   [ $PropertyI getProperty  KeyStore.slot                  ]  
   set attrArray(type)                   [ $PropertyI getProperty  KeyStore.type                  ]  
   set attrArray(useForAcceleration)     [ $PropertyI getProperty  KeyStore.useForAcceleration    ]  

   set managementScopeList [ $AdminConfig list ManagementScope ] 

   foreach i $managementScopeList {

       set scopeType [ $AdminConfig showAttribute $i scopeType ]

       if { $scopeType == "cell" } { set managementScopeId $i }

   }

   set attrArray(managementScope) $managementScopeId   

   foreach i [ lsort [ array names attrArray ] ] {

       lappend attrList [ list $i $attrArray($i) ]

   }
 
   return $attrList 

}

Index by: file name | procedure name | procedure call | annotation
File generated 2007-08-07 at 13:42.