-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce JDBC based persistence for SAML #6241
base: master
Are you sure you want to change the base?
Conversation
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6241 +/- ##
============================================
+ Coverage 45.66% 45.87% +0.20%
- Complexity 14080 14183 +103
============================================
Files 1632 1636 +4
Lines 100764 101283 +519
Branches 17705 17781 +76
============================================
+ Hits 46016 46462 +446
- Misses 48036 48058 +22
- Partials 6712 6763 +51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -0,0 +1,193 @@ | |||
/* | |||
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix licenses
|
||
package org.wso2.carbon.identity.core.dao; | ||
|
||
public class SAMLSSOServiceProviderConstants { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a class comment
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
return this.value; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
package org.wso2.carbon.identity.core.model; | ||
|
||
/** | ||
* This class represents a tuple of key and value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we improve a class comment a bit, indicating how this class related to the SAML
return StringUtils.isNotBlank(ISSUER_QUALIFIER) ? | ||
issuer + IdentityRegistryResources.QUALIFIER_ID + ISSUER_QUALIFIER : issuer; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
@@ -0,0 +1,49 @@ | |||
package org.wso2.carbon.identity.core.constant; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add licenses
public static final String UPDATED_ISSUER_QUALIFIER = "updatedIssuerQualifier"; | ||
public static final boolean UPDATED_DO_SINGLE_LOGOUT = false; | ||
public static final String[] UPDATED_REQUESTED_RECIPIENTS = {"updatedRecipient1", "updatedRecipient2"}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
@@ -0,0 +1,65 @@ | |||
package org.wso2.carbon.identity.core.util; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add licenses.
--SAML-- | ||
CREATE INDEX IDX_SAML2_SP_ISSUER ON IDN_SAML2_SERVICE_PROVIDER (ISSUER, TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
/ | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); | ||
/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
-- SAML -- | ||
CREATE INDEX IDX_SAML2_SP_ISSUER ON IDN_SAML2_SERVICE_PROVIDER (ISSUER, TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
@@ -1700,4 +1752,4 @@ GO | |||
-- Trigger AUTHORIZED_API delete by API_ID on API_RESOURCE deletion by ID -- | |||
CREATE TRIGGER API_RESOURCE_DELETE_TRIGGER ON API_RESOURCE INSTEAD OF DELETE AS BEGIN DELETE FROM AUTHORIZED_API WHERE API_ID IN (SELECT ID FROM DELETED) DELETE FROM API_RESOURCE WHERE ID IN (SELECT ID FROM deleted) END; | |||
|
|||
GO | |||
GO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
-- SAML -- | ||
CREATE INDEX IDX_SAML2_SP_ISSUER ON IDN_SAML2_SERVICE_PROVIDER (ISSUER, TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
--SAML-- | ||
CREATE INDEX IDX_SAML2_SP_ISSUER ON IDN_SAML2_SERVICE_PROVIDER (ISSUER, TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
/ | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); | ||
/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
/ | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); | ||
/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
-- SAML -- | ||
CREATE INDEX IDX_SAML2_SP_ISSUER ON IDN_SAML2_SERVICE_PROVIDER (ISSUER, TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_TENANT_ID ON IDN_SAML2_SERVICE_PROVIDER (TENANT_ID); | ||
CREATE INDEX IDX_SAML2_SP_PROPERTIES ON IDN_SAML2_SP_PROPERTIES (SP_ID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
import static org.wso2.carbon.identity.core.dao.SAMLSSOServiceProviderConstants.SAML2TableColumns.SP_ID; | ||
|
||
import static java.time.ZoneOffset.UTC; | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
import java.util.Date; | ||
import java.util.TimeZone; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove new line.
return certificateId != null ? certificateId : -1; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
throws IdentityException { | ||
/** | ||
|
||
Registry registry = getRegistry(tenantId); | ||
* Add the service provider information to the registry. | ||
|
||
* @param serviceProviderDO Service provider information object. | ||
|
||
* @return True if addition successful. | ||
|
||
* @throws IdentityException Error while persisting to the registry. | ||
|
||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the method comment.
registry = getRegistry(tenantId); | ||
// Registry registry = getRegistry(tenantId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registry = getRegistry(tenantId);
part should be removed.
Registry registry = getRegistry(tenantId);
part should be uncommented.
@@ -78,6 +81,8 @@ public class SAMLSSOServiceProviderDO implements Serializable { | |||
private boolean doFrontChannelLogout; | |||
private String frontChannelLogoutBinding; | |||
|
|||
private static final String BACKCHANNEL_LOGOUT_BINDING = "BackChannel"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to move out this constant to a constants class.
/** | ||
* Implementation of the SAMLSSOServiceProviderDAO interface for JDBC-based persistence. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the new line.
} | ||
|
||
private void setServiceProviderParameters(NamedPreparedStatement statement, | ||
SAMLSSOServiceProviderDO serviceProviderDO, int tenantId) throws SQLException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a new line here
* @param serviceProviderDO | ||
* @param tenant | ||
* @return | ||
* @throws SQLException | ||
* @throws CertificateRetrievingException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add descriptions for parameters and return values
private X509Certificate getApplicationCertificate(SAMLSSOServiceProviderDO serviceProviderDO, Tenant tenant) | ||
throws CertificateRetrievingException, DataAccessException { | ||
|
||
// Check whether there is a certificate stored against the service provider (in the database) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Check whether there is a certificate stored against the service provider (in the database) | |
// Check whether there is a certificate stored against the service provider (in the database). |
/** | ||
* Returns the certificate reference ID for the given issuer (Service Provider) if there is one. | ||
* | ||
* @param issuer | ||
* @return | ||
* @throws SQLException | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add description for parameters and return statements
|
||
} | ||
|
||
// IDN_SAML2_SERVICE_PROVIDER table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// IDN_SAML2_SERVICE_PROVIDER table | |
// IDN_SAML2_SERVICE_PROVIDER table. |
@@ -0,0 +1,49 @@ | |||
package org.wso2.carbon.identity.core.constant; | |||
|
|||
public class TestConstants { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the class comment.
|
||
import static org.mockito.Mockito.spy; | ||
|
||
public class TestUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the class comment here.
throw new RuntimeException("No data source initiated for database: " + DB_NAME); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the missing new line here.
CREATE OR REPLACE TRIGGER IDN_SAML2_SERVICE_PROVIDER_TRIG | ||
BEFORE INSERT | ||
ON IDN_SAML2_SERVICE_PROVIDER | ||
REFERENCING NEW AS NEW | ||
FOR EACH ROW | ||
BEGIN | ||
SELECT IDN_SAML2_SERVICE_PROVIDER_SEQ.nextval INTO :NEW.ID FROM dual; | ||
END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the indentation to align with other queries.
CREATE OR REPLACE TRIGGER IDN_SAML2_SP_PROPERTIES_TRIG | ||
BEFORE INSERT | ||
ON IDN_SAML2_SP_PROPERTIES | ||
REFERENCING NEW AS NEW | ||
FOR EACH ROW | ||
BEGIN | ||
SELECT IDN_SAML2_SP_PROPERTIES_SEQ.nextval INTO :NEW.ID FROM dual; | ||
END |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the indentation to align with other queries.
Proposed changes in this pull request
Introduce JDBC based persistence for SAML. Related to,