for(int i = DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY; i < subjectdnfieldnumbers.length; i++){ for(int j=0; j < subjectaltnamesnumbers[i]; j++){ checkIfDataFullfillProfile(DNEXTRATORTOPROFILEMAPPER[i],j,subjectaltnames.getField(i,j), DNEXTRATORTOPROFILEMAPPERTEXTS[i]);
for(int i = DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY; i < DNFieldExtractor.NUMBEROFFIELDS; i++){ for(int j=0; j < subjectaltnamesnumbers[i-DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY]; j++){ checkIfDataFullfillProfile(DNEXTRATORTOPROFILEMAPPER[i],j,subjectaltnames.getField(i,j), DNEXTRATORTOPROFILEMAPPERTEXTS[i], email);
    public void doesUserFullfillEndEntityProfileWithoutPassword(String username,  String dn, String subjectaltname, String email,  int certificateprofileid, boolean administrator, boolean keyrecoverable, int tokentype, int hardwaretokenissuerid) throws UserDoesntFullfillEndEntityProfile{       DNFieldExtractor subjectdnfields = new DNFieldExtractor(dn, DNFieldExtractor.TYPE_SUBJECTDN);      DNFieldExtractor subjectaltnames   = new DNFieldExtractor(subjectaltname, DNFieldExtractor.TYPE_SUBJECTALTNAME);            String dnfield;      String[] values;              // Check that no other than supported dn fields exists in the subject dn.      if(subjectdnfields.existsOther())        throw new UserDoesntFullfillEndEntityProfile("Unsupported Subject DN Field found.");           if(subjectaltnames.existsOther())        throw new UserDoesntFullfillEndEntityProfile("Unsupported Subject Alternate Name Field found.");                   checkIfAllRequiredFieldsExists(subjectdnfields, subjectaltnames,  username, email);                  // Check contents of username.       checkIfDataFullfillProfile(USERNAME,0,username, "Username");            // Check contents of Subject DN fields.      int[] subjectdnfieldnumbers = subjectdnfields.getNumberOfFields();      for(int i = 0; i < DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY; i++){        for(int j=0; j < subjectdnfieldnumbers[i]; j++){          checkIfDataFullfillProfile(DNEXTRATORTOPROFILEMAPPER[i],j,subjectdnfields.getField(i,j), DNEXTRATORTOPROFILEMAPPERTEXTS[i]);                    }       }       // Check contents of Subject Alternative Name fields.           int[] subjectaltnamesnumbers = subjectaltnames.getNumberOfFields();      for(int i = DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY; i < subjectdnfieldnumbers.length; i++){        for(int j=0; j < subjectaltnamesnumbers[i]; j++){          checkIfDataFullfillProfile(DNEXTRATORTOPROFILEMAPPER[i],j,subjectaltnames.getField(i,j), DNEXTRATORTOPROFILEMAPPERTEXTS[i]);                    }                        }                   //  Check Email address.     checkIfDataFullfillProfile(EMAIL,0,email,"Email");               // Check for administrator flag.      if(!getUse(ADMINISTRATOR,0) &&  administrator)          throw new UserDoesntFullfillEndEntityProfile("Administrator cannot be set.");                  if(isRequired(ADMINISTRATOR,0)){        if(getValue(ADMINISTRATOR,0).equals(TRUE) && !administrator)           throw new UserDoesntFullfillEndEntityProfile("Administrator flag is required.");                 if(getValue(ADMINISTRATOR,0).equals(FALSE) && administrator)                   throw new UserDoesntFullfillEndEntityProfile("Administrator flag cannot be set in end entity profile.");               }      // Check for administrator flag.      if(!getUse(KEYRECOVERABLE,0) &&  administrator)          throw new UserDoesntFullfillEndEntityProfile("Key Recoverable cannot be used.");          if(isRequired(KEYRECOVERABLE,0)){        if(getValue(KEYRECOVERABLE,0).equals(TRUE) && !administrator)           throw new UserDoesntFullfillEndEntityProfile("Key Recoverable is required.");          if(getValue(KEYRECOVERABLE,0).equals(FALSE) && administrator)                  throw new UserDoesntFullfillEndEntityProfile("Key Recoverable cannot be set in end entity profile.");                  }               // Check if certificate profile is among available certificate profiles.             String[] availablecertprofiles;       try{        availablecertprofiles = new RE(SPLITCHAR, false).split(getValue(AVAILCERTPROFILES,0));        }catch(Exception e){          throw new UserDoesntFullfillEndEntityProfile("Error parsing end entity profile.");        }      if(availablecertprofiles == null)           throw new UserDoesntFullfillEndEntityProfile("Error Available certificate profiles is null.");         else{        boolean found=false;          for(int i=0; i < availablecertprofiles.length;i++){          if( Integer.parseInt(availablecertprofiles[i]) == certificateprofileid)            found=true;        }                if(!found)           throw new UserDoesntFullfillEndEntityProfile("Couldn't find certificate profile among available certificate profiles.");       }             // Check if tokentype is among available  token types.          String[] availablesofttokentypes;       try{        availablesofttokentypes = new RE(SPLITCHAR, false).split(getValue(AVAILKEYSTORE,0));        }catch(Exception e){        throw new UserDoesntFullfillEndEntityProfile("Error parsing end entity profile.");        }      if(availablesofttokentypes == null)         throw new UserDoesntFullfillEndEntityProfile("Error available  token types is null.");         else{        boolean found=false;          for(int i=0; i < availablesofttokentypes.length;i++){          if( Integer.parseInt(availablesofttokentypes[i]) == tokentype)            found=true;        }               if(!found)           throw new UserDoesntFullfillEndEntityProfile("Couldn't find  token type among available token types.");       }                    // If soft token check for hardwaretoken issuer id = 0.      if(tokentype <= SecConst.TOKEN_SOFT){               if(hardwaretokenissuerid != 0)           throw new UserDoesntFullfillEndEntityProfile("Soft tokens cannot have a hardware token issuer.");                 }          // If Hard token type check if hardware token issuer is among available hardware token issuers.      if(tokentype > SecConst.TOKEN_SOFT){ // Hardware token.        String[] availablehardtokenissuers;         try{          availablehardtokenissuers = new RE(SPLITCHAR, false).split(getValue(AVAILTOKENISSUER,0));          }catch(Exception e){          throw new UserDoesntFullfillEndEntityProfile("Error parsing end entity profile.");          }        if(availablehardtokenissuers == null)           throw new UserDoesntFullfillEndEntityProfile("Error available hard token issuers is null.");           else{          boolean found=false;            for(int i=0; i < availablehardtokenissuers.length;i++){            if( Integer.parseInt(availablehardtokenissuers[i]) == hardwaretokenissuerid)              found=true;          }                  if(!found)            throw new UserDoesntFullfillEndEntityProfile("Couldn't find hard token issuers among available hard token issuers.");         }      }     }