commit
92058b16c9
18 changed files with 31 additions and 41 deletions
|
@ -2,7 +2,6 @@ package org.keycloak;
|
|||
|
||||
import org.keycloak.util.KeycloakUriBuilder;
|
||||
|
||||
import java.security.KeyStore;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -12,7 +11,9 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class AbstractOAuthClient {
|
||||
public static final String OAUTH_TOKEN_REQUEST_STATE = "OAuth_Token_Request_State";
|
||||
private static final String OAUTH_TOKEN_REQUEST_STATE = "OAuth_Token_Request_State";
|
||||
private final AtomicLong counter = new AtomicLong();
|
||||
|
||||
protected String clientId;
|
||||
protected Map<String, String> credentials;
|
||||
protected String authUrl;
|
||||
|
@ -23,8 +24,6 @@ public class AbstractOAuthClient {
|
|||
protected String stateCookiePath;
|
||||
protected boolean isSecure;
|
||||
protected boolean publicClient;
|
||||
protected final AtomicLong counter = new AtomicLong();
|
||||
|
||||
protected String getStateCode() {
|
||||
return counter.getAndIncrement() + "/" + UUID.randomUUID().toString();
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import java.security.Principal;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class KeycloakPrincipal implements Principal, Serializable {
|
||||
protected String name;
|
||||
protected String surrogate;
|
||||
protected final String name;
|
||||
protected final String surrogate;
|
||||
|
||||
public KeycloakPrincipal(String name, String surrogate) {
|
||||
this.name = name;
|
||||
|
|
|
@ -27,7 +27,7 @@ public class RSATokenVerifier {
|
|||
}
|
||||
if (!verified) throw new VerificationException("Token signature not validated");
|
||||
|
||||
AccessToken token = null;
|
||||
AccessToken token;
|
||||
try {
|
||||
token = input.readJsonContent(AccessToken.class);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.keycloak.jose.jws;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
import org.codehaus.jackson.annotate.JsonProperty;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.map.annotate.JsonSerialize;
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class HMACProvider {
|
||||
public static String getJavaAlgorithm(Algorithm alg) {
|
||||
private static String getJavaAlgorithm(Algorithm alg) {
|
||||
switch (alg) {
|
||||
case HS256:
|
||||
return "HMACSHA256";
|
||||
|
@ -28,7 +28,7 @@ public class HMACProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public static Mac getMAC(final Algorithm alg) {
|
||||
private static Mac getMAC(final Algorithm alg) {
|
||||
|
||||
try {
|
||||
return Mac.getInstance(getJavaAlgorithm(alg));
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Set;
|
|||
*/
|
||||
public class ProviderFactoryLoader<T extends Provider> implements Iterable<ProviderFactory<T>> {
|
||||
|
||||
private Map<String, ProviderFactory<T>> factories = new HashMap<String, ProviderFactory<T>>();
|
||||
private final Map<String, ProviderFactory<T>> factories = new HashMap<String, ProviderFactory<T>>();
|
||||
|
||||
private ProviderFactoryLoader(ServiceLoader<? extends ProviderFactory> serviceLoader) {
|
||||
for (ProviderFactory p : serviceLoader) {
|
||||
|
@ -59,9 +59,9 @@ public class ProviderFactoryLoader<T extends Provider> implements Iterable<Provi
|
|||
|
||||
private class LazyProviderFactory<T extends Provider> implements ProviderFactory<T> {
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
private final ProviderFactory<T> factory;
|
||||
|
||||
private ProviderFactory<T> factory;
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
private LazyProviderFactory(ProviderFactory<T> factory) {
|
||||
this.factory = factory;
|
||||
|
|
|
@ -15,6 +15,7 @@ public class LogoutAction extends AdminAction {
|
|||
public LogoutAction(String id, int expiration, String resource, String user, int notBefore) {
|
||||
super(id, expiration, resource, LOGOUT);
|
||||
this.user = user;
|
||||
this.notBefore = notBefore;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.keycloak.representations.adapters.action;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.keycloak.representations.idm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ package org.keycloak.representations.idm;
|
|||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
public class ErrorRepresentation {
|
||||
public String errorMessage;
|
||||
private String errorMessage;
|
||||
|
||||
public ErrorRepresentation() {
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.keycloak.representations.idm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
|
@ -221,7 +221,6 @@ public class Encode
|
|||
private static String decodeBytes(String enc, CharsetDecoder decoder)
|
||||
{
|
||||
Matcher matcher = encodedChars.matcher(enc);
|
||||
StringBuffer buf = new StringBuffer();
|
||||
ByteBuffer bytes = ByteBuffer.allocate(enc.length() / 3);
|
||||
while (matcher.find())
|
||||
{
|
||||
|
@ -268,7 +267,7 @@ public class Encode
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public static boolean savePathParams(String segment, StringBuffer newSegment, List<String> params)
|
||||
private static boolean savePathParams(String segment, StringBuffer newSegment, List<String> params)
|
||||
{
|
||||
boolean foundParam = false;
|
||||
// Regular expressions can have '{' and '}' characters. Replace them to do match
|
||||
|
@ -293,7 +292,7 @@ public class Encode
|
|||
* @param encoding
|
||||
* @return
|
||||
*/
|
||||
public static String encodeValue(String segment, String[] encoding)
|
||||
private static String encodeValue(String segment, String[] encoding)
|
||||
{
|
||||
ArrayList<String> params = new ArrayList<String>();
|
||||
boolean foundParam = false;
|
||||
|
@ -395,7 +394,7 @@ public class Encode
|
|||
return encodeFromArray(nameOrValue, queryNameValueEncoding, true);
|
||||
}
|
||||
|
||||
protected static String encodeFromArray(String segment, String[] encodingMap, boolean encodePercent)
|
||||
private static String encodeFromArray(String segment, String[] encodingMap, boolean encodePercent)
|
||||
{
|
||||
StringBuffer result = new StringBuffer();
|
||||
for (int i = 0; i < segment.length(); i++)
|
||||
|
@ -445,7 +444,7 @@ public class Encode
|
|||
return encoded;
|
||||
}
|
||||
|
||||
public static String pathParamReplacement(String segment, List<String> params)
|
||||
private static String pathParamReplacement(String segment, List<String> params)
|
||||
{
|
||||
StringBuffer newSegment = new StringBuffer();
|
||||
Matcher matcher = PARAM_REPLACEMENT.matcher(segment);
|
||||
|
|
|
@ -55,8 +55,8 @@ public class KeycloakUriBuilder {
|
|||
return impl;
|
||||
}
|
||||
|
||||
public static final Pattern opaqueUri = Pattern.compile("^([^:/?#]+):([^/].*)");
|
||||
public static final Pattern hierarchicalUri = Pattern.compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
|
||||
private static final Pattern opaqueUri = Pattern.compile("^([^:/?#]+):([^/].*)");
|
||||
private static final Pattern hierarchicalUri = Pattern.compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
|
||||
private static final Pattern hostPortPattern = Pattern.compile("([^/:]+):(\\d+)");
|
||||
|
||||
public static boolean compare(String s1, String s2) {
|
||||
|
@ -149,7 +149,6 @@ public class KeycloakUriBuilder {
|
|||
Matcher hostPortMatch = hostPortPattern.matcher(host);
|
||||
if (hostPortMatch.matches()) {
|
||||
this.host = hostPortMatch.group(1);
|
||||
int val = 0;
|
||||
try {
|
||||
this.port = Integer.parseInt(hostPortMatch.group(2));
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -359,12 +358,12 @@ public class KeycloakUriBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public URI buildFromMap(Map<String, ? extends Object> values) throws IllegalArgumentException {
|
||||
public URI buildFromMap(Map<String, ?> values) throws IllegalArgumentException {
|
||||
if (values == null) throw new IllegalArgumentException("values parameter is null");
|
||||
return buildUriFromMap(values, false, true);
|
||||
}
|
||||
|
||||
public URI buildFromEncodedMap(Map<String, ? extends Object> values) throws IllegalArgumentException {
|
||||
public URI buildFromEncodedMap(Map<String, ?> values) throws IllegalArgumentException {
|
||||
if (values == null) throw new IllegalArgumentException("values parameter is null");
|
||||
return buildUriFromMap(values, true, false);
|
||||
}
|
||||
|
@ -374,7 +373,7 @@ public class KeycloakUriBuilder {
|
|||
return buildUriFromMap(values, false, encodeSlashInPath);
|
||||
}
|
||||
|
||||
protected URI buildUriFromMap(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean encodeSlash) throws IllegalArgumentException {
|
||||
protected URI buildUriFromMap(Map<String, ?> paramMap, boolean fromEncodedMap, boolean encodeSlash) throws IllegalArgumentException {
|
||||
String buf = buildString(paramMap, fromEncodedMap, false, encodeSlash);
|
||||
try {
|
||||
return URI.create(buf);
|
||||
|
@ -383,7 +382,7 @@ public class KeycloakUriBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private String buildString(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, boolean encodeSlash) {
|
||||
private String buildString(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, boolean encodeSlash) {
|
||||
for (Map.Entry<String, ? extends Object> entry : paramMap.entrySet()) {
|
||||
if (entry.getKey() == null) throw new IllegalArgumentException("map key is null");
|
||||
if (entry.getValue() == null) throw new IllegalArgumentException("map value is null");
|
||||
|
@ -448,11 +447,10 @@ public class KeycloakUriBuilder {
|
|||
}
|
||||
|
||||
public static Matcher createUriParamMatcher(String string) {
|
||||
Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBraces(string));
|
||||
return matcher;
|
||||
return PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBraces(string));
|
||||
}
|
||||
|
||||
protected StringBuffer replaceParameter(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash) {
|
||||
protected StringBuffer replaceParameter(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer, boolean encodeSlash) {
|
||||
Matcher matcher = createUriParamMatcher(string);
|
||||
while (matcher.find()) {
|
||||
String param = matcher.group(1);
|
||||
|
@ -481,7 +479,7 @@ public class KeycloakUriBuilder {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
protected StringBuffer replaceQueryStringParameter(Map<String, ? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer) {
|
||||
protected StringBuffer replaceQueryStringParameter(Map<String, ?> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer) {
|
||||
Matcher matcher = createUriParamMatcher(string);
|
||||
while (matcher.find()) {
|
||||
String param = matcher.group(1);
|
||||
|
|
|
@ -42,7 +42,6 @@ public class MultivaluedHashMap<K, V> extends HashMap<K, List<V>>
|
|||
if (list == null)
|
||||
{
|
||||
add(key, value);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -76,8 +76,7 @@ public final class PemUtils {
|
|||
*/
|
||||
public static byte[] pemToDer(InputStream is) throws IOException {
|
||||
String pem = pemFromStream(is);
|
||||
byte[] der = pemToDer(pem);
|
||||
return der;
|
||||
return pemToDer(pem);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.ServiceLoader;
|
|||
*/
|
||||
public class ProviderLoader<T> implements Iterable<T> {
|
||||
|
||||
private ServiceLoader<T> serviceLoader;
|
||||
private final ServiceLoader<T> serviceLoader;
|
||||
|
||||
public static <T> Iterable<T> load(Class<T> service) {
|
||||
ServiceLoader<T> providers = ServiceLoader.load(service);
|
||||
|
@ -26,7 +26,7 @@ public class ProviderLoader<T> implements Iterable<T> {
|
|||
|
||||
private static class ProviderIterator<T> implements Iterator<T> {
|
||||
|
||||
private Iterator<T> itr;
|
||||
private final Iterator<T> itr;
|
||||
|
||||
private T next;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public final class StreamUtil {
|
|||
char[] buffer = new char[1024];
|
||||
StringBuilder builder = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
int wasRead = 0;
|
||||
int wasRead;
|
||||
do
|
||||
{
|
||||
wasRead = reader.read(buffer, 0, 1024);
|
||||
|
|
|
@ -195,7 +195,7 @@ public class ResourceAdminManager {
|
|||
String token = new TokenManager().encodeToken(realm, adminAction);
|
||||
logger.infov("logout user: {0} resource: {1} url: {2}", user, resource.getName(), managementUrl);
|
||||
ClientRequest request = client.createRequest(UriBuilder.fromUri(managementUrl).path(AdapterConstants.K_LOGOUT).build().toString());
|
||||
ClientResponse response = null;
|
||||
ClientResponse response;
|
||||
try {
|
||||
response = request.body(MediaType.TEXT_PLAIN_TYPE, token).post(UserStats.class);
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue