protected WorkManagerSecurity parseWorkManagerSecurity(XMLStreamReader reader) throws XMLStreamException,
      ParserException, ValidateException
   {
      boolean mappingRequired = false;
      String domain = null;
      String defaultPrincipal = null;
      List<String> defaultGroups = null;
      Map<String, String> userMappings = null;
      Map<String, String> groupMappings = null;

      boolean userMappingEnabled = false;

      HashMap<String, String> expressions = new HashMap<String, String>();

      while (reader.hasNext())
      {
         switch (reader.nextTag())
         {
            case END_ELEMENT : {
               if (CommonXML.ELEMENT_WORKMANAGER_SECURITY.equals(reader.getLocalName()))
               {
                  return new WorkManagerSecurityImpl(mappingRequired, domain,
                                                     defaultPrincipal, defaultGroups,
                                                     userMappings, groupMappings,
                          !expressions.isEmpty() ? expressions : null);
               }
               else
               {
                  switch (reader.getLocalName())
                  {
                     case CommonXML.ELEMENT_DEFAULT_GROUPS :
                     case CommonXML.ELEMENT_MAPPINGS :
                     case CommonXML.ELEMENT_MAPPING_REQUIRED :
                     case CommonXML.ELEMENT_DOMAIN :
                     case CommonXML.ELEMENT_DEFAULT_PRINCIPAL :
                     case CommonXML.ELEMENT_GROUP :
                     case CommonXML.ELEMENT_USERS :
                     case CommonXML.ELEMENT_GROUPS :
                     case CommonXML.ELEMENT_MAP :
                        break;
                     default :
                        throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                  }
               }
               break;
            }
            case START_ELEMENT : {
               switch (reader.getLocalName())
               {
                  case CommonXML.ELEMENT_DEFAULT_GROUPS :
                  case CommonXML.ELEMENT_MAPPINGS : {
                     // Skip
                     break;
                  }
                  case CommonXML.ELEMENT_MAPPING_REQUIRED : {
                     mappingRequired = elementAsBoolean(reader, CommonXML.ELEMENT_MAPPING_REQUIRED, expressions);
                     break;
                  }
                  case CommonXML.ELEMENT_DOMAIN : {
                     domain = elementAsString(reader, CommonXML.ELEMENT_DOMAIN, expressions);
                     break;
                  }
                  case CommonXML.ELEMENT_DEFAULT_PRINCIPAL : {
                     defaultPrincipal = elementAsString(reader, CommonXML.ELEMENT_DEFAULT_PRINCIPAL, expressions);
                     break;
                  }
                  case CommonXML.ELEMENT_GROUP : {
                     if (defaultGroups == null)
                        defaultGroups = new ArrayList<String>(1);

                     defaultGroups.add(elementAsString(reader,
                                                       getExpressionKey(CommonXML.ELEMENT_GROUP,
                                                                        Integer.toString(defaultGroups.size())),
                                                       expressions));
                     break;
                  }
                  case CommonXML.ELEMENT_USERS : {
                     userMappingEnabled = true;
                     break;
                  }
                  case CommonXML.ELEMENT_GROUPS : {
                     userMappingEnabled = false;
                     break;
                  }
                  case CommonXML.ELEMENT_MAP : {
                     if (userMappingEnabled)
                     {
                        if (userMappings == null)
                           userMappings = new HashMap<String, String>();

                        String from = attributeAsString(reader, CommonXML.ATTRIBUTE_FROM, expressions);

                        if (from == null || from.trim().equals(""))
                           throw new ParserException(
                              bundle.requiredAttributeMissing(CommonXML.ATTRIBUTE_FROM,
                                                              reader.getLocalName()));

                        String to = attributeAsString(reader, CommonXML.ATTRIBUTE_TO, expressions);

                        if (to == null || to.trim().equals(""))
                           throw new ParserException(
                              bundle.requiredAttributeMissing(CommonXML.ATTRIBUTE_TO,
                                                              reader.getLocalName()));

                        userMappings.put(from, to);
                     }
                     else
                     {
                        if (groupMappings == null)
                           groupMappings = new HashMap<String, String>();

                        String from = attributeAsString(reader, CommonXML.ATTRIBUTE_FROM, expressions);

                        if (from == null || from.trim().equals(""))
                           throw new ParserException(
                              bundle.requiredAttributeMissing(CommonXML.ATTRIBUTE_FROM,
                                                              reader.getLocalName()));

                        String to = attributeAsString(reader, CommonXML.ATTRIBUTE_TO, expressions);

                        if (to == null || to.trim().equals(""))
                           throw new ParserException(
                              bundle.requiredAttributeMissing(CommonXML.ATTRIBUTE_TO,
                                                              reader.getLocalName()));

                        groupMappings.put(from, to);
                     }
                     break;
                  }
                  default :
                     throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
               }
               break;
            }
         }
      }
      throw new ParserException(bundle.unexpectedEndOfDocument());
   }
protected WorkManagerSecurity parseWorkManagerSecurity ( XMLStreamReader reader ) throws XMLStreamException , ParserException , ValidateException { boolean mappingRequired = false ; String domain = null ; String defaultPrincipal = null ; List < String > defaultGroups = null ; Map < String , String > userMappings = null ; Map < String , String > groupMappings = null ; boolean userMappingEnabled = false ; HashMap < String , String > expressions = new HashMap < String , String > ( ) ; while ( reader . hasNext ( ) ) { switch ( reader . nextTag ( ) ) { case END_ELEMENT : { if ( CommonXML . ELEMENT_WORKMANAGER_SECURITY . equals ( reader . getLocalName ( ) ) ) { return new WorkManagerSecurityImpl ( mappingRequired , domain , defaultPrincipal , defaultGroups , userMappings , groupMappings , ! expressions . isEmpty ( ) ? expressions : null ) ; } else { switch ( reader . getLocalName ( ) ) { case CommonXML . ELEMENT_DEFAULT_GROUPS : case CommonXML . ELEMENT_MAPPINGS : case CommonXML . ELEMENT_MAPPING_REQUIRED : case CommonXML . ELEMENT_DOMAIN : case CommonXML . ELEMENT_DEFAULT_PRINCIPAL : case CommonXML . ELEMENT_GROUP : case CommonXML . ELEMENT_USERS : case CommonXML . ELEMENT_GROUPS : case CommonXML . ELEMENT_MAP : break ; default : throw new ParserException ( bundle . unexpectedEndTag ( reader . getLocalName ( ) ) ) ; } } break ; } case START_ELEMENT : { switch ( reader . getLocalName ( ) ) { case CommonXML . ELEMENT_DEFAULT_GROUPS : case CommonXML . ELEMENT_MAPPINGS : { break ; } case CommonXML . ELEMENT_MAPPING_REQUIRED : { mappingRequired = elementAsBoolean ( reader , CommonXML . ELEMENT_MAPPING_REQUIRED , expressions ) ; break ; } case CommonXML . ELEMENT_DOMAIN : { domain = elementAsString ( reader , CommonXML . ELEMENT_DOMAIN , expressions ) ; break ; } case CommonXML . ELEMENT_DEFAULT_PRINCIPAL : { defaultPrincipal = elementAsString ( reader , CommonXML . ELEMENT_DEFAULT_PRINCIPAL , expressions ) ; break ; } case CommonXML . ELEMENT_GROUP : { if ( defaultGroups == null ) defaultGroups = new ArrayList < String > ( 1 ) ; defaultGroups . add ( elementAsString ( reader , getExpressionKey ( CommonXML . ELEMENT_GROUP , Integer . toString ( defaultGroups . size ( ) ) ) , expressions ) ) ; break ; } case CommonXML . ELEMENT_USERS : { userMappingEnabled = true ; break ; } case CommonXML . ELEMENT_GROUPS : { userMappingEnabled = false ; break ; } case CommonXML . ELEMENT_MAP : { if ( userMappingEnabled ) { if ( userMappings == null ) userMappings = new HashMap < String , String > ( ) ; String from = attributeAsString ( reader , CommonXML . ATTRIBUTE_FROM , expressions ) ; if ( from == null || from . trim ( ) . equals ( "" ) ) throw new ParserException ( bundle . requiredAttributeMissing ( CommonXML . ATTRIBUTE_FROM , reader . getLocalName ( ) ) ) ; String to = attributeAsString ( reader , CommonXML . ATTRIBUTE_TO , expressions ) ; if ( to == null || to . trim ( ) . equals ( "" ) ) throw new ParserException ( bundle . requiredAttributeMissing ( CommonXML . ATTRIBUTE_TO , reader . getLocalName ( ) ) ) ; userMappings . put ( from , to ) ; } else { if ( groupMappings == null ) groupMappings = new HashMap < String , String > ( ) ; String from = attributeAsString ( reader , CommonXML . ATTRIBUTE_FROM , expressions ) ; if ( from == null || from . trim ( ) . equals ( "" ) ) throw new ParserException ( bundle . requiredAttributeMissing ( CommonXML . ATTRIBUTE_FROM , reader . getLocalName ( ) ) ) ; String to = attributeAsString ( reader , CommonXML . ATTRIBUTE_TO , expressions ) ; if ( to == null || to . trim ( ) . equals ( "" ) ) throw new ParserException ( bundle . requiredAttributeMissing ( CommonXML . ATTRIBUTE_TO , reader . getLocalName ( ) ) ) ; groupMappings . put ( from , to ) ; } break ; } default : throw new ParserException ( bundle . unexpectedElement ( reader . getLocalName ( ) ) ) ; } break ; } } } throw new ParserException ( bundle . unexpectedEndOfDocument ( ) ) ; }
Parse workmanager's security element
@param reader The reader
@return The value
@exception XMLStreamException XMLStreamException
@exception ParserException ParserException
@exception ValidateException ValidateException