本文整理汇总了Java中org.wso2.carbon.identity.core.util.IdentityUtil类的典型用法代码示例。如果您正苦于以下问题:Java IdentityUtil类的具体用法?Java IdentityUtil怎么用?Java IdentityUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentityUtil类属于org.wso2.carbon.identity.core.util包,在下文中一共展示了IdentityUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getUser
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Build user object from complete username
* @param userName
* @return
*/
public static UserDTO getUser(String userName) {
if (userName == null) {
return null;
}
String userStoreDomain = IdentityUtil.extractDomainFromName(userName);
String tenantDomain = MultitenantUtils.getTenantDomain(userName);
String userNameWithoutTenantDomainAndUserStoreDomain = MultitenantUtils
.getTenantAwareUsername(UserCoreUtil.removeDomainFromName(userName));
UserDTO user = new UserDTO();
user.setUsername(userNameWithoutTenantDomainAndUserStoreDomain);
user.setRealm(userStoreDomain);
user.setTenantDomain(tenantDomain);
return user;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:AuthenticationEndpointUtil.java
示例2: init
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
public void init(InitConfig initConfig) {
this.initConfig = initConfig;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
(HttpIdentityResponseFactory.class.getName(), this.getClass().getName());
if (identityEventListenerConfig == null) {
return;
}
if(identityEventListenerConfig.getProperties() != null) {
for(Map.Entry<Object,Object> property:identityEventListenerConfig.getProperties().entrySet()) {
String key = (String)property.getKey();
String value = (String)property.getValue();
if(!properties.containsKey(key)) {
properties.setProperty(key, value);
} else {
log.warn("Property key " + key + " already exists. Cannot add property!!");
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:HttpIdentityResponseFactory.java
示例3: init
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Initialize IdentityProcessor
*
* @param initConfig IdentityProcessor properties
*/
public void init(InitConfig initConfig) {
if(initConfig != null) {
this.initConfig = initConfig;
}
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
(IdentityProcessor.class.getName(), this.getClass().getName());
if (identityEventListenerConfig == null) {
return;
}
if(identityEventListenerConfig.getProperties() != null) {
for(Map.Entry<Object,Object> property:identityEventListenerConfig.getProperties().entrySet()) {
String key = (String)property.getKey();
String value = (String)property.getValue();
if(!properties.containsKey(key)) {
properties.setProperty(key, value);
} else {
log.warn("Property key " + key + " already exists. Cannot add property!!");
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:IdentityProcessor.java
示例4: isUserExistsInUserStore
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Check whether the authenticated user exists in any user store that belongs to the realm the user belongs to.
*
* @param authenticatedUserName
* @param tenantDomain
* @param userStoreDomain
* @return
*/
private boolean isUserExistsInUserStore(String authenticatedUserName, String tenantDomain, String userStoreDomain)
throws
AuthenticationFailedException {
UserStoreManager userStoreManager;
try {
String userNameWithUserStoreDomain = IdentityUtil.addDomainToName(authenticatedUserName, userStoreDomain);
userStoreManager = getPrimaryUserStoreManager(tenantDomain);
// check whether the user exists in the given user store domain
return userStoreManager.isExistingUser(userNameWithUserStoreDomain);
} catch (UserStoreException e) {
String errorMsg = "Error when searching for user: %s in '%s' userStoreDomain in '%s' tenant.";
throw new AuthenticationFailedException(
String.format(errorMsg, authenticatedUserName, userStoreDomain, tenantDomain), e);
}
}
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:25,代码来源:IWAFederatedAuthenticator.java
示例5: setConfigFilePaths
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Set jaas.conf and krb5 paths
*/
public static void setConfigFilePaths() {
String jaasConfigPath = System.getProperty(IWAConstants.JAAS_CONFIG_PROPERTY);
String krb5ConfigPath = System.getProperty(IWAConstants.KERBEROS_CONFIG_PROPERTY);
String identityConfPath = Paths.get(CarbonUtils.getCarbonConfigDirPath(), "identity").toString();
// Set jaas.conf file path if not set by the system property already.
if (IdentityUtil.isBlank(jaasConfigPath)) {
jaasConfigPath = Paths.get(identityConfPath, IWAConstants.JAAS_CONF_FILE_NAME).toString();
System.setProperty(IWAConstants.JAAS_CONFIG_PROPERTY, jaasConfigPath);
}
// Set the krb5.conf file if not set by the system property already.
if (IdentityUtil.isBlank(krb5ConfigPath)) {
krb5ConfigPath = Paths.get(identityConfPath, IWAConstants.KERBEROS_CONF_FILE_NAME).toString();
System.setProperty(IWAConstants.KERBEROS_CONFIG_PROPERTY, krb5ConfigPath);
}
if (log.isDebugEnabled()) {
log.debug("Kerberos jaas.conf file path set to : " + jaasConfigPath);
log.debug("Kerberos krb5.conf file path set to : " + krb5ConfigPath);
}
}
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:27,代码来源:IWAAuthenticationUtil.java
示例6: setAuthenticatedSubjectIdentifier
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Sets authenticated subject identifier according to the useTenantDomainInLocalSubjectIdentifier and
* useUserstoreDomainInLocalSubjectIdentifier properties.
*
* @param authenticatedSubjectIdentifier authenticated subject identifier
* @param serviceProvider service provider
*/
public void setAuthenticatedSubjectIdentifier(String authenticatedSubjectIdentifier, ServiceProvider serviceProvider) {
if (!isFederatedUser() && serviceProvider != null) {
boolean useUserstoreDomainInLocalSubjectIdentifier = serviceProvider.getLocalAndOutBoundAuthenticationConfig()
.isUseUserstoreDomainInLocalSubjectIdentifier();
boolean useTenantDomainInLocalSubjectIdentifier = serviceProvider.getLocalAndOutBoundAuthenticationConfig()
.isUseTenantDomainInLocalSubjectIdentifier();
if (useUserstoreDomainInLocalSubjectIdentifier && StringUtils.isNotEmpty(userStoreDomain)) {
authenticatedSubjectIdentifier = IdentityUtil.addDomainToName(userName, userStoreDomain);
}
if (useTenantDomainInLocalSubjectIdentifier && StringUtils.isNotEmpty(tenantDomain)) {
authenticatedSubjectIdentifier = UserCoreUtil.addTenantDomainToEntry(authenticatedSubjectIdentifier,
tenantDomain);
}
}
this.authenticatedSubjectIdentifier = authenticatedSubjectIdentifier;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:AuthenticatedUser.java
示例7: readTenantDataListenerURLs
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
private void readTenantDataListenerURLs(OMElement documentElement) {
OMElement tenantDataURLsElem =
documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(
FrameworkConstants.Config.QNAME_TENANT_DATA_LISTENER_URLS));
if (tenantDataURLsElem != null) {
for (Iterator tenantDataURLElems = tenantDataURLsElem.getChildrenWithLocalName(
FrameworkConstants.Config.ELEM_TENANT_DATA_LISTENER_URL);
tenantDataURLElems.hasNext(); ) {
OMElement tenantDataListenerURLElem = (OMElement) tenantDataURLElems.next();
if (tenantDataListenerURLElem != null &&
StringUtils.isNotEmpty(tenantDataListenerURLElem.getText())) {
tenantDataEndpointURLs.add(IdentityUtil.fillURLPlaceholders(tenantDataListenerURLElem.getText()));
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:FileBasedConfigurationBuilder.java
示例8: evaluate
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Evaluates the given XACML request and returns the Response
*
* @param requestCtx Balana Object model for request
* @param xacmlRequest Balana Object model for request
* @return ResponseCtx Balana Object model for response
*/
public ResponseCtx evaluate(AbstractRequestCtx requestCtx, String xacmlRequest) {
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_REQUEST)) {
log.debug("XACML Request : " + xacmlRequest);
}
ResponseCtx xacmlResponse;
if ((xacmlResponse = (ResponseCtx) getFromCache(xacmlRequest, false)) != null) {
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
log.debug("XACML Response : " + xacmlResponse);
}
return xacmlResponse;
}
xacmlResponse = pdp.evaluate(requestCtx);
addToCache(xacmlRequest, xacmlResponse, false);
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.XACML_RESPONSE)) {
log.debug("XACML Response : " + xacmlResponse);
}
return xacmlResponse;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:EntitlementEngine.java
示例9: PAPPolicyReader
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
private PAPPolicyReader(PolicyFinder policyFinder) {
this.policyFinder = policyFinder;
// create the factory
DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory();
documentBuilderFactory.setIgnoringComments(true);
// now use the factory to create the document builder
try {
builder = documentBuilderFactory.newDocumentBuilder();
builder.setErrorHandler(this);
} catch (ParserConfigurationException pce) {
throw new IllegalArgumentException("Failed to create the DocumentBuilder. : ", pce);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:PAPPolicyReader.java
示例10: unmarshall
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Constructing the SAML or XACML Objects from a String
*
* @param xmlString Decoded SAML or XACML String
* @return SAML or XACML Object
* @throws org.wso2.carbon.identity.entitlement.EntitlementException
*/
public XMLObject unmarshall(String xmlString) throws EntitlementException {
try {
doBootstrap();
DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes()));
Element element = document.getDocumentElement();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
return unmarshaller.unmarshall(element);
} catch (Exception e) {
log.error("Error in constructing XML(SAML or XACML) Object from the encoded String", e);
throw new EntitlementException("Error in constructing XML(SAML or XACML) from the encoded String ", e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:WSXACMLMessageReceiver.java
示例11: equals
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的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
示例12: getUserFromUserName
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Returns a User object constructed from fully qualified username
*
* @param username Fully qualified username
* @return User object
* @throws IllegalArgumentException
*/
public static User getUserFromUserName(String username) {
User user = new User();
if (StringUtils.isNotBlank(username)) {
String tenantDomain = MultitenantUtils.getTenantDomain(username);
String tenantAwareUsername = MultitenantUtils.getTenantAwareUsername(username);
String tenantAwareUsernameWithNoUserDomain = UserCoreUtil.removeDomainFromName(tenantAwareUsername);
String userStoreDomain = IdentityUtil.extractDomainFromName(username).toUpperCase();
user.setUserName(tenantAwareUsernameWithNoUserDomain);
if (StringUtils.isNotEmpty(tenantDomain)) {
user.setTenantDomain(tenantDomain);
} else {
user.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
}
if (StringUtils.isNotEmpty(userStoreDomain)) {
user.setUserStoreDomain(userStoreDomain);
} else {
user.setTenantDomain(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME);
}
}
return user;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:User.java
示例13: isExistsInUserStore
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Check whether the authenticated user exists in any user store that belongs to the realm the user belongs to.
*
* @param authenticatedUserName
* @param tenantDomain
* @return
*/
private boolean isExistsInUserStore(String authenticatedUserName, String tenantDomain,
String realm) throws AuthenticationFailedException {
UserStoreManager userStoreManager;
try {
userStoreManager = getPrimaryUserStoreManager(tenantDomain).getSecondaryUserStoreManager();
String userStoreDomain = IdentityUtil.getPrimaryDomainName();
authenticatedUserName = IdentityUtil.addDomainToName(authenticatedUserName, userStoreDomain);
// Check whether the authenticated user is in primary user store. This is a limitation and will be improved
// to support ADs mounted as secondary user stores
return userStoreManager.isExistingUser(MultitenantUtils.getTenantAwareUsername(authenticatedUserName));
} catch (UserStoreException e) {
throw new
AuthenticationFailedException("IWALocalAuthenticator failed to find the user in the userstore", e);
}
}
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:26,代码来源:IWALocalAuthenticator.java
示例14: init
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
@Override
public void init(InitConfig initConfig) {
this.initConfig = initConfig;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
(AbstractIdentityHandler.class.getName(), this.getClass().getName());
if (identityEventListenerConfig == null) {
return;
}
if(identityEventListenerConfig.getProperties() != null) {
for(Map.Entry<Object,Object> property:identityEventListenerConfig.getProperties().entrySet()) {
String key = (String)property.getKey();
String value = (String)property.getValue();
if(!properties.containsKey(key)) {
properties.setProperty(key, value);
} else {
log.warn("Property key " + key + " already exists. Cannot add property!!");
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:AbstractIdentityHandler.java
示例15: init
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
public void init(InitConfig initConfig) {
this.initConfig = initConfig;
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
(AbstractIdentityMessageHandler.class.getName(), this.getClass().getName());
if (identityEventListenerConfig == null) {
return;
}
if(identityEventListenerConfig.getProperties() != null) {
for(Map.Entry<Object,Object> property:identityEventListenerConfig.getProperties().entrySet()) {
String key = (String)property.getKey();
String value = (String)property.getValue();
if(!properties.containsKey(key)) {
properties.setProperty(key, value);
} else {
log.warn("Property key " + key + " already exists. Cannot add property!!");
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:AbstractIdentityMessageHandler.java
示例16: isIdentityMgtListenerEnable
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
private static boolean isIdentityMgtListenerEnable() {
String listenerClassName = IdentityMgtConfig.getInstance().getProperty
(IdentityMgtConstants.PropertyConfig.IDENTITY_MGT_LISTENER_CLASS);
if (StringUtils.isBlank(listenerClassName)) {
listenerClassName = IdentityMgtEventListener.class.getName();
}
IdentityEventListenerConfig identityEventListenerConfig = IdentityUtil.readEventListenerProperty
(UserOperationEventListener.class.getName(), listenerClassName);
if (identityEventListenerConfig == null) {
return true;
}
if (StringUtils.isNotBlank(identityEventListenerConfig.getEnable())) {
return Boolean.parseBoolean(identityEventListenerConfig.getEnable());
} else {
return true;
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:UserIdentityManagementUtil.java
示例17: getCounterInstanceForDomain
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Create an instance of the given count retriever class
*
* @param domain
* @return
* @throws UserStoreCounterException
*/
public static UserStoreCountRetriever getCounterInstanceForDomain(String domain) throws UserStoreCounterException {
if (StringUtils.isEmpty(domain)) {
domain = IdentityUtil.getPrimaryDomainName();
}
RealmConfiguration realmConfiguration = getUserStoreList().get(domain);
if (realmConfiguration != null && realmConfiguration.getUserStoreProperty(countRetrieverClass) != null) {
String retrieverType = realmConfiguration.getUserStoreProperty(countRetrieverClass);
UserStoreCountRetriever userStoreCountRetriever = UserStoreCountDataHolder.getInstance()
.getCountRetrieverFactories().get(retrieverType).buildCountRetriever(realmConfiguration);
if (userStoreCountRetriever == null) {
throw new UserStoreCounterException(
"Could not create an instance of class: " + retrieverType + " for " +
"the domain: " + domain);
}
return userStoreCountRetriever;
} else {
return null;
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:UserStoreCountUtils.java
示例18: deleteFile
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
private void deleteFile(File file, final String userStoreName) throws IdentityUserStoreMgtException {
if (!IdentityUtil.isValidFileName(userStoreName)) {
String message = "Provided domain name : '" + userStoreName + "' is invalid.";
log.error(message);
throw new IdentityUserStoreMgtException(message);
}
File[] deleteCandidates = file.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.equalsIgnoreCase(userStoreName);
}
});
if (ArrayUtils.isNotEmpty(deleteCandidates)) {
for (File file1 : deleteCandidates) {
if (file1.delete()) {
log.info("File " + file.getName() + " deleted successfully");
} else {
log.error("error at deleting file:" + file.getName());
}
}
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:UserStoreConfigAdminService.java
示例19: bulkImportUsers
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* @param userStoreDomain
* @param fileName
* @param handler
* @param defaultPassword
* @throws UserAdminException
*/
public void bulkImportUsers(String userStoreDomain, String fileName, DataHandler handler, String defaultPassword)
throws UserAdminException {
//password will no longer be used, instead the password will be taken from the file
if (fileName == null || handler == null) {
throw new UserAdminException("Required data not provided");
}
if (StringUtils.isEmpty(userStoreDomain)) {
userStoreDomain = IdentityUtil.getPrimaryDomainName();
}
try {
InputStream inStream = handler.getInputStream();
getUserAdminProxy().bulkImportUsers(userStoreDomain, fileName, inStream, defaultPassword);
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new UserAdminException(e.getMessage(), e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:UserAdmin.java
示例20: isAdminProfileSpoof
import org.wso2.carbon.identity.core.util.IdentityUtil; //导入依赖的package包/类
/**
* Checks whether the given user name is admin user name and the currently logged in user also admin.
* Only admin user is allowed for admin user profile related operations.
*
* @param username Username to be checked.
* @return True only if admin user.
* @throws UserStoreException Error occurred while retrieving realm configuration.
*/
private boolean isAdminProfileSpoof(String username) throws UserStoreException {
if (StringUtils.isEmpty(username)) {
return false;
}
RealmConfiguration realmConfiguration = getUserRealm().getRealmConfiguration();
String adminUsername = IdentityUtil.addDomainToName(realmConfiguration.getAdminUserName(),
IdentityUtil.getPrimaryDomainName());
String targetUsername = IdentityUtil.addDomainToName(username, IdentityUtil.getPrimaryDomainName());
// If the given user name is not the admin username, simply we can allow and return false. Our intention is to
// check whether a non admin user is trying to do operations on an admin profile.
if (!StringUtils.equalsIgnoreCase(targetUsername, adminUsername)) {
return false;
}
String loggedInUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
if (loggedInUsername != null) {
loggedInUsername = IdentityUtil.addDomainToName(loggedInUsername, IdentityUtil.getPrimaryDomainName());
}
// If the currently logged in user is also the admin user this isn't a spoof attempt. Hence returning false.
return !StringUtils.equalsIgnoreCase(loggedInUsername, adminUsername);
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:UserProfileAdmin.java
注:本文中的org.wso2.carbon.identity.core.util.IdentityUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论