1   /*
2    * Copyright 2018 LINE Corporation
3    *
4    * LINE Corporation licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package com.linecorp.centraldogma.server.auth.saml;
17  
18  import static java.util.Objects.requireNonNull;
19  
20  final class HtmlUtil {
21  
22      private static final String BEGIN =
23              "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
24              "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">" +
25              "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">" +
26              "<head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" /></head>" +
27              "<body onload=\"";
28  
29      private static final String END = "\"></body></html>";
30  
31      static String getHtmlWithOnload(String... statements) {
32          requireNonNull(statements, "statements");
33  
34          final StringBuilder sb = new StringBuilder(BEGIN);
35          for (String statement : statements) {
36              sb.append(statement).append(';');
37          }
38          sb.append(END);
39          return sb.toString();
40      }
41  
42      private HtmlUtil() {}
43  }