private void resetDefaultRealm() throws IOException { InputStream templateResource = new FileInputStream( getKrb5conf().getAbsolutePath()); String content = IOUtil.readInput(templateResource); content = content.replaceAll("default_realm = .*\n", "default_realm = " + getRealm() + "\n"); IOUtil.writeFile(content, getKrb5conf()); }
private void prepareKdcServer() throws Exception { // transport simpleKdc.setWorkDir(workDir); simpleKdc.setKdcHost(getHost()); simpleKdc.setKdcRealm(realm); if (transport == null) { transport = conf.getProperty(TRANSPORT); } if (port == 0) { port = NetworkUtil.getServerPort(); } if (transport != null) { if (transport.trim().equals("TCP")) { simpleKdc.setKdcTcpPort(port); simpleKdc.setAllowUdp(false); } else if (transport.trim().equals("UDP")) { simpleKdc.setKdcUdpPort(port); simpleKdc.setAllowTcp(false); } else { throw new IllegalArgumentException("Invalid transport: " + transport); } } else { throw new IllegalArgumentException("Need to set transport!"); } simpleKdc.getKdcConfig().setString(KdcConfigKey.KDC_SERVICE_NAME, conf.getProperty(INSTANCE)); if (conf.getProperty(DEBUG) != null) { krb5Debug = getAndSet(SUN_SECURITY_KRB5_DEBUG, conf.getProperty(DEBUG)); } }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(byte[] binaryData) { return Utf8.toString(encodeBase64(binaryData, false, true)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base64 alphabet. * * @param pArray * a byte array containing binary data * @return A String containing only Base64 character data * @since 1.4 */ public String encodeToString(byte[] pArray) { return Utf8.toString(encode(pArray)); }
/** * Read an input stream and return the content as string assuming UTF8. * @param in The input stream * @return The read String * @return The content * @throws IOException e */ public static String readInput(InputStream in) throws IOException { byte[] content = readInputStream(in); return Utf8.toString(content); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. * @since 1.4 */ public static byte[] encodeBase64URLSafe(byte[] binaryData) { return encodeBase64(binaryData, false, true); }
public HostPort(String host, int port) throws UnknownHostException { this.host = host; this.port = port; this.addr = Util.toInetAddress(host); }
/** * Flushes this output stream and forces any buffered output bytes to be written out to the stream. * * @throws java.io.IOException * if an I/O error occurs. */ public void flush() throws IOException { flush(true); }
/** * Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF. * * @param binaryData * binary data to encode * @return String containing Base64 characters. * @since 1.4 */ public static String encodeBase64String(byte[] binaryData) { return Utf8.toString(encodeBase64(binaryData, true)); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base64 alphabet. * * @param pArray * a byte array containing binary data * @return A String containing only Base64 character data * @since 1.4 */ public String encodeToString(byte[] pArray) { return Utf8.toString(encode(pArray)); }
/** * Read an input stream and return the content as string assuming UTF8. * @param in The input stream * @return The read String * @return The content * @throws IOException e */ public static String readInput(InputStream in) throws IOException { byte[] content = readInputStream(in); return Utf8.toString(content); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. * @since 1.4 */ public static byte[] encodeBase64URLSafe(byte[] binaryData) { return encodeBase64(binaryData, false, true); }
public HostPort(String host, int port) throws UnknownHostException { this.host = host; this.port = port; this.addr = Util.toInetAddress(host); }
/** * Flushes this output stream and forces any buffered output bytes to be written out to the stream. * * @throws java.io.IOException * if an I/O error occurs. */ public void flush() throws IOException { flush(true); }
/** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * * @param binaryData * binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(byte[] binaryData) { return Utf8.toString(encodeBase64(binaryData, false, true)); }
/** * Encodes binary data using the base64 algorithm into 76 character blocks separated by CRLF. * * @param binaryData * binary data to encode * @return String containing Base64 characters. * @since 1.4 */ public static String encodeBase64String(byte[] binaryData) { return Utf8.toString(encodeBase64(binaryData, true)); }