public void parse ( UNode userNode ) { m_userID = userNode . getName ( ) ; m_password = null ; m_permissions . clear ( ) ; for ( String childName : userNode . getMemberNames ( ) ) { UNode childNode = userNode . getMember ( childName ) ; switch ( childNode . getName ( ) ) { case "password" : Utils . require ( childNode . isValue ( ) , "'password' must be a simple value: " + childNode ) ; m_password = childNode . getValue ( ) ; break ; case "hash" : Utils . require ( childNode . isValue ( ) , "Invalid 'hash' value" ) ; m_hash = childNode . getValue ( ) ; break ; case "permissions" : Utils . require ( childNode . isValue ( ) , "'permissions' must be a list of values: " + childNode ) ; String [ ] permissions = childNode . getValue ( ) . split ( "," ) ; for ( String permission : permissions ) { String permToken = permission . toUpperCase ( ) . trim ( ) ; try { m_permissions . add ( Permission . valueOf ( permToken ) ) ; } catch ( IllegalArgumentException e ) { Utils . require ( false , "Unrecognized permission: %s; allowed values are: %s" , permToken , Arrays . asList ( Permission . values ( ) ) . toString ( ) ) ; } } break ; default : Utils . require ( false , "Unknown 'user' property: " + childNode ) ; } } }
Parse a user definition expressed as a UNode tree .