+ * Creates a random {@code byte[]} secret of the specified size. + *
+ * + * @param size the size of the secret to be created, in bytes. + * + * @return a {@code byte[]} containing the generated secret. + */ + public static byte[] createRandomSecret(final int size) { + SecureRandom random = new SecureRandom(); + byte[] secret = new byte[size]; + random.nextBytes(secret); + return secret; + } +} diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2AuthnRequestBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2AuthnRequestBuilder.java similarity index 98% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2AuthnRequestBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2AuthnRequestBuilder.java index 8dd3436f99..40db78c5f3 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2AuthnRequestBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2AuthnRequestBuilder.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.exceptions.ConfigurationException; import org.keycloak.saml.processing.api.saml.v2.request.SAML2Request; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2ErrorResponseBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2ErrorResponseBuilder.java similarity index 95% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2ErrorResponseBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2ErrorResponseBuilder.java index 3ea4440423..db7ac7ebf0 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2ErrorResponseBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2ErrorResponseBuilder.java @@ -1,7 +1,6 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.constants.JBossSAMLURIConstants; -import org.keycloak.saml.common.exceptions.ConfigurationException; import org.keycloak.saml.common.exceptions.ProcessingException; import org.keycloak.saml.processing.api.saml.v2.response.SAML2Response; import org.keycloak.saml.processing.core.saml.v2.common.IDGenerator; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LoginResponseBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LoginResponseBuilder.java similarity index 99% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LoginResponseBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2LoginResponseBuilder.java index 0b7dfb4f22..9ca5f670d9 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LoginResponseBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LoginResponseBuilder.java @@ -1,4 +1,4 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.PicketLinkLogger; import org.keycloak.saml.common.PicketLinkLoggerFactory; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutRequestBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java similarity index 98% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutRequestBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java index 982927e107..a1c7c7ee17 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutRequestBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java @@ -1,4 +1,4 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.exceptions.ConfigurationException; import org.keycloak.saml.common.exceptions.ParsingException; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutResponseBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutResponseBuilder.java similarity index 98% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutResponseBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutResponseBuilder.java index 43aa1c9625..6710f71acf 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2LogoutResponseBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutResponseBuilder.java @@ -1,4 +1,4 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.constants.JBossSAMLURIConstants; import org.keycloak.saml.common.exceptions.ConfigurationException; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2NameIDPolicyBuilder.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2NameIDPolicyBuilder.java similarity index 97% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2NameIDPolicyBuilder.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAML2NameIDPolicyBuilder.java index cc395cbf9b..446ca3634d 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAML2NameIDPolicyBuilder.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAML2NameIDPolicyBuilder.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.dom.saml.v2.protocol.NameIDPolicyType; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAMLRequestParser.java b/saml/saml-core/src/main/java/org/keycloak/saml/SAMLRequestParser.java similarity index 98% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAMLRequestParser.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SAMLRequestParser.java index 65db552550..fb4fa0a854 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SAMLRequestParser.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SAMLRequestParser.java @@ -1,4 +1,4 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import org.keycloak.saml.common.PicketLinkLogger; import org.keycloak.saml.common.PicketLinkLoggerFactory; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SignatureAlgorithm.java b/saml/saml-core/src/main/java/org/keycloak/saml/SignatureAlgorithm.java similarity index 98% rename from saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SignatureAlgorithm.java rename to saml/saml-core/src/main/java/org/keycloak/saml/SignatureAlgorithm.java index b10f0ce4df..8df4bc3f26 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SignatureAlgorithm.java +++ b/saml/saml-core/src/main/java/org/keycloak/saml/SignatureAlgorithm.java @@ -1,4 +1,4 @@ -package org.keycloak.protocol.saml; +package org.keycloak.saml; import java.security.Signature; import java.util.HashMap; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/EntityDescriptorImporterService.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/EntityDescriptorImporterService.java index 2b6a72c7f1..8cdd302faf 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/EntityDescriptorImporterService.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/EntityDescriptorImporterService.java @@ -5,6 +5,7 @@ import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; import org.keycloak.models.ClientModel; import org.keycloak.models.RealmModel; import org.keycloak.models.utils.KeycloakModelUtils; +import org.keycloak.saml.SignatureAlgorithm; import org.keycloak.services.resources.admin.RealmAuth; import org.keycloak.saml.common.constants.JBossSAMLURIConstants; import org.keycloak.saml.common.exceptions.ConfigurationException; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/JaxrsSAML2BindingBuilder.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/JaxrsSAML2BindingBuilder.java index fc2b5e954a..36e58044f9 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/JaxrsSAML2BindingBuilder.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/JaxrsSAML2BindingBuilder.java @@ -1,5 +1,6 @@ package org.keycloak.protocol.saml; +import org.keycloak.saml.BaseSAML2BindingBuilder; import org.keycloak.saml.common.exceptions.ConfigurationException; import org.keycloak.saml.common.exceptions.ProcessingException; import org.w3c.dom.Document; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java index 42952304c7..4be6608d42 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java @@ -26,6 +26,11 @@ import org.keycloak.protocol.RestartLoginCookie; import org.keycloak.protocol.saml.mappers.SAMLAttributeStatementMapper; import org.keycloak.protocol.saml.mappers.SAMLLoginResponseMapper; import org.keycloak.protocol.saml.mappers.SAMLRoleListMapper; +import org.keycloak.saml.SAML2ErrorResponseBuilder; +import org.keycloak.saml.SAML2LoginResponseBuilder; +import org.keycloak.saml.SAML2LogoutRequestBuilder; +import org.keycloak.saml.SAML2LogoutResponseBuilder; +import org.keycloak.saml.SignatureAlgorithm; import org.keycloak.saml.common.constants.GeneralConstants; import org.keycloak.saml.common.constants.JBossSAMLURIConstants; import org.keycloak.saml.common.exceptions.ConfigurationException; diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocolUtils.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocolUtils.java index d865b2cdcd..bc18f3da96 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocolUtils.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlProtocolUtils.java @@ -2,6 +2,7 @@ package org.keycloak.protocol.saml; import org.keycloak.VerificationException; import org.keycloak.models.ClientModel; +import org.keycloak.saml.SignatureAlgorithm; import org.keycloak.saml.common.constants.GeneralConstants; import org.keycloak.saml.common.exceptions.ProcessingException; import org.keycloak.saml.processing.api.saml.v2.sig.SAML2Signature; @@ -23,22 +24,6 @@ import java.security.cert.Certificate; */ public class SamlProtocolUtils { - /** - *- * Creates a random {@code byte[]} secret of the specified size. - *
- * - * @param size the size of the secret to be created, in bytes. - * - * @return a {@code byte[]} containing the generated secret. - */ - public static byte[] createRandomSecret(final int size) { - SecureRandom random = new SecureRandom(); - byte[] secret = new byte[size]; - random.nextBytes(secret); - return secret; - } - public static void verifyDocumentSignature(ClientModel client, Document document) throws VerificationException { if (!"true".equals(client.getAttribute(SamlProtocol.SAML_CLIENT_SIGNATURE_ATTRIBUTE))) { diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java index 96b240ae90..0780e941c9 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java @@ -3,7 +3,6 @@ package org.keycloak.protocol.saml; import org.jboss.logging.Logger; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpResponse; -import org.jboss.resteasy.spi.NotFoundException; import org.keycloak.ClientConnection; import org.keycloak.VerificationException; import org.keycloak.authentication.AuthenticationProcessor; @@ -24,10 +23,12 @@ import org.keycloak.models.IdentityProviderModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.UserSessionModel; -import org.keycloak.models.utils.DefaultAuthenticationFlows; import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.protocol.RestartLoginCookie; import org.keycloak.protocol.oidc.utils.RedirectUtils; +import org.keycloak.saml.SAML2LogoutResponseBuilder; +import org.keycloak.saml.SAMLRequestParser; +import org.keycloak.saml.SignatureAlgorithm; import org.keycloak.saml.common.constants.GeneralConstants; import org.keycloak.saml.common.constants.JBossSAMLURIConstants; import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder;