Merge pull request #1207 from patriot1burke/master
bump default key sizes
This commit is contained in:
commit
edfe7bd285
7 changed files with 23 additions and 27 deletions
|
@ -42,15 +42,13 @@ import org.keycloak.saml.processing.core.saml.v2.constants.X500SAMLProfileConsta
|
||||||
import org.keycloak.saml.processing.core.util.JAXPValidationUtil;
|
import org.keycloak.saml.processing.core.util.JAXPValidationUtil;
|
||||||
import org.keycloak.saml.processing.core.util.XMLEncryptionUtil;
|
import org.keycloak.saml.processing.core.util.XMLEncryptionUtil;
|
||||||
import org.keycloak.saml.processing.core.util.XMLSignatureUtil;
|
import org.keycloak.saml.processing.core.util.XMLSignatureUtil;
|
||||||
|
import org.keycloak.saml.processing.web.util.PostBindingUtil;
|
||||||
import org.keycloak.services.ErrorPage;
|
import org.keycloak.services.ErrorPage;
|
||||||
import org.keycloak.services.managers.AuthenticationManager;
|
import org.keycloak.services.managers.AuthenticationManager;
|
||||||
import org.keycloak.services.messages.Messages;
|
import org.keycloak.services.messages.Messages;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.keycloak.services.ErrorPage;
|
|
||||||
import org.keycloak.services.managers.AuthenticationManager;
|
|
||||||
import org.keycloak.services.messages.Messages;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
|
@ -447,7 +445,9 @@ public class SAMLEndpoint {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected SAMLDocumentHolder extractResponseDocument(String response) {
|
protected SAMLDocumentHolder extractResponseDocument(String response) {
|
||||||
return SAMLRequestParser.parseResponsePostBinding(response);
|
byte[] samlBytes = PostBindingUtil.base64Decode(response);
|
||||||
|
String xml = new String(samlBytes);
|
||||||
|
return SAMLRequestParser.parseResponseDocument(samlBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -111,7 +111,9 @@ public final class KeycloakModelUtils {
|
||||||
public static void generateRealmKeys(RealmModel realm) {
|
public static void generateRealmKeys(RealmModel realm) {
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
keyPair = generator.generateKeyPair();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +144,9 @@ public final class KeycloakModelUtils {
|
||||||
String subject = client.getClientId();
|
String subject = client.getClientId();
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
keyPair = generator.generateKeyPair();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,9 @@ public class ProxyServerBuilder {
|
||||||
log.warn("Generating temporary SSL cert");
|
log.warn("Generating temporary SSL cert");
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
keyPair = generator.generateKeyPair();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,20 +119,6 @@ public class KeyStoreUtil {
|
||||||
return ks;
|
return ks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a Key Pair
|
|
||||||
*
|
|
||||||
* @param algo (RSA, DSA etc)
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*
|
|
||||||
* @throws GeneralSecurityException
|
|
||||||
*/
|
|
||||||
public static KeyPair generateKeyPair(String algo) throws GeneralSecurityException {
|
|
||||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance(algo);
|
|
||||||
return kpg.genKeyPair();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Public Key from the keystore
|
* Get the Public Key from the keystore
|
||||||
*
|
*
|
||||||
|
|
|
@ -47,9 +47,12 @@ public class SAMLRequestParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SAMLDocumentHolder parseResponsePostBinding(String samlMessage) {
|
public static SAMLDocumentHolder parseResponsePostBinding(String samlMessage) {
|
||||||
InputStream is;
|
|
||||||
byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
|
byte[] samlBytes = PostBindingUtil.base64Decode(samlMessage);
|
||||||
is = new ByteArrayInputStream(samlBytes);
|
return parseResponseDocument(samlBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SAMLDocumentHolder parseResponseDocument(byte[] samlBytes) {
|
||||||
|
InputStream is = new ByteArrayInputStream(samlBytes);
|
||||||
SAML2Response response = new SAML2Response();
|
SAML2Response response = new SAML2Response();
|
||||||
try {
|
try {
|
||||||
response.getSAML2ObjectFromStream(is);
|
response.getSAML2ObjectFromStream(is);
|
||||||
|
@ -61,8 +64,7 @@ public class SAMLRequestParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SAMLDocumentHolder parseResponseRedirectBinding(String samlMessage) {
|
public static SAMLDocumentHolder parseResponseRedirectBinding(String samlMessage) {
|
||||||
InputStream is;
|
InputStream is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
|
||||||
is = RedirectBindingUtil.base64DeflateDecode(samlMessage);
|
|
||||||
SAML2Response response = new SAML2Response();
|
SAML2Response response = new SAML2Response();
|
||||||
try {
|
try {
|
||||||
response.getSAML2ObjectFromStream(is);
|
response.getSAML2ObjectFromStream(is);
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class TokenManager {
|
||||||
throw new OAuthErrorException(OAuthErrorException.INVALID_GRANT, "Invalid refresh token");
|
throw new OAuthErrorException(OAuthErrorException.INVALID_GRANT, "Invalid refresh token");
|
||||||
}
|
}
|
||||||
refreshToken = jws.readJsonContent(RefreshToken.class);
|
refreshToken = jws.readJsonContent(RefreshToken.class);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
throw new OAuthErrorException(OAuthErrorException.INVALID_GRANT, "Invalid refresh token", e);
|
throw new OAuthErrorException(OAuthErrorException.INVALID_GRANT, "Invalid refresh token", e);
|
||||||
}
|
}
|
||||||
if (refreshToken.isExpired()) {
|
if (refreshToken.isExpired()) {
|
||||||
|
|
|
@ -111,7 +111,9 @@ public class ClientAttributeCertificateResource {
|
||||||
String subject = client.getClientId();
|
String subject = client.getClientId();
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
|
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||||
|
generator.initialize(2048);
|
||||||
|
keyPair = generator.generateKeyPair();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue