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

# 
# Install JAAS AuthID.
#
####################################################################
# Patrick Finnegan 14/03/2007.  V1. 
####################################################################

proc installJAASAuthID { propertiesFile } {

   global AdminConfig 

   set procName [ lindex [ info level 0 ] 0 ]

   putsLog "## proc - $procName"

   foreach i [ info args $procName ]  {

      upvar 0 $i ilocal

      set propertiesArray($i) $ilocal 

   }

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

   foreach { a b } [ array get propertiesArray ] {

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

   }

   putsLog "JAAS properties are: ............" 

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

       foreach a $propertiesList {

           putsLog [ format "%-5s %-20s %-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 

   }

   set  alias       [ $PropertyI getProperty jaasAuth.alias        ]
   set  description [ $PropertyI getProperty jaasAuth.description  ]
   set  userId      [ $PropertyI getProperty jaasAuth.userId       ]
   set  password    [ $PropertyI getProperty jaasAuth.password     ]

   set attrArray(alias)       $alias  
   set attrArray(description) $description
   set attrArray(userId)      $userId
   set attrArray(password)    $password

   putsLog "List installed JAASAuthData authentication entries...."

   set JAASEntries [ $AdminConfig list JAASAuthData ] 

   if { $JAASEntries == {} } { 

       putsLog "No installed JAASAuth entries" 

   } else {

       foreach e $JAASEntries {

	  set subList [ $AdminConfig show $e ]

	  foreach e $subList { 

	     putsLog [ format "%-5s %-30s %-20s" " " [ lindex $e 0 ] [ lindex $e 1 ] ]
	  }

	  putsLog "" 
       }

       removeExistingEntries $JAASEntries $alias 

   }

   foreach { a b } [ array get attrArray ] { lappend attrList [ list $a $b ] }

   puts "$AdminConfig create JAASAuthData [$AdminConfig list Security] $attrList" 

   if { [ catch { $AdminConfig create JAASAuthData [$AdminConfig list Security] $attrList } r ] == 0 } { 

           putsLog "Puts J2CAuthId $attrArray(alias) created successfully" 

   } else {

       return -code error $r 

   }

   putsLog "List installed JAASAuthData authentication entries - confirm change "

   foreach e [ $AdminConfig list JAASAuthData ] {

      set subList [ $AdminConfig show $e ]

      foreach e $subList {
         putsLog [ format "%-5s %-30s %-20s" " " [ lindex $e 0 ] [ lindex $e 1 ] ]
      }

      putsLog "" 
   }
}
###################################################################
# remove duplicate entires. 
###################################################################
proc removeExistingEntries { JAASEntries alias } {

   global AdminConfig 

   set procName [ lindex [ info level 0 ] 0 ]

   putsLog "## proc - $procName"

   foreach i [ info args $procName ]  {

      upvar 0 $i ilocal

      set propertiesArray($i) $ilocal 

   }

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

   foreach { a b } [ array get propertiesArray ] {

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

   }

   putsLog "Remove Possible Duplicate Entries"

   foreach i $JAASEntries {

      putsLog "JAASEntry is $i"

      set existingAliasName [ $AdminConfig showAttribute $i alias  ]
      
      putsLog "existing alias name is: $existingAliasName"
      putsLog "new alias name is:      $alias"

      if { $existingAliasName == $alias } {

          putsLog "match for $alias"
          putsLog " **** Delete $alias **** "
          
          if { [ catch { $AdminConfig remove $i } r ] == 0 } {

	      putsLog "alias deleted successfully: $existingAliasName $i"

          } else {

	      putsLog "failed to delete alias: $existingAliasName $i"

	      return -code error $r 

          }


      } else { 

          putsLog "no match for $alias"
      }

  }

}

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