Java源码示例:org.wso2.carbon.identity.base.IdentityException
示例1
private String buildFilter(String filter) {
if (StringUtils.isNotBlank(filter)) {
try {
FilterTreeBuilder filterTreeBuilder = new FilterTreeBuilder(filter);
Node rootNode = filterTreeBuilder.buildTree();
if (rootNode instanceof ExpressionNode) {
ExpressionNode expressionNode = (ExpressionNode) rootNode;
if (SEARCH_SUPPORTED_FIELDS.contains(expressionNode.getAttributeValue())) {
return generateFilterStringForBackend(expressionNode.getAttributeValue(), expressionNode
.getOperation(), expressionNode.getValue());
} else {
throw buildClientError(ErrorMessage.UNSUPPORTED_FILTER_ATTRIBUTE, expressionNode
.getAttributeValue());
}
} else {
throw buildClientError(ErrorMessage.INVALID_FILTER_FORMAT);
}
} catch (IOException | IdentityException e) {
throw buildClientError(ApplicationManagementConstants.ErrorMessage.INVALID_FILTER_FORMAT, null);
}
} else {
return null;
}
}
示例2
/**
* @param authRequest OpenID authentication request
* @return A set of policies requested
* @throws IdentityException
*/
public static String[] getAuthenticationPolicies(AuthRequest authRequest) throws IdentityException {
MessageExtension message = null;
PapeRequest papeRequest = null;
List preferredPolicies = null;
try {
if (authRequest.hasExtension(PapeMessage.OPENID_NS_PAPE)) {
message = authRequest.getExtension(PapeMessage.OPENID_NS_PAPE);
if (message instanceof PapeRequest) {
papeRequest = (PapeRequest) message;
preferredPolicies = papeRequest.getPreferredAuthPoliciesList();
if (preferredPolicies != null && !preferredPolicies.isEmpty()) {
return (String[]) preferredPolicies.toArray(new String[preferredPolicies.size()]);
}
}
}
return new String[0];
} catch (MessageException e) {
throw IdentityException.error("Failed retrieve authentication policies", e);
}
}
示例3
private static void rollbackSAMLSpRemoval(SAMLSSOServiceProviderDTO oldSAMLSp) {
if (oldSAMLSp != null) {
if (logger.isDebugEnabled()) {
String issuer =
SAMLSSOUtil.getIssuerWithQualifier(oldSAMLSp.getIssuer(), oldSAMLSp.getIssuerQualifier());
logger.debug("Error occurred while updating SAML SP with issuer: " + issuer +
". Attempting to rollback by recreating the old SAML SP.");
}
try {
getSamlSsoConfigService().addRPServiceProvider(oldSAMLSp);
} catch (IdentityException e) {
throw handleException(e);
}
}
}
示例4
/**
* @param userId
* @param tenant
* @throws IdentityException
*/
@Override
public void invalidate(String userId, int tenant) throws IdentityException {
PreparedStatement prepStmt = null;
Connection connection = null;
try {
connection = IdentityDatabaseUtil.getDBConnection();
prepStmt = connection.prepareStatement(SQLQuery.INVALIDATE_METADATA);
prepStmt.setString(1, userId.toLowerCase());
prepStmt.setInt(2, tenant);
prepStmt.execute();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw IdentityException.error("Error while invalidating user identity data", e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
示例5
public static String decodeForPost(String encodedStr)
throws IdentityException {
try {
org.apache.commons.codec.binary.Base64 base64Decoder = new org.apache.commons.codec.binary.Base64();
byte[] xmlBytes = encodedStr.getBytes("UTF-8");
byte[] base64DecodedByteArray = base64Decoder.decode(xmlBytes);
String decodedString = new String(base64DecodedByteArray, "UTF-8");
if (log.isDebugEnabled()) {
log.debug("Request message " + decodedString);
}
return decodedString;
} catch (IOException e) {
throw IdentityException.error(
"Error when decoding the SAML Request.", e);
}
}
示例6
/**
* @param registry
* @param paramName
* @param value
* @throws IdentityException
*/
public void createOrUpdateParameter(Registry registry, String paramName, String value)
throws IdentityException {
if (paramName == null || value == null) {
throw IdentityException.error("Invalid inputs");
}
ParameterDO param = null;
param = new ParameterDO();
paramName = paramName.trim();
param.setName(paramName);
param.setValue(value);
ParameterDAO dao = new ParameterDAO(registry);
dao.createOrUpdateParameter(param);
}
示例7
/**
* @param metadataSet
* @throws IdentityException
*/
public void invalidateMetadataSet(IdentityMetadataDO[] metadataSet) throws IdentityException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
try {
prepStmt = connection.prepareStatement(SQLQuery.INVALIDATE_METADATA);
for (IdentityMetadataDO metadata : metadataSet) {
prepStmt.setString(1, metadata.getUserName());
prepStmt.setInt(2, metadata.getTenantId());
prepStmt.setString(3, metadata.getMetadataType());
prepStmt.setString(4, metadata.getMetadata());
prepStmt.addBatch();
}
prepStmt.executeBatch();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw IdentityException.error("Error while invalidating user identity data", e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
示例8
protected void loadClaims(String userIdentifier) throws IdentityProviderException {
IdentityClaimManager claimManager = null;
Claim[] claims = null;
if (log.isDebugEnabled()) {
log.debug("Loading claims");
}
try {
claimManager = IdentityClaimManager.getInstance();
claims = claimManager.getAllSupportedClaims(UserCoreConstants.DEFAULT_CARBON_DIALECT,
IdentityTenantUtil.getRealm(null, userIdentifier));
for (int i = 0; i < claims.length; i++) {
Claim temp = claims[i];
supportedClaims.put(temp.getClaimUri(), temp);
}
} catch (IdentityException e) {
log.error("Error while loading claims", e);
throw new IdentityProviderException("Error while loading claims", e);
}
}
示例9
/**
* Builds the SAML error response and sets the compressed value to the reqValidationResponseDTO
*
* @param id
* @param status
* @param statMsg
* @param destination
* @return
* @throws IdentityException
*/
private SAMLSSOReqValidationResponseDTO buildErrorResponse(String id, String status, String statMsg, String
destination, String responseSigningAlgorithmUri, String responseDigestAlgorithmUri)
throws IdentityException {
SAMLSSOReqValidationResponseDTO reqValidationResponseDTO = new SAMLSSOReqValidationResponseDTO();
LogoutResponse logoutResp = new SingleLogoutMessageBuilder().buildLogoutResponse(id, status, statMsg,
destination, false, null, responseSigningAlgorithmUri, responseDigestAlgorithmUri);
reqValidationResponseDTO.setLogOutReq(true);
reqValidationResponseDTO.setValid(false);
try {
reqValidationResponseDTO.setResponse(SAMLSSOUtil.compressResponse(SAMLSSOUtil.marshall(logoutResp)));
} catch (IOException e) {
throw IdentityException.error("Error while creating logout response", e);
}
return reqValidationResponseDTO;
}
示例10
/**
* This method sets user claim values in user store
*
* @param userStoreManager userStoreManager object
* @param username user name
* @param claims set of claims
* @param profile profile
* @throws IdentityException
*/
protected void setUserClaimsValuesInUserStore(UserStoreManager userStoreManager,
String username,
Map<String, String> claims, String profile) throws IdentityException {
try {
// We are calling the doSetUserClaimsValues() method of the userstore to prevent Identity Management
// listener being called once again for claim value set events.
if (userStoreManager instanceof JDBCUserStoreManager) {
((JDBCUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
} else if (userStoreManager instanceof ActiveDirectoryUserStoreManager) {
((ActiveDirectoryUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
} else if (userStoreManager instanceof ReadWriteLDAPUserStoreManager) {
((ReadWriteLDAPUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
} else {
String msg = "Cannot persist identity data to userstore for user:%s. Unsupported userstore type:%s to" +
" be used as UserStoreBasedIdentityDataStore.";
throw IdentityException.error(String.format(msg, username, userStoreManager.getClass().getName()));
}
} catch (org.wso2.carbon.user.api.UserStoreException e) {
throw IdentityException.error("Error while persisting identity user data in to user store for user: "
+ username, e);
}
}
示例11
private boolean isUserNameWithAllowedDomainName(String userName, UserRealm realm)
throws IdentityException {
int index;
index = userName.indexOf("/");
// Check whether we have a secondary UserStoreManager setup.
if (index > 0) {
// Using the short-circuit. User name comes with the domain name.
try {
return !realm.getRealmConfiguration().isRestrictedDomainForSlefSignUp(
userName.substring(0, index));
} catch (UserStoreException e) {
throw IdentityException.error(e.getMessage(), e);
}
}
return true;
}
示例12
/**
* @param ppid
* @return
* @throws IdentityException
*/
public String getOAuthConsumerSecret(String consumerKey) throws IdentityException {
String path = null;
Resource resource = null;
if (log.isDebugEnabled()) {
log.debug("Retreiving user for OAuth consumer key " + consumerKey);
}
try {
path = RegistryConstants.PROFILES_PATH + consumerKey;
if (registry.resourceExists(path)) {
resource = registry.get(path);
return resource.getProperty(IdentityRegistryResources.OAUTH_CONSUMER_PATH);
} else {
return null;
}
} catch (RegistryException e) {
log.error("Error while retreiving user for OAuth consumer key " + consumerKey, e);
throw IdentityException.error("Error while retreiving user for OAuth consumer key "
+ consumerKey, e);
}
}
示例13
/**
* get all challenge questions
*
* @return array of questions
* @throws IdentityMgtServiceException if fails
*/
public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException {
ChallengeQuestionProcessor processor = IdentityMgtServiceComponent.
getRecoveryProcessor().getQuestionProcessor();
List<ChallengeQuestionDTO> questionDTOs = null;
try {
questionDTOs = processor.getAllChallengeQuestions();
} catch (IdentityException e) {
String errorMessage = "Error while loading user challenge questions";
log.error(errorMessage, e);
throw new IdentityMgtServiceException(errorMessage);
}
return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]);
}
示例14
/**
* Returns oAuth consumer secret for a give consumer key.
*
* @param consumerKey consumer key
* @return oAuth consumer secret
* @throws IdentityException if error occurs while obtaining the consumer secret
*/
public String getOAuthConsumerSecret(String consumerKey) throws IdentityException {
String path = null;
Resource resource = null;
if (log.isDebugEnabled()) {
log.debug("Retreiving user for OAuth consumer key " + consumerKey);
}
try {
path = RegistryConstants.PROFILES_PATH + consumerKey;
if (registry.resourceExists(path)) {
resource = registry.get(path);
return resource.getProperty(IdentityRegistryResources.OAUTH_CONSUMER_PATH);
} else {
return null;
}
} catch (RegistryException e) {
log.error("Error while retreiving user for OAuth consumer key " + consumerKey, e);
throw IdentityException.error("Error while retreiving user for OAuth consumer key "
+ consumerKey, e);
}
}
示例15
/**
* gets no of verified user challenges
*
* @param userDTO bean class that contains user and tenant Information
* @return no of verified challenges
* @throws IdentityException if fails
*/
public static int getVerifiedChallenges(UserDTO userDTO) throws IdentityException {
int noOfChallenges = 0;
try {
UserRegistry registry = IdentityMgtServiceComponent.getRegistryService().
getConfigSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
String identityKeyMgtPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_CHALLENGES +
RegistryConstants.PATH_SEPARATOR + userDTO.getUserId() +
RegistryConstants.PATH_SEPARATOR + userDTO.getUserId();
Resource resource;
if (registry.resourceExists(identityKeyMgtPath)) {
resource = registry.get(identityKeyMgtPath);
String property = resource.getProperty(IdentityMgtConstants.VERIFIED_CHALLENGES);
if (property != null) {
return Integer.parseInt(property);
}
}
} catch (RegistryException e) {
log.error("Error while processing userKey", e);
}
return noOfChallenges;
}
示例16
/**
* @param request
* @return
* @throws AxisFault
*/
private IWAAuthenticatorStub getIWAClient(HttpServletRequest request)
throws AxisFault, IdentityException {
HttpSession session = request.getSession();
ServletContext servletContext = session.getServletContext();
String backendServerURL = request.getParameter("backendURL");
if (backendServerURL == null) {
backendServerURL = CarbonUIUtil.getServerURL(servletContext, request.getSession());
}
ConfigurationContext configContext = (ConfigurationContext) servletContext
.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String serviceEPR = backendServerURL + "IWAAuthenticator";
IWAAuthenticatorStub stub = new IWAAuthenticatorStub(configContext, serviceEPR);
ServiceClient client = stub._getServiceClient();
client.engageModule("rampart");
Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
Policy signOnly = IdentityBaseUtil.getSignOnlyPolicy();
Policy mergedPolicy = signOnly.merge(rampartConfig);
Options options = client.getOptions();
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, mergedPolicy);
options.setManageSession(true);
return stub;
}
示例17
/**
* We build the parser using the recursive descent parser technique.
*/
private void factor() throws IdentityException {
symbol = nextSymbol();
if (symbol.equals(String.valueOf(IdentityCoreConstants.Filter.NOT))) {
OperationNode not = new OperationNode(IdentityCoreConstants.Filter.NOT);
factor();
not.setRightNode(root);
root = not;
} else if (symbol.equals(String.valueOf("("))) {
expression();
symbol = nextSymbol(); // We don't care about ')'.
} else {
if (!(symbol.equals(String.valueOf(")")))) {
ExpressionNode expressionNode = new ExpressionNode();
validateAndBuildFilterExpression(symbol, expressionNode);
root = expressionNode;
symbol = nextSymbol();
} else {
throw new IdentityException("Invalid argument: Identity Provider filter name value is empty or " +
"invalid symbol: " + symbol);
}
}
}
示例18
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);
}
}
示例19
/**
* Stores identity data.
*
* @throws IdentityException
*/
@Override
public void store(UserRecoveryDataDO recoveryDataDO) throws IdentityException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
try {
prepStmt = connection.prepareStatement(SQLQuery.STORE_META_DATA);
prepStmt.setString(1, recoveryDataDO.getUserName().toLowerCase());
prepStmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
prepStmt.setString(3, recoveryDataDO.getCode().toLowerCase());
prepStmt.setString(4, recoveryDataDO.getSecret());
prepStmt.setString(5, recoveryDataDO.getExpireTime());
prepStmt.execute();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw IdentityException.error("Error while storing user identity data", e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
示例20
private boolean isUserNameWithAllowedDomainName(String userName, UserRealm realm)
throws IdentityException {
int index;
index = userName.indexOf("/");
// Check whether we have a secondary UserStoreManager setup.
if (index > 0) {
// Using the short-circuit. User name comes with the domain name.
try {
return !realm.getRealmConfiguration().isRestrictedDomainForSlefSignUp(
userName.substring(0, index));
} catch (UserStoreException e) {
throw IdentityException.error(e.getMessage(), e);
}
}
return true;
}
示例21
private static UserRealm getRealmForAnonymousSession(String domainName, String username)
throws IdentityException {
try {
if (username != null) {
return AnonymousSessionUtil.getRealmByUserName(registryService, realmService,
username);
}
if (domainName == null) {
domainName = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
return AnonymousSessionUtil.getRealmByTenantDomain(registryService, realmService,
domainName);
} catch (CarbonException e) {
throw IdentityException.error("Error Obtaining a realm for user name: " + username + " and " +
"domain:" + domainName, e);
}
}
示例22
/**
* This service method will return back all available password validation regular expressions
* against the corresponding domain names.
*
* @return
* @throws IdentityException
*/
public PasswordRegExDTO[] getPasswordRegularExpressions() throws IdentityException {
UserRealm realm = null;
realm = IdentityTenantUtil.getRealm(null, null);
List<PasswordRegExDTO> passwordRegExList = new ArrayList<PasswordRegExDTO>();
PasswordRegExDTO passwordRegEx;
try {
UserStoreManager manager = realm.getUserStoreManager();
String domainName;
String regEx;
while (manager != null) {
domainName = manager.getRealmConfiguration().getUserStoreProperty(
UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
regEx = manager.getRealmConfiguration().getUserStoreProperty(
UserCoreConstants.RealmConfig.PROPERTY_JS_REG_EX);
if (regEx != null && regEx.length() > 0) {
passwordRegEx = new PasswordRegExDTO();
passwordRegEx.setDomainName(domainName);
passwordRegEx.setRegEx(regEx);
passwordRegExList.add(passwordRegEx);
}
manager = manager.getSecondaryUserStoreManager();
}
} catch (UserStoreException e) {
log.error(e);
throw IdentityException.error(
"Error occured while loading password validation regular expressions.");
}
return passwordRegExList.toArray(new PasswordRegExDTO[passwordRegExList.size()]);
}
示例23
/**
* Invalidates the identity metadata
*
* @param userName
* @param tenantId
* @param metadataType
* @param metadata
* @throws IdentityException
*/
public static void invalidateUserIdentityMetadata(String userName, int tenantId, String metadataType,
String metadata) throws IdentityException {
JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
UserRecoveryDataDO metadataDO =
new UserRecoveryDataDO(userName, tenantId, metadataType,
metadata);
store.invalidate(metadataDO);
}
示例24
/**
* Get all challenge questions
*
* @return array of questions
* @throws IdentityMgtServiceException if fails
*/
public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException {
ChallengeQuestionProcessor processor = IdentityMgtServiceComponent.
getRecoveryProcessor().getQuestionProcessor();
List<ChallengeQuestionDTO> questionDTOs = null;
try {
questionDTOs = processor.getAllChallengeQuestions();
} catch (IdentityException e) {
log.error("Error while loading user challenges", e);
throw new IdentityMgtServiceException("Error while loading user challenges");
}
return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]);
}
示例25
/**
* @param userName
* @param tenantId
* @return
*/
public List<String> getChallengeQuestionUris(String userName, int tenantId) throws IdentityMgtServiceException{
if (log.isDebugEnabled()) {
log.debug("Challenge Question from the user profile.");
}
List<String> challenges = new ArrayList<String>();
String claimValue = null;
String[] challengesUris;
try {
claimValue = Utils.getClaimFromUserStoreManager(userName, tenantId,
"http://wso2.org/claims/challengeQuestionUris");
} catch (IdentityException e) {
throw new IdentityMgtServiceException("Error while getting cliams.", e);
}
if (claimValue != null) {
if (claimValue.contains(IdentityMgtConfig.getInstance().getChallengeQuestionSeparator())) {
challengesUris = claimValue.split(IdentityMgtConfig.getInstance().getChallengeQuestionSeparator());
} else {
challengesUris = new String[]{claimValue.trim()};
}
for (String challengesUri : challengesUris) {
if (StringUtils.isNotBlank(challengesUri)) {
challenges.add(challengesUri.trim());
}
}
}
return challenges;
}
示例26
/**
* Validating the access token. Should be equal in the scope where the original request token
* been issued to.If this matches, the method returns the user who authorized the request token.
*
* @param consumerKey Consumer Key
* @param oauthToken Access Token
* @param reqScope Scope in the request
* @return Authorized Username
* @throws IdentityException Error when reading token information from persistence store or invalid token or invalid scope.
*/
public String validateAccessToken(String consumerKey, String oauthToken, String reqScope)
throws IdentityException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
ResultSet resultSet = null;
String scope = null;
String authorizedUser = null;
try {
prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.GET_ACCESS_TOKEN);
prepStmt.setString(1, oauthToken);
resultSet = prepStmt.executeQuery();
if (resultSet.next()) {
scope = resultSet.getString(1);
authorizedUser = resultSet.getString(2);
} else {
throw IdentityException.error("Invalid access token : " + oauthToken);
}
connection.commit();
} catch (SQLException e) {
throw new IdentityOAuthAdminException("Error when reading the callback url for consumer key : " +
consumerKey, e);
} finally {
IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
}
if (reqScope != null && reqScope.equals(scope)) {
return authorizedUser;
} else {
throw IdentityException.error("Scope of the access token doesn't match with the original scope");
}
}
示例27
@Override
public void removeServiceProviderConfiguration(String issuer) throws IdentityApplicationManagementException {
try {
IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager();
Registry configSystemRegistry = (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().
getRegistry(RegistryType.SYSTEM_CONFIGURATION);
persistenceManager.removeServiceProvider(configSystemRegistry, issuer);
} catch (IdentityException e) {
log.error("Erro while deleting the issuer", e);
throw new IdentityApplicationManagementException("Error while deleting SAML issuer " + e.getMessage());
}
}
示例28
public static IdentityClaimManager getInstance() throws IdentityException {
// Enables attempted thread-safety using double-check locking
if (claimManager == null) {
synchronized (lock) {
if (claimManager == null) {
claimManager = new IdentityClaimManager();
if (log.isDebugEnabled()) {
log.debug("IdentityClaimManager singleton instance created successfully");
}
}
}
}
return claimManager;
}
示例29
/**
* Stores identity data set.
*
* @throws IdentityException
*/
@Override
@Deprecated
public void store(UserRecoveryDataDO[] recoveryDataDOs) throws IdentityException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
try {
prepStmt = connection.prepareStatement(SQLQuery.STORE_META_DATA);
for (UserRecoveryDataDO dataDO : recoveryDataDOs) {
prepStmt.setString(1, dataDO.getUserName().toLowerCase());
prepStmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
prepStmt.setString(3, dataDO.getCode().toLowerCase());
prepStmt.setString(4, dataDO.getSecret());
prepStmt.setString(5, dataDO.getExpireTime());
prepStmt.addBatch();
}
prepStmt.executeBatch();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw IdentityException.error("Error while storing user identity data", e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
示例30
private void addThriftSession(ThriftSession thriftSession) throws IdentityException {
//add to cache
authenticatedSessions.put(thriftSession.getSessionId(), thriftSession);
//add to database
ThriftSessionDAO sessionDAO = this.thriftSessionDAO.getInstance();
sessionDAO.addSession(thriftSession);
}