Skip to content
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

Remove unnecessary registry usages #400

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext;
import org.wso2.carbon.identity.application.authentication.framework.listener.SessionContextMgtListener;
import org.wso2.carbon.registry.core.utils.UUIDGenerator;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -66,9 +66,9 @@ public Map<String, String> onPreCreateSession(String sessionId, HttpServletReque
}
if (IdentityTenantUtil.isTenantedSessionsEnabled()) {
// Add suffix to the session id for identify saml sso token id cookies which has a tenanted path.
sessionId = UUIDGenerator.generateUUID() + SAMLSSOConstants.TENANT_QUALIFIED_TOKEN_ID_COOKIE_SUFFIX;
sessionId = UUID.randomUUID() + SAMLSSOConstants.TENANT_QUALIFIED_TOKEN_ID_COOKIE_SUFFIX;
} else {
sessionId = UUIDGenerator.generateUUID();
sessionId = UUID.randomUUID().toString();
}
}
Map<String, String> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.context.RegistryType;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementValidationException;
Expand All @@ -34,7 +32,6 @@
import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderDTO;
import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderInfoDTO;
import org.wso2.carbon.identity.sso.saml.util.SAMLSSOUtil;
import org.wso2.carbon.registry.core.Registry;

import java.io.ByteArrayInputStream;
import java.io.StringWriter;
Expand Down Expand Up @@ -284,12 +281,6 @@ public void doExportServiceProvider(ServiceProvider serviceProvider, Boolean exp
}
}

private Registry getConfigSystemRegistry() {

return (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType
.SYSTEM_CONFIGURATION);
}

/**
* Validate inbound auth SAML configurations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import org.wso2.carbon.identity.sso.saml.internal.IdentitySAMLSSOServiceComponentHolder;
import org.wso2.carbon.identity.sso.saml.session.SSOSessionPersistenceManager;
import org.wso2.carbon.identity.sso.saml.util.SAMLSSOUtil;
import org.wso2.carbon.registry.core.utils.UUIDGenerator;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class IdPInitSSOAuthnRequestProcessor implements SSOAuthnRequestProcessor {

Expand Down Expand Up @@ -116,7 +116,7 @@ public SAMLSSORespDTO process(SAMLSSOAuthnReqDTO authnReqDTO, String sessionId,
sessionIndexId = sessionPersistenceManager.getSessionIndexFromTokenId(sessionId,
authnReqDTO.getLoggedInTenantDomain());
} else {
sessionIndexId = UUIDGenerator.generateUUID();
sessionIndexId = UUID.randomUUID().toString();
sessionPersistenceManager.persistSession(sessionId, sessionIndexId,
authnReqDTO.getLoggedInTenantDomain());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
import org.wso2.carbon.identity.sso.saml.internal.IdentitySAMLSSOServiceComponentHolder;
import org.wso2.carbon.identity.sso.saml.session.SSOSessionPersistenceManager;
import org.wso2.carbon.identity.sso.saml.util.SAMLSSOUtil;
import org.wso2.carbon.registry.core.utils.UUIDGenerator;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class SPInitSSOAuthnRequestProcessor implements SSOAuthnRequestProcessor{

Expand Down Expand Up @@ -103,7 +103,7 @@ public SAMLSSORespDTO process(SAMLSSOAuthnReqDTO authnReqDTO, String sessionId,
sessionIndexId = sessionPersistenceManager.getSessionIndexFromTokenId(sessionId,
authnReqDTO.getLoggedInTenantDomain());
} else {
sessionIndexId = UUIDGenerator.generateUUID();
sessionIndexId = UUID.randomUUID().toString();
sessionPersistenceManager.persistSession(sessionId, sessionIndexId,
authnReqDTO.getLoggedInTenantDomain());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import org.wso2.carbon.identity.sso.saml.util.SAMLSOAPUtils;
import org.wso2.carbon.identity.sso.saml.util.SAMLSSOUtil;
import org.wso2.carbon.idp.mgt.util.IdPManagementUtil;
import org.wso2.carbon.registry.core.utils.UUIDGenerator;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;

Expand All @@ -99,6 +98,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
Expand Down Expand Up @@ -827,7 +827,7 @@ private void sendToFrameworkForAuthentication(HttpServletRequest req, HttpServle
sessionDTO.setProperties(signInRespDTO.getProperties());
sessionDTO.setLoggedInTenantDomain(getLoggedInTenantDomain(req));

String sessionDataKey = UUIDGenerator.generateUUID();
String sessionDataKey = UUID.randomUUID().toString();
addSessionDataToCache(sessionDataKey, sessionDTO);

String selfPath = ServiceURLBuilder.create().addPath(req.getContextPath()).build().getRelativeInternalURL();
Expand Down Expand Up @@ -910,7 +910,7 @@ private void sendToFrameworkForLogout(HttpServletRequest request, HttpServletRes
sessionDTO.setValidationRespDTO(signInRespDTO);
}

String sessionDataKey = UUIDGenerator.generateUUID();
String sessionDataKey = UUID.randomUUID().toString();
addSessionDataToCache(sessionDataKey, sessionDTO);

String selfPath = ServiceURLBuilder.create().addPath(request.getContextPath()).build().getRelativeInternalURL();
Expand Down Expand Up @@ -1240,7 +1240,7 @@ private String getSamlSSOTokenIdFromSessionContext(AuthenticationResult authenti
log.debug("Session context identifier is not found in the authentication result.");
}
}
return UUIDGenerator.generateUUID();
return UUID.randomUUID().toString();
}

private void handleLogoutResponseFromFramework(HttpServletRequest request, HttpServletResponse response,
Expand Down