private String addAttributeQueryTemplate(String extended,String cot){
  String buff="    <AttributeQueryConfig metaAlias=\"/attrQuery\">\n" + "        <Attribute name=\"signingCertAlias\">\n" + "            <Value>"+ "</Value>\n"+ "        </Attribute>\n"+ "        <Attribute name=\"encryptionCertAlias\">\n"+ "            <Value>"+ "</Value>\n"+ "        </Attribute>\n"+ "        <Attribute name=\"wantNameIDEncrypted\">\n"+ "            <Value>"+ "</Value>\n"+ "        </Attribute>\n"+ "        <Attribute name=\"cotlist\">\n"+ "            <Value>" + cot + "</Value>\n"+ "        </Attribute>\n"+ "    </AttributeQueryConfig>\n";
  int idx=extended.indexOf("</EntityConfig>");
  if (idx != -1) {
    extended=extended.substring(0,idx) + buff + "</EntityConfig>";
  }
  return extended;
}

private String addAttributeQueryTemplate ( String extended , String cot ) { String buff = "    <AttributeQueryConfig metaAlias=\"/attrQuery\">\n" + "        <Attribute name=\"signingCertAlias\">\n" + "            <Value>" + "</Value>\n" + "        </Attribute>\n" + "        <Attribute name=\"encryptionCertAlias\">\n" + "            <Value>" + "</Value>\n" + "        </Attribute>\n" + "        <Attribute name=\"wantNameIDEncrypted\">\n" + "            <Value>" + "</Value>\n" + "        </Attribute>\n" + "        <Attribute name=\"cotlist\">\n" + "            <Value>" + cot + "</Value>\n" + "        </Attribute>\n" + "    </AttributeQueryConfig>\n" ; int idx = extended . indexOf ( "</EntityConfig>" ) ; if ( idx != - 1 ) { extended = extended . substring ( 0 , idx ) + buff + "</EntityConfig>" ; } return extended ; }
below method will add the attributequery to the sp extended meta data
