AutoRefactor'ed use StringBuilder
| | |
| | | } |
| | | |
| | | /* add public-key certificate entry */ |
| | | final LdapName keyDn = new LdapName((new StringBuilder()) |
| | | .append(ServerProperty.INSTANCE_KEY_ID.getAttributeName()) |
| | | .append("=").append(Rdn.escapeValue(keyID)).append(",") |
| | | .append(ADSContext.getInstanceKeysContainerDN()).toString()); |
| | | final LdapName keyDn = new LdapName( |
| | | ServerProperty.INSTANCE_KEY_ID.getAttributeName() + "=" + Rdn.escapeValue(keyID) |
| | | + "," + ADSContext.getInstanceKeysContainerDN()); |
| | | ctx.createSubcontext(keyDn, keyAttrs).close(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void jumpSection() { |
| | | htmlBuff.append("<p class=\"category-index\">" + |
| | | "<strong>Jump To:</strong><br>\n"); |
| | | htmlBuff.append("<p class=\"category-index\"><strong>Jump To:</strong><br>\n"); |
| | | |
| | | String[] catNames = catTopMoList.keySet().toArray(new String[0]); |
| | | for (int ii=0; ii < catNames.length; ii++) { |
| | |
| | | } |
| | | |
| | | private void homeLink() { |
| | | htmlBuff.append("<div style=\"font-size:11px;margin-top:-10px;" + |
| | | "margin-bottom:-10px; text-align:right\"><a href=\"" + |
| | | MAIN_FILE + |
| | | "\" target=\"_top\">Configuration Reference Home</a></div>"); |
| | | htmlBuff.append("<div style=\"font-size:11px;margin-top:-10px;") |
| | | .append("margin-bottom:-10px; text-align:right\"><a href=\"") |
| | | .append(MAIN_FILE) |
| | | .append("\" target=\"_top\">Configuration Reference Home</a></div>"); |
| | | } |
| | | |
| | | |
| | |
| | | private void propertiesLinkTable(TreeMap<String, |
| | | PropertyDefinition> basicProps, |
| | | TreeMap<String, PropertyDefinition> advancedProps) { |
| | | htmlBuff.append( |
| | | "<table border=\"0\" cellspacing=\"0\" class=\"jump-table\">\n" + |
| | | " <tr>\n" + |
| | | " <th>Basic Properties:</th>\n" + |
| | | " <th>Advanced Properties:</th>\n" + |
| | | " </tr>\n"); |
| | | htmlBuff.append("<table border=\"0\" cellspacing=\"0\" class=\"jump-table\">\n") |
| | | .append(" <tr>\n") |
| | | .append(" <th>Basic Properties:</th>\n") |
| | | .append(" <th>Advanced Properties:</th>\n") |
| | | .append(" </tr>\n"); |
| | | |
| | | PropertyDefinition[] basicPropsArray = |
| | | basicProps.values().toArray(new PropertyDefinition[0]); |
| | |
| | | } |
| | | |
| | | htmlBuff.append("<tr>\n"); |
| | | htmlBuff.append(basicHtmlCell + advancedHtmlCell); |
| | | htmlBuff.append(basicHtmlCell).append(advancedHtmlCell); |
| | | htmlBuff.append("</tr>\n"); |
| | | } |
| | | htmlBuff.append("</table>\n"); |
| | |
| | | if (!mo.getName().startsWith(firstChar)) { |
| | | firstChar = mo.getName().substring(0, 1); |
| | | String letter = firstChar.toUpperCase(); |
| | | moPointers.append(getAnchor(letter) + getHeading2(letter)); |
| | | moPointers.append(getAnchor(letter)).append(getHeading2(letter)); |
| | | lettersPointers += getLink(letter, "#" + letter) + " "; |
| | | } |
| | | moPointers.append( |
| | | "<p> " + |
| | | getLink(mo.getUserFriendlyName().toString(), mo.getName() + ".html", |
| | | MAIN_FRAME) + |
| | | "</p>\n"); |
| | | moPointers.append("<p> ") |
| | | .append(getLink(mo.getUserFriendlyName().toString(), mo.getName() + ".html", MAIN_FRAME)) |
| | | .append("</p>\n"); |
| | | } |
| | | paragraph(lettersPointers); |
| | | htmlBuff.append(moPointers); |
| | |
| | | if (!propName.startsWith(firstChar)) { |
| | | firstChar = propName.substring(0, 1); |
| | | String letter = firstChar.toUpperCase(); |
| | | htmlBuff.append(getAnchor(letter) + getHeading2(letter)); |
| | | htmlBuff.append(getAnchor(letter)).append(getHeading2(letter)); |
| | | lettersPointers += getLink(letter, "#" + letter) + " "; |
| | | } |
| | | String propLink = getLink(propName, |
| | |
| | | } |
| | | |
| | | private void bullet(String str) { |
| | | htmlBuff.append( |
| | | "<li>" + |
| | | str + |
| | | "</li>\n"); |
| | | htmlBuff.append("<li>").append(str).append("</li>\n"); |
| | | } |
| | | |
| | | private void heading2(String string) { |
| | |
| | | } |
| | | |
| | | private void htmlHeader(String pageTitle) { |
| | | htmlBuff.append(getHtmlHeader(pageTitle) + |
| | | "<body>\n"); |
| | | htmlBuff.append(getHtmlHeader(pageTitle)).append("<body>\n"); |
| | | |
| | | } |
| | | |
| | |
| | | if (!inList) { |
| | | htmlStr += "<br>"; |
| | | } |
| | | htmlBuff.append(htmlStr + "\n"); |
| | | htmlBuff.append(htmlStr).append("\n"); |
| | | } |
| | | |
| | | private void newline() { |
| | |
| | | classStr = "class=" + pClass; |
| | | } |
| | | |
| | | htmlBuff.append( |
| | | "<p " + |
| | | indentStr + " " + |
| | | styleStr + " " + |
| | | classStr + |
| | | ">" + |
| | | description + |
| | | "</p>\n"); |
| | | htmlBuff.append("<p ").append(indentStr).append(" ").append(styleStr).append(" ").append(classStr).append(">") |
| | | .append(description) |
| | | .append("</p>\n"); |
| | | } |
| | | |
| | | private int getIndentPixels() { |
| | |
| | | } |
| | | |
| | | private void startTable() { |
| | | htmlBuff.append( |
| | | "<table " + |
| | | "style=\"width: 100%; text-align: left;\"" + |
| | | "border=\"1\"" + |
| | | "cellpadding=\"1\"" + |
| | | "cellspacing=\"0\"" + |
| | | ">\n"); |
| | | htmlBuff.append("<table ") |
| | | .append("style=\"width: 100%; text-align: left;\"") |
| | | .append("border=\"1\"") |
| | | .append("cellpadding=\"1\"") |
| | | .append("cellspacing=\"0\"") |
| | | .append(">\n"); |
| | | |
| | | htmlBuff.append("<tbody>\n"); |
| | | } |
| | |
| | | "<tr>\n"); |
| | | for (int ii = 0; ii < strings.length; ii++) { |
| | | String string = strings[ii]; |
| | | htmlBuff.append( |
| | | "<td style=\"" + |
| | | "vertical-align: top; " + |
| | | ((ii == 0) ? "width: 20%;" : "") + |
| | | "\">" + |
| | | string + |
| | | "<br></td>"); |
| | | htmlBuff.append("<td style=\"") |
| | | .append("vertical-align: top; ") |
| | | .append(ii == 0 ? "width: 20%;" : "") |
| | | .append("\">") |
| | | .append(string) |
| | | .append("<br></td>"); |
| | | } |
| | | htmlBuff.append( |
| | | "</tr>\n"); |
| | |
| | | } |
| | | |
| | | private void htmlFooter() { |
| | | htmlBuff.append( |
| | | "</body>\n" + |
| | | "</html>\n"); |
| | | htmlBuff.append("</body>\n").append("</html>\n"); |
| | | } |
| | | |
| | | private void viewHelp(String helpStr) { |
| | | htmlBuff.append( |
| | | "<p class=\"view-help\" >" + |
| | | helpStr + |
| | | "</p>" + |
| | | "\n" |
| | | ); |
| | | htmlBuff.append("<p class=\"view-help\" >") |
| | | .append(helpStr) |
| | | .append("</p>") |
| | | .append("\n"); |
| | | } |
| | | |
| | | private void generateFile(String fileName) { |
| | |
| | | { |
| | | if (indexNameOut.length() > 0) |
| | | { |
| | | debugBuffer.append(newUndefinedSet().toString()); |
| | | debugBuffer.append(newUndefinedSet()); |
| | | appendDebugIndexInformation(debugBuffer, indexNameOut.toString()); |
| | | } |
| | | } |
| | |
| | | } |
| | | if (indexNameOut != null) |
| | | { |
| | | indexNameOut.append(IndexFilterType.PRESENCE.toString()); |
| | | indexNameOut.append(IndexFilterType.PRESENCE); |
| | | } |
| | | return entrySet; |
| | | } |
| | |
| | | = "cn=secret keys," + ADSContext.getAdministrationSuffixDN(); |
| | | final DN baseDN = DN.valueOf(baseDNStr); |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + OC_CRYPTO_CIPHER_KEY + ")"; |
| | | final String FILTER_NOT_COMPROMISED = new StringBuilder("(!(") |
| | | .append(ATTR_CRYPTO_KEY_COMPROMISED_TIME) |
| | | .append("=*))").toString(); |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = new StringBuilder("(") |
| | | .append(ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME) |
| | | .append("=").append(cipherTransformationName) |
| | | .append(")").toString(); |
| | | final String FILTER_CIPHER_KEY_LENGTH = new StringBuilder("(") |
| | | .append(ATTR_CRYPTO_KEY_LENGTH_BITS) |
| | | .append("=").append(String.valueOf(cipherKeyLength)) |
| | | .append(")").toString(); |
| | | final String searchFilter = new StringBuilder("(&") |
| | | .append(FILTER_OC_INSTANCE_KEY) |
| | | .append(FILTER_NOT_COMPROMISED) |
| | | .append(FILTER_CIPHER_TRANSFORMATION_NAME) |
| | | .append(FILTER_CIPHER_KEY_LENGTH) |
| | | .append(")").toString(); |
| | | final String FILTER_NOT_COMPROMISED = |
| | | "(!(" + ATTR_CRYPTO_KEY_COMPROMISED_TIME + "=*))"; |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = |
| | | "(" + ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME + "=" + cipherTransformationName + ")"; |
| | | final String FILTER_CIPHER_KEY_LENGTH = |
| | | "(" + ATTR_CRYPTO_KEY_LENGTH_BITS + "=" + cipherKeyLength + ")"; |
| | | final String searchFilter = |
| | | "(&" + FILTER_OC_INSTANCE_KEY + FILTER_NOT_COMPROMISED + FILTER_CIPHER_TRANSFORMATION_NAME + FILTER_CIPHER_KEY_LENGTH + ")"; |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter).addAttribute("dn"); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | | assertFalse(searchOp.getSearchEntries().isEmpty()); |
| | |
| | | final String baseDNStr // TODO: is this DN defined elsewhere as a constant? |
| | | = "cn=secret keys," + ADSContext.getAdministrationSuffixDN(); |
| | | final DN baseDN = DN.valueOf(baseDNStr); |
| | | final String FILTER_OC_INSTANCE_KEY |
| | | = new StringBuilder("(objectclass=") |
| | | .append(ConfigConstants.OC_CRYPTO_CIPHER_KEY) |
| | | .append(")").toString(); |
| | | final String FILTER_NOT_COMPROMISED = new StringBuilder("(!(") |
| | | .append(ConfigConstants.ATTR_CRYPTO_KEY_COMPROMISED_TIME) |
| | | .append("=*))").toString(); |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = new StringBuilder("(") |
| | | .append(ConfigConstants.ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME) |
| | | .append("=").append(cipherTransformationName) |
| | | .append(")").toString(); |
| | | final String FILTER_CIPHER_KEY_LENGTH = new StringBuilder("(") |
| | | .append(ConfigConstants.ATTR_CRYPTO_KEY_LENGTH_BITS) |
| | | .append("=").append(String.valueOf(cipherKeyLength)) |
| | | .append(")").toString(); |
| | | final String searchFilter = new StringBuilder("(&") |
| | | .append(FILTER_OC_INSTANCE_KEY) |
| | | .append(FILTER_NOT_COMPROMISED) |
| | | .append(FILTER_CIPHER_TRANSFORMATION_NAME) |
| | | .append(FILTER_CIPHER_KEY_LENGTH) |
| | | .append(")").toString(); |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + OC_CRYPTO_CIPHER_KEY + ")"; |
| | | final String FILTER_NOT_COMPROMISED = "(!(" + ATTR_CRYPTO_KEY_COMPROMISED_TIME + "=*))"; |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = "(" + ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME + "=" + cipherTransformationName + ")"; |
| | | final String FILTER_CIPHER_KEY_LENGTH = "(" + ATTR_CRYPTO_KEY_LENGTH_BITS + "=" + cipherKeyLength + ")"; |
| | | final String searchFilter = |
| | | "(&" + FILTER_OC_INSTANCE_KEY + FILTER_NOT_COMPROMISED + FILTER_CIPHER_TRANSFORMATION_NAME + FILTER_CIPHER_KEY_LENGTH + ")"; |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter) |
| | | .addAttribute(ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | |
| | | if (! violatingDNs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("The extensibleObject object class is not allowed for " + |
| | | "use in the server configuration."); |
| | | message.append(EOL); |
| | | message.append("Configuration entries containing the extensibleObject " + |
| | | "object class:"); |
| | | message.append(EOL); |
| | | message.append("The extensibleObject object class is not allowed for use in the server configuration.") |
| | | .append(EOL); |
| | | message.append("Configuration entries containing the extensibleObject object class:").append(EOL); |
| | | for (DN dn : violatingDNs) |
| | | { |
| | | message.append("- "); |
| | | message.append(dn.toString()); |
| | | message.append(EOL); |
| | | message.append("- ").append(dn).append(EOL); |
| | | } |
| | | |
| | | throw new AssertionError(message.toString()); |
| | |
| | | addRequest.toString(buffer); |
| | | |
| | | StringBuilder key = new StringBuilder(); |
| | | key.append("AddRequest(dn="+dn+", attrs={"); |
| | | key.append("AddRequest(dn=").append(dn).append(", attrs={"); |
| | | for (int i = 0; i < numAttributes; i++) |
| | | { |
| | | attributes.get(i).toString(key); |
| | |
| | | } |
| | | |
| | | StringBuilder key = new StringBuilder(); |
| | | key.append(indentBuf); |
| | | key.append("Add Request"); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(" Attributes:"); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append("Add Request").append(EOL); |
| | | key.append(indentBuf).append(" DN: ").append(dn).append(EOL); |
| | | key.append(" Attributes:").append(EOL); |
| | | for (RawAttribute attribute : attributes) |
| | | { |
| | | attribute.toString(key, indent+4); |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | AddResponseProtocolOp addResponse; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | AddResponseProtocolOp addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | addResponse.toString(buffer); |
| | | |
| | | key.append("AddResponse(resultCode=" + resultCode |
| | | + ", " + "errorMessage=" + resultMsg + ", matchedDN=" + dn + ", " |
| | | + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | String key = "AddResponse(resultCode=" + resultCode |
| | | + ", errorMessage=" + resultMsg |
| | | + ", matchedDN=" + dn + |
| | | ", referralURLs={" + joinAsString(", ", referralURLs) + "})"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | } |
| | | |
| | | static void join(StringBuilder sb, List<String> referralURLs) |
| | | { |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | sb.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | sb.append(", "); |
| | | sb.append(iterator.next()); |
| | | } |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | int indent = 5; |
| | | int i; |
| | | |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | addResponse.toString(buffer, indent); |
| | | |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Add Response"); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append("Add Response").append(EOL); |
| | | key.append(indentBuf).append(" Result Code: ").append(resultCode).append(EOL); |
| | | key.append(indentBuf).append(" Error Message: ").append(resultMsg).append(EOL); |
| | | key.append(indentBuf).append(" Matched DN: ").append(dn).append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Result Code: "); |
| | | key.append(resultCode); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Error Message: "); |
| | | key.append(resultMsg); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Matched DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Referral URLs: "); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append(" Referral URLs: ").append(EOL); |
| | | for (String url : referralURLs) |
| | | { |
| | | key.append(indentBuf); |
| | | key.append(" "); |
| | | key.append(url); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append(" ").append(url).append(EOL); |
| | | } |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | CompareRequestProtocolOp compareRequest; |
| | | CompareRequestProtocolOp compareRequest = new CompareRequestProtocolOp( |
| | | dn, attributeType, assertionValue); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | int i; |
| | | |
| | | compareRequest = new CompareRequestProtocolOp(dn, attributeType, |
| | | assertionValue); |
| | | compareRequest.toString(buffer); |
| | | |
| | | key.append("CompareRequest(dn="+dn+", attribute="+attributeType+", " + |
| | | "value="+assertionValue+")"); |
| | | String key = "CompareRequest(dn=" + dn |
| | | + ", attribute=" + attributeType |
| | | + ", value=" + assertionValue + ")"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Test |
| | | public void TestToStringMultiLine() throws Exception |
| | | { |
| | | CompareRequestProtocolOp compareRequest; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | int i; |
| | | int indent; |
| | | int indent = 5; |
| | | |
| | | indent = 5; |
| | | compareRequest = new CompareRequestProtocolOp(dn, attributeType, |
| | | assertionValue); |
| | | CompareRequestProtocolOp compareRequest = new CompareRequestProtocolOp(dn, attributeType, assertionValue); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | compareRequest.toString(buffer, indent); |
| | | |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | | for (i=0 ; i < indent; i++) |
| | | for (int i = 0 ; i < indent; i++) |
| | | { |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Compare Request"); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Target DN: "); |
| | | key.append(dn); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Attribute Type: "); |
| | | key.append(attributeType); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Assertion Value:"); |
| | | key.append(EOL); |
| | | StringBuilder key = new StringBuilder(); |
| | | key.append(indentBuf).append("Compare Request").append(EOL); |
| | | key.append(indentBuf).append(" Target DN: ").append(dn).append(EOL); |
| | | key.append(indentBuf).append(" Attribute Type: ").append(attributeType).append(EOL); |
| | | key.append(indentBuf).append(" Assertion Value:").append(EOL); |
| | | key.append(assertionValue.toHexPlusAsciiString(indent+4)); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | CompareResponseProtocolOp compareResponse; |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | CompareResponseProtocolOp compareResponse = new CompareResponseProtocolOp( |
| | | resultCode, resultMsg, dn, referralURLs); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | |
| | | compareResponse = new CompareResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | compareResponse.toString(buffer); |
| | | |
| | | key.append("CompareResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | String key = "CompareResponse(resultCode=" + resultCode |
| | | + ", errorMessage=" + resultMsg |
| | | + ", matchedDN=" + dn |
| | | + ", referralURLs={" + joinAsString(", ", referralURLs) + "})"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Compare Response"); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append("Compare Response").append(EOL); |
| | | key.append(indentBuf).append(" Result Code: ").append(resultCode).append(EOL); |
| | | key.append(indentBuf).append(" Error LocalizableMessage: ").append(resultMsg).append(EOL); |
| | | key.append(indentBuf).append(" Matched DN: ").append(dn).append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Result Code: "); |
| | | key.append(resultCode); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Error LocalizableMessage: "); |
| | | key.append(resultMsg); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Matched DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Referral URLs: "); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append(" Referral URLs: ").append(EOL); |
| | | for (String url : referralURLs) |
| | | { |
| | | key.append(indentBuf); |
| | | key.append(" "); |
| | | key.append(url); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append(" ").append(url).append(EOL); |
| | | } |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | DeleteResponseProtocolOp deleteResponse; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | deleteResponse = new DeleteResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | DeleteResponseProtocolOp deleteResponse = new DeleteResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | deleteResponse.toString(buffer); |
| | | |
| | | key.append("DeleteResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | String key = "DeleteResponse(resultCode=" + resultCode |
| | | + ", errorMessage=" + resultMsg |
| | | + ", matchedDN=" + dn |
| | | + ", referralURLs={" + joinAsString(", ", referralURLs) + "})"; |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Delete Response"); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append("Delete Response").append(EOL); |
| | | key.append(indentBuf).append(" Result Code: ").append(resultCode).append(EOL); |
| | | key.append(indentBuf).append(" Error LocalizableMessage: ").append(resultMsg).append(EOL); |
| | | key.append(indentBuf).append(" Matched DN: ").append(dn).append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Result Code: "); |
| | | key.append(resultCode); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Error LocalizableMessage: "); |
| | | key.append(resultMsg); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Matched DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Referral URLs: "); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append(" Referral URLs: ").append(EOL); |
| | | for (String url : referralURLs) |
| | | { |
| | | key.append(indentBuf); |
| | | key.append(" "); |
| | | key.append(url); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append(" ").append(url).append(EOL); |
| | | } |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | newSuperiorDn); |
| | | modifyRequest.toString(buffer); |
| | | |
| | | key.append("ModifyDNRequest(dn="+dn+", newRDN="+newRdn+", " + |
| | | "deleteOldRDN="+true+", newSuperior="+newSuperiorDn+")"); |
| | | key.append("ModifyDNRequest(dn=").append(dn).append(", newRDN=").append(newRdn).append(", ").append("deleteOldRDN=").append(true).append(", newSuperior=") |
| | | .append(newSuperiorDn).append(")"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | ModifyDNResponseProtocolOp modifyResponse; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | modifyResponse = new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | ModifyDNResponseProtocolOp modifyResponse = new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | modifyResponse.toString(buffer); |
| | | |
| | | key.append("ModifyDNResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn + ", " |
| | | + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | String key = "ModifyDNResponse(resultCode=" + resultCode |
| | | + ", errorMessage=" + resultMsg |
| | | + ", matchedDN=" + dn |
| | | + ", referralURLs={" + joinAsString(", ", referralURLs) + "})"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Modify DN Response"); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append("Modify DN Response").append(EOL); |
| | | key.append(indentBuf).append(" Result Code: ").append(resultCode).append(EOL); |
| | | key.append(indentBuf).append(" Error LocalizableMessage: ").append(resultMsg).append(EOL); |
| | | key.append(indentBuf).append(" Matched DN: ").append(dn).append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Result Code: "); |
| | | key.append(resultCode); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Error LocalizableMessage: "); |
| | | key.append(resultMsg); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Matched DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Referral URLs: "); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append(" Referral URLs: ").append(EOL); |
| | | for (String url : referralURLs) |
| | | { |
| | | key.append(indentBuf); |
| | | key.append(" "); |
| | | key.append(url); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append(" ").append(url).append(EOL); |
| | | } |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | new ModifyRequestProtocolOp(dn, modifications); |
| | | modifyRequest.toString(buffer); |
| | | |
| | | key.append("ModifyRequest(dn="+dn+", mods={"); |
| | | key.append("ModifyRequest(dn=").append(dn).append(", mods={"); |
| | | for (int i = 0; i < numModifications; i++) |
| | | { |
| | | modifications.get(i).toString(key); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Test |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | ModifyResponseProtocolOp modifyResponse; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | ModifyResponseProtocolOp modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | modifyResponse.toString(buffer); |
| | | |
| | | key.append("ModifyResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | String key = "ModifyResponse(resultCode=" + resultCode |
| | | + ", errorMessage=" + resultMsg |
| | | + ", matchedDN=" + dn |
| | | + ", referralURLs={" + joinAsString(", ", referralURLs) + "})"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | assertEquals(buffer.toString(), key); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | ModifyResponseProtocolOp modifyResponse; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<>(); |
| | | referralURLs.add("ds1.example.com"); |
| | |
| | | int indent = 5; |
| | | int i; |
| | | |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | modifyResponse.toString(buffer, indent); |
| | | |
| | | StringBuilder indentBuf = new StringBuilder(indent); |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | key.append(indentBuf); |
| | | key.append("Modify Response"); |
| | | key.append(EOL); |
| | | StringBuilder key = new StringBuilder(); |
| | | key.append(indentBuf).append("Modify Response").append(EOL); |
| | | key.append(indentBuf).append(" Result Code: ").append(resultCode).append(EOL); |
| | | key.append(indentBuf).append(" Error LocalizableMessage: ").append(resultMsg).append(EOL); |
| | | key.append(indentBuf).append(" Matched DN: ").append(dn).append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Result Code: "); |
| | | key.append(resultCode); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Error LocalizableMessage: "); |
| | | key.append(resultMsg); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Matched DN: "); |
| | | key.append(dn.toString()); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf); |
| | | key.append(" Referral URLs: "); |
| | | key.append(EOL); |
| | | |
| | | key.append(indentBuf).append(" Referral URLs: ").append(EOL); |
| | | for (String url : referralURLs) |
| | | { |
| | | key.append(indentBuf); |
| | | key.append(" "); |
| | | key.append(url); |
| | | key.append(EOL); |
| | | key.append(indentBuf).append(" ").append(url).append(EOL); |
| | | } |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | private void testSetUp(String tc) throws Exception |
| | | { |
| | | personEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=user.1." + tc + "," + baseDN + "", |
| | | "dn: uid=user.1." + tc + "," + baseDN, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | |
| | | user1entrysecondUUID = "22222222-2222-2222-2222-222222222222"; |
| | | user1dn = DN.valueOf("uid=user1" + tc + "," + baseDN); |
| | | personWithUUIDEntry = TestCaseUtils.makeEntry( |
| | | "dn: "+ user1dn + "", |
| | | "dn: " + user1dn, |
| | | "objectClass: top", "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", "uid: user.1", |
| | |
| | | final StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < ENTRYCOUNT; i++) |
| | | { |
| | | sb.append("key : value" + i + "\n\n"); |
| | | sb.append("key : value").append(i).append("\n\n"); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All attribute syntaxes defined in OpenDS must have " + |
| | | "valid OIDs assigned."); |
| | | message.append(EOL); |
| | | message.append("Attribute syntaxes without valid OIDs:"); |
| | | message.append(EOL); |
| | | message.append("All attribute syntaxes defined in OpenDS must have valid OIDs assigned.").append(EOL); |
| | | message.append("Attribute syntaxes without valid OIDs:").append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- " + s); |
| | | message.append(EOL); |
| | | message.append("- ").append(s).append(EOL); |
| | | } |
| | | |
| | | throw new AssertionError(message.toString()); |
| | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All matching rules defined in OpenDS must have valid " + |
| | | "OIDs assigned."); |
| | | message.append("All matching rules defined in OpenDS must have valid ").append("OIDs assigned."); |
| | | message.append(EOL); |
| | | message.append("Matching rules without valid OIDs:"); |
| | | message.append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- " + s); |
| | | message.append("- ").append(s); |
| | | message.append(EOL); |
| | | } |
| | | |
| | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All attribute types defined in OpenDS must have valid " + |
| | | "OIDs assigned."); |
| | | message.append("All attribute types defined in OpenDS must have valid ").append("OIDs assigned."); |
| | | message.append(EOL); |
| | | message.append("Attribute types without valid OIDs:"); |
| | | message.append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- " + s); |
| | | message.append("- ").append(s); |
| | | message.append(EOL); |
| | | } |
| | | |
| | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All object classes defined in OpenDS must have valid " + |
| | | "OIDs assigned."); |
| | | message.append("All object classes defined in OpenDS must have valid ").append("OIDs assigned."); |
| | | message.append(EOL); |
| | | message.append("Object classes without valid OIDs:"); |
| | | message.append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- " + s); |
| | | message.append("- ").append(s); |
| | | message.append(EOL); |
| | | } |
| | | |
| | |
| | | if (! invalidOIDs.isEmpty()) |
| | | { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("All name forms defined in OpenDS must have valid OIDs " + |
| | | "assigned."); |
| | | message.append("All name forms defined in OpenDS must have valid OIDs ").append("assigned."); |
| | | message.append(EOL); |
| | | message.append("Name forms without valid OIDs:"); |
| | | message.append(EOL); |
| | | for (String s : invalidOIDs) |
| | | { |
| | | message.append("- " + s); |
| | | message.append("- ").append(s); |
| | | message.append(EOL); |
| | | } |
| | | |