public static KerberosJdkProvider getProvider() { if (Environment.IS_IBM_JAVA) { return new IBMJDKProvider(); } else { return new SunJDKProvider(); } }
public static String serializeCredential(KerberosTicket kerberosTicket, GSSCredential gssCredential) throws KerberosSerializationException { try { if (gssCredential == null) { throw new KerberosSerializationException("Null credential given as input"); } kerberosTicket = KerberosJdkProvider.getProvider().gssCredentialToKerberosTicket(kerberosTicket, gssCredential); return serialize(kerberosTicket); } catch (IOException e) { throw new KerberosSerializationException("Unexpected exception when serialize GSSCredential", e); } }
/** * Encodes everything of a query parameter name or value. * * @param nameOrValue * @return */ public static String encodeQueryParamAsIs(String nameOrValue) { return encodeFromArray(nameOrValue, queryNameValueEncoding, true); }
@Override public String getQueryParamValue(String param) { if (queryParameters == null) { queryParameters = UriUtils.decodeQueryString(request.getQueryString()); } return queryParameters.getFirst(param); }
/** * Convenience function that gets first value of an attribute by attribute name * * @param name * @return */ public String getAttribute(String name) { return attributes.getFirst(name); }
private static byte[] pemToDer(String pem) throws IOException { pem = removeBeginEnd(pem); return Base64.decode(pem); }
public KeycloakUriBuilder segment(String... segments) throws IllegalArgumentException { if (segments == null) throw new IllegalArgumentException("segments parameter was null"); for (String segment : segments) { if (segment == null) throw new IllegalArgumentException("A segment is null"); path(Encode.encodePathSegment(segment)); } return this; }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode( String s ) throws java.io.IOException { return decode( s, NO_OPTIONS ); }
public final List<V> getList(K key) { List<V> list = get(key); if (list == null) { list = createListInstance(); List<V> existing = putIfAbsent(key, list); if (existing != null) { list = existing; } } return list; }
@Override public String getRemoteAddr() { // TODO: implement properly return HostUtils.getIpAddress(); }
/** * Keep any valid encodings from string i.e. keep "%2D" but don't keep "%p" * * @param segment * @return */ public static String encodePathSegmentSaveEncodings(String segment) { String result = encodeFromArray(segment, pathSegmentEncoding, false); result = encodeNonCodes(result); return result; }
public ComponentModel(ComponentModel copy) { this.id = copy.id; this.name = copy.name; this.providerId = copy.providerId; this.providerType = copy.providerType; this.parentId = copy.parentId; this.subType = copy.subType; this.config.addAll(copy.config); }
/** * Keep encoded values "%..." and template parameters intact. */ public static String encodeMatrixParam(String value) { return encodeValue(value, matrixParameterEncoding); }
public KeycloakUriBuilder replacePath(String path) { if (path == null) { this.path = null; return this; } this.path = Encode.encodePath(path); return this; }
@Override public String getProperty(String key, String defaultValue) { String value = getProperty(key); return value != null ? value : defaultValue; }
@Override public String getQueryParamValue(String paramName) { if (queryParameters == null) { queryParameters = UriUtils.decodeQueryString(request.getQueryString()); } return queryParameters.getFirst(paramName); }
/** * Keep any valid encodings from string i.e. keep "%2D" but don't keep "%p" * * @param segment * @return */ public static String encodeQueryParamSaveEncodings(String segment) { String result = encodeFromArray(segment, queryNameValueEncoding, false); result = encodeNonCodes(result); return result; }
/** * Encode via <a href="http://ietf.org/rfc/rfc3986.txt">RFC 3986</a>. PCHAR is allowed allong with '/' * <p/> * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" * / "*" / "+" / "," / ";" / "=" * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" */ public static String encodePathAsIs(String segment) { return encodeFromArray(segment, pathEncoding, true); }
/** * Keep encoded values "%...", matrix parameters and template parameters intact. */ public static String encodePathSegment(String value) { return encodeValue(value, pathSegmentEncoding); }
/** * Encode via <a href="http://ietf.org/rfc/rfc3986.txt">RFC 3986</a>. PCHAR is allowed allong with '/' * <p/> * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" * / "*" / "+" / "," / ";" / "=" * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" */ public static String encodePathSegmentAsIs(String segment) { return encodeFromArray(segment, pathSegmentEncoding, true); }