本文整理汇总了Java中org.wso2.carbon.identity.core.util.IdentityTenantUtil类的典型用法代码示例。如果您正苦于以下问题:Java IdentityTenantUtil类的具体用法?Java IdentityTenantUtil怎么用?Java IdentityTenantUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentityTenantUtil类属于org.wso2.carbon.identity.core.util包,在下文中一共展示了IdentityTenantUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRegistryService
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
private void createRegistryService(Class realClass, WithRegistry withRegistry) {
try {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(withRegistry.tenantDomain());
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(withRegistry.tenantId());
RegistryContext registryContext = RegistryContext.getBaseInstance(IdentityTenantUtil.getRealmService());
DataSource dataSource = MockInitialContextFactory
.initializeDatasource(REG_DB_JNDI_NAME, realClass, new String[] { REG_DB_SQL_FILE });
registryContext.setDataAccessManager(new JDBCDataAccessManager(dataSource));
RegistryService registryService = new EmbeddedRegistryService(registryContext);
OSGiDataHolder.getInstance().setRegistryService(registryService);
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setRegistry(RegistryType.USER_GOVERNANCE, registryService.getRegistry());
Class[] singletonClasses = withRegistry.injectToSingletons();
injectSingletonVariables(registryService, RegistryService.class, singletonClasses);
} catch (RegistryException e) {
log.error("Error creating the registry.", e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:CarbonBasedTestListener.java
示例2: addToCache
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Add a cache entry.
*
* @param key Key which cache entry is indexed.
* @param entry Actual object where cache entry is placed.
*/
public void addToCache(AuthenticationContextCacheKey key, AuthenticationContextCacheEntry entry) {
super.addToCache(key, entry);
if (isTemporarySessionDataPersistEnabled) {
int tenantId = MultitenantConstants.INVALID_TENANT_ID;
String tenantDomain = entry.getContext().getTenantDomain();
if (tenantDomain != null) {
tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
}
if (entry.getContext() != null && entry.getContext().getProperties() != null) {
Iterator it = entry.getContext().getProperties().entrySet().iterator();
while (it.hasNext())
{
Map.Entry<String, Object> item = (Map.Entry<String, Object>) it.next();
if (!(item.getValue() instanceof Serializable)) {
it.remove();
}
}
SessionDataStore.getInstance().storeSessionData(key.getContextId(), AUTHENTICATION_CONTEXT_CACHE_NAME,
entry, tenantId);
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:AuthenticationContextCache.java
示例3: addLocalClaim
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Override
public void addLocalClaim(LocalClaim localClaim, String tenantDomain) throws ClaimMetadataException {
if (localClaim == null || StringUtils.isBlank(localClaim.getClaimURI())) {
throw new ClaimMetadataException("Local claim URI cannot be empty");
} else if (localClaim.getMappedAttributes().isEmpty()) {
throw new ClaimMetadataException("Mapped attribute of the claim dialect URI : " + localClaim
.getClaimDialectURI() + " and Claim URI : " + localClaim.getClaimURI() + " cannot be empty");
}
// TODO : validate claim dialect already exists?
// TODO : validate tenant domain?
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
// Add listener
this.localClaimDAO.addLocalClaim(localClaim, tenantId);
// Add listener
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:ClaimMetadataManagementServiceImpl.java
示例4: getExternalClaims
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Override
public List<ExternalClaim> getExternalClaims(String externalClaimDialectURI, String tenantDomain) throws
ClaimMetadataException {
if (StringUtils.isBlank(externalClaimDialectURI)) {
throw new ClaimMetadataException("External claim dialect URI cannot be empty");
}
if (ClaimConstants.LOCAL_CLAIM_DIALECT_URI.equalsIgnoreCase(externalClaimDialectURI)) {
throw new ClaimMetadataException("Invalid external claim dialect " + ClaimConstants
.LOCAL_CLAIM_DIALECT_URI);
}
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
// Add listener
List<ExternalClaim> externalClaims = this.externalClaimDAO.getExternalClaims(externalClaimDialectURI, tenantId);
// Add listener
return externalClaims;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:ClaimMetadataManagementServiceImpl.java
示例5: equals
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof User)) return false;
User user = (User) o;
if (!tenantDomain.equals(user.tenantDomain)) return false;
boolean isUsernameCaseSensitive = IdentityUtil.isUserStoreCaseSensitive(userStoreDomain,
IdentityTenantUtil.getTenantId(tenantDomain));
if(isUsernameCaseSensitive) {
if (!userName.equals(user.userName)) return false;
} else {
if (!userName.equalsIgnoreCase(user.userName)) return false;
}
if (!userStoreDomain.equals(user.userStoreDomain)) return false;
return true;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:User.java
示例6: testGetServiceProvider
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test
public void testGetServiceProvider() throws Exception {
mockStatic(IdentityTenantUtil.class);
RealmService mockRealmService = mock(RealmService.class);
TenantManager mockTenantManager = mock(TenantManager.class);
when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");
Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);
String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(path)).thenReturn(true);
when(mockRegistry.get(path)).thenReturn(dummyResource);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch");
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:SAMLSSOServiceProviderDAOTest.java
示例7: sendEmail
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
private void sendEmail(String userName, int tenantId, String notification) {
UserRecoveryDTO dto;
String tenantDomain = IdentityTenantUtil.getTenantDomain(tenantId);
if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
dto = new UserRecoveryDTO(userName);
} else {
UserDTO userDTO = new UserDTO(UserCoreUtil.addTenantDomainToEntry(userName, tenantDomain));
userDTO.setTenantId(tenantId);
dto = new UserRecoveryDTO(userDTO);
}
dto.setNotification(notification);
dto.setNotificationType(EMAIL_NOTIFICATION_TYPE);
try {
IdentityMgtServiceComponent.getRecoveryProcessor().recoverWithNotification(dto);
} catch (IdentityException e) {
//proceed with the rest of the flow even if the email is not sent
log.error("Email notification sending failed for user:" + userName + " for " + notification);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:IdentityMgtEventListener.java
示例8: addUser
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
public void addUser(UserDTO user) throws Exception {
UserFieldDTO[] userFieldDTOs = null;
Map<String, String> userClaims = null;
userFieldDTOs = user.getUserFields();
userClaims = new HashMap<String, String>();
if (userFieldDTOs != null) {
for (UserFieldDTO userFieldDTO : userFieldDTOs) {
userClaims.put(userFieldDTO.getClaimUri(), userFieldDTO.getFieldValue());
}
}
UserRealm realm = null;
String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(user.getUserName());
String tenantName = MultitenantUtils.getTenantDomain(user.getUserName());
realm = IdentityTenantUtil.getRealm(tenantName, null);
addUser(tenantAwareUserName, user.getPassword(), userClaims, null, realm);
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:UserRegistrationService.java
示例9: doPreDeleteUser
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Delete federated user account associations a user has upon deleting the local user account.
*
* @param userName
* @param userStoreManager
* @return
* @throws UserStoreException
*/
@Override
public boolean doPreDeleteUser(String userName,
UserStoreManager userStoreManager) throws UserStoreException {
if (!isEnable()) {
return true;
}
String userStoreDomain = UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration());
if (StringUtils.isBlank(userStoreDomain)) {
userStoreDomain = UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME;
}
int tenantId = userStoreManager.getTenantId();
if (log.isDebugEnabled()) {
log.debug("doPreDeleteUser method executed in ProfileMgtEventListener for user:" +
getFullQualifiedUsername(userName, userStoreDomain, IdentityTenantUtil.getTenantDomain(tenantId)));
}
deleteFederatedIdpAccountAssociations(userName, userStoreDomain, tenantId);
return true;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:ProfileMgtEventListener.java
示例10: getIdPByAuthenticatorPropertyValue
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* @param property IDP authenticator property (E.g.: IdPEntityId)
* @param value Value associated with given Property
* @param tenantDomain
* @return <code>IdentityProvider</code> Identity Provider information
* @throws IdentityProviderManagementException Error when getting Identity Provider
* information by authenticator property value
*/
@Override
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain,
boolean ignoreFileBasedIdps)
throws IdentityProviderManagementException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
if (StringUtils.isEmpty(property) || StringUtils.isEmpty(value)) {
String msg = "Invalid argument: Authenticator property or property value is empty";
throw new IdentityProviderManagementException(msg);
}
IdentityProvider identityProvider = dao.getIdPByAuthenticatorPropertyValue(
null, property, value, tenantId, tenantDomain);
if (identityProvider == null && !ignoreFileBasedIdps) {
identityProvider = new FileBasedIdPMgtDAO()
.getIdPByAuthenticatorPropertyValue(property, value, tenantDomain);
}
return identityProvider;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:IdentityProviderManager.java
示例11: getIdPByRealmId
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Retrieves Identity provider information about a given tenant by realm identifier
*
* @param realmId Unique realm identifier of the Identity provider of whose information is
* requested
* @param tenantDomain Tenant domain whose information is requested
* @throws IdentityProviderManagementException Error when getting Identity Provider
* information by IdP home realm identifier
*/
@Override
public IdentityProvider getIdPByRealmId(String realmId, String tenantDomain)
throws IdentityProviderManagementException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
if (StringUtils.isEmpty(realmId)) {
String msg = "Invalid argument: Identity Provider Home Realm Identifier value is empty";
throw new IdentityProviderManagementException(msg);
}
IdentityProvider identityProvider = dao.getIdPByRealmId(realmId, tenantId, tenantDomain);
if (identityProvider == null) {
identityProvider = new FileBasedIdPMgtDAO().getIdPByRealmId(realmId, tenantDomain);
}
return identityProvider;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:IdentityProviderManager.java
示例12: testProcessAuthenticationResponseWithBackupCode
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test(expectedExceptions = {AuthenticationFailedException.class})
public void testProcessAuthenticationResponseWithBackupCode() throws Exception {
mockStatic(IdentityTenantUtil.class);
mockStatic(SMSOTPUtils.class);
when(httpServletRequest.getParameter(SMSOTPConstants.CODE)).thenReturn("123456");
context.setProperty(SMSOTPConstants.OTP_TOKEN,"123");
context.setProperty(SMSOTPConstants.USER_NAME,"admin");
when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
when(SMSOTPUtils.getBackupCode(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("true");
when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
Whitebox.invokeMethod(smsotpAuthenticator, "processAuthenticationResponse",
httpServletRequest, httpServletResponse, context);
}
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:19,代码来源:SMSOTPAuthenticatorTest.java
示例13: testCheckWithBackUpCodes
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test
public void testCheckWithBackUpCodes() throws Exception {
mockStatic(IdentityTenantUtil.class);
context.setProperty(SMSOTPConstants.USER_NAME,"admin");
when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
when(userRealm.getUserStoreManager()
.getUserClaimValue(MultitenantUtils.getTenantAwareUsername("admin"),
SMSOTPConstants.SAVED_OTP_LIST, null)).thenReturn("12345,4568,1234,7896");
AuthenticatedUser user = (AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER);
Whitebox.invokeMethod(smsotpAuthenticator, "checkWithBackUpCodes",
context,"1234",user);
}
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:18,代码来源:SMSOTPAuthenticatorTest.java
示例14: testCheckWithInvalidBackUpCodes
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test(expectedExceptions = {AuthenticationFailedException.class})
public void testCheckWithInvalidBackUpCodes() throws Exception {
mockStatic(IdentityTenantUtil.class);
context.setProperty(SMSOTPConstants.USER_NAME,"admin");
when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
when(userRealm.getUserStoreManager()
.getUserClaimValue(MultitenantUtils.getTenantAwareUsername("admin"),
SMSOTPConstants.SAVED_OTP_LIST, null)).thenReturn("12345,4568,1234,7896");
AuthenticatedUser user = (AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER);
Whitebox.invokeMethod(smsotpAuthenticator, "checkWithBackUpCodes",
context,"45698789",user);
}
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:18,代码来源:SMSOTPAuthenticatorTest.java
示例15: testGetScreenAttribute
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test
public void testGetScreenAttribute() throws UserStoreException, AuthenticationFailedException {
mockStatic(IdentityTenantUtil.class);
mockStatic(SMSOTPUtils.class);
when(SMSOTPUtils.getScreenUserAttribute(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn
("http://wso2.org/claims/mobile");
when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when(userRealm.getUserStoreManager()
.getUserClaimValue("admin", "http://wso2.org/claims/mobile", null)).thenReturn("0778965231");
when(SMSOTPUtils.getNoOfDigits(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("4");
// with forward order
Assert.assertEquals(smsotpAuthenticator.getScreenAttribute(context,userRealm,"admin"),"0778");
// with backward order
when(SMSOTPUtils.getDigitsOrder(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("backward");
Assert.assertEquals(smsotpAuthenticator.getScreenAttribute(context,userRealm,"admin"),"5231");
}
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:22,代码来源:SMSOTPAuthenticatorTest.java
示例16: testIsSMSOTPDisableForLocalUser
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
@Test
public void testIsSMSOTPDisableForLocalUser() throws UserStoreException, AuthenticationFailedException,
SMSOTPException {
mockStatic(IdentityTenantUtil.class);
String username = "admin";
when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
when(SMSOTPUtils.isSMSOTPEnableOrDisableByUser(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
Map<String, String> claims = new HashMap<>();
claims.put(SMSOTPConstants.USER_SMSOTP_DISABLED_CLAIM_URI, "false");
userStoreManager.setUserClaimValues(MultitenantUtils.getTenantAwareUsername(username), claims, null);
Assert.assertEquals(SMSOTPUtils.isSMSOTPDisableForLocalUser(anyString(), context, SMSOTPConstants
.AUTHENTICATOR_NAME), false);
}
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:17,代码来源:SMSOTPUtilsTest.java
示例17: getTokenData
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Return the remember me token after validations. Expairy will be checked.
*
* @param rememberMe
* @return <code>OpenIDRememberMeDO</code>
* @throws IdentityProviderException
*/
public OpenIDRememberMeDO getTokenData(OpenIDRememberMeDO rememberMe) throws IdentityProviderException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
try {
prepStmt = connection.prepareStatement(OpenIDSQLQueries.LOAD_REMEMBER_ME_TOKEN);
prepStmt.setString(1, rememberMe.getUserName());
prepStmt.setInt(2, IdentityTenantUtil.getTenantIdOfUser(rememberMe.getUserName()));
OpenIDRememberMeDO openIDRememberMeDO = buildRememberMeDO(prepStmt.executeQuery(), rememberMe.getUserName());
connection.commit();
return openIDRememberMeDO;
} catch (SQLException e) {
throw new IdentityProviderException("Unable to load RememberMe token for " + rememberMe.getUserName(), e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:26,代码来源:OpenIDRememberMeTokenDAO.java
示例18: isTokenExist
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Check if the token already exist in the database.
*
* @param connection
* @param rememberMe
* @return
* @throws SQLException
*/
private boolean isTokenExist(Connection connection, OpenIDRememberMeDO rememberMe) throws SQLException {
PreparedStatement prepStmt = null;
ResultSet results = null;
boolean result = false;
try {
prepStmt = connection.prepareStatement(OpenIDSQLQueries.CHECK_REMEMBER_ME_TOKEN_EXIST);
prepStmt.setString(1, rememberMe.getUserName());
prepStmt.setInt(2, IdentityTenantUtil.getTenantIdOfUser(rememberMe.getUserName()));
results = prepStmt.executeQuery();
if (results.next()) {
result = true;
}
} finally {
IdentityDatabaseUtil.closeResultSet(results);
IdentityDatabaseUtil.closeStatement(prepStmt);
}
return result;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:31,代码来源:OpenIDRememberMeTokenDAO.java
示例19: updateTokenData
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Updates the OpenID RememberMe token in cache
*
* @param rememberMe
* @throws IdentityProviderException
*/
public synchronized void updateTokenData(OpenIDRememberMeDO rememberMe) throws IdentityProviderException {
String username = rememberMe.getUserName();
int tenantId = IdentityTenantUtil.getTenantIdOfUser(rememberMe.getUserName());
if (log.isDebugEnabled()) {
log.debug("Updating RememberMe token in cache for " + username + " with tenant ID " + tenantId);
}
OpenIDIdentityCacheKey key = new OpenIDIdentityCacheKey(tenantId, username);
// if the entry exist, remove it
if (rememberMeCache.getValueFromCache(key) != null) {
rememberMeCache.clearCacheEntry(key);
}
// now create a new entry
Date date = null;
if (rememberMe.getTimestamp() != null) {
date = new Date(rememberMe.getTimestamp().getTime());
} else {
date = new Date();
}
OpenIDIdentityCacheEntry entry = new OpenIDIdentityCacheEntry(rememberMe.getToken(), null, date);
// add the entry
rememberMeCache.addToCache(key, entry);
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:OpenIDRememberMeTokenCache.java
示例20: getTokenData
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; //导入依赖的package包/类
/**
* Returns the RememberMe token from cache
*
* @param rememberMe
* @return <code>OpenIDRememberMeDO</code>
* @throws IdentityProviderException
*/
public synchronized OpenIDRememberMeDO getTokenData(OpenIDRememberMeDO rememberMe)
throws IdentityProviderException {
String username = rememberMe.getUserName();
int tenantId = IdentityTenantUtil.getTenantIdOfUser(rememberMe.getUserName());
if (log.isDebugEnabled()) {
log.debug("Loading RememberMe token in cache for " + username + " with tenant ID " + tenantId);
}
OpenIDIdentityCacheKey key = new OpenIDIdentityCacheKey(tenantId, username);
OpenIDIdentityCacheEntry entry = rememberMeCache.getValueFromCache(key);
if (entry == null) {
return null;
}
rememberMe.setToken(entry.getCacheEntry());
Timestamp timestamp = new Timestamp(entry.getDate().getTime());
rememberMe.setTimestamp(timestamp);
return rememberMe;
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:27,代码来源:OpenIDRememberMeTokenCache.java
注:本文中的org.wso2.carbon.identity.core.util.IdentityTenantUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论