本文整理汇总了Java中org.wso2.carbon.CarbonConstants类的典型用法代码示例。如果您正苦于以下问题:Java CarbonConstants类的具体用法?Java CarbonConstants怎么用?Java CarbonConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CarbonConstants类属于org.wso2.carbon包,在下文中一共展示了CarbonConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRolesToAdd
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
private Collection<String> getRolesToAdd(UserStoreManager userStoreManager, String[] newRoles)
throws UserStoreException {
List<String> rolesToAdd = Arrays.asList(newRoles);
List<String> updatedRolesToAdd = new ArrayList<>();
// Make Internal domain name case insensitive
for (String role : rolesToAdd) {
if (StringUtils.containsIgnoreCase(role, UserCoreConstants.INTERNAL_DOMAIN +
CarbonConstants.DOMAIN_SEPARATOR)) {
updatedRolesToAdd.add(UserCoreConstants.INTERNAL_DOMAIN + CarbonConstants.DOMAIN_SEPARATOR +
UserCoreUtil.removeDomainFromName(role));
} else {
updatedRolesToAdd.add(role);
}
}
List<String> allExistingRoles = removeDomainFromNamesExcludeInternal(
Arrays.asList(userStoreManager.getRoleNames()), userStoreManager.getTenantId());
updatedRolesToAdd.retainAll(allExistingRoles);
return updatedRolesToAdd;
}
示例2: prependUserStoreDomainToName
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
public static String prependUserStoreDomainToName(String authenticatedSubject) {
if (authenticatedSubject == null || authenticatedSubject.trim().isEmpty()) {
throw new IllegalArgumentException("Invalid argument. authenticatedSubject : "
+ authenticatedSubject);
}
if (!authenticatedSubject.contains(CarbonConstants.DOMAIN_SEPARATOR)) {
if (UserCoreUtil.getDomainFromThreadLocal() != null
&& !UserCoreUtil.getDomainFromThreadLocal().isEmpty()) {
authenticatedSubject = UserCoreUtil.getDomainFromThreadLocal()
+ CarbonConstants.DOMAIN_SEPARATOR + authenticatedSubject;
}
} else if (authenticatedSubject.indexOf(CarbonConstants.DOMAIN_SEPARATOR) == 0) {
throw new IllegalArgumentException("Invalid argument. authenticatedSubject : "
+ authenticatedSubject + " begins with \'" + CarbonConstants.DOMAIN_SEPARATOR
+ "\'");
}
return authenticatedSubject;
}
示例3: testGetUserRealmInfo
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
@Test
public void testGetUserRealmInfo() throws Exception {
Mockito.when(realm.getAuthorizationManager()).thenReturn(authorizationManager);
Mockito.when(realm.getClaimManager()).thenReturn(claimManager);
Mockito.when(authorizationManager.isUserAuthorized("admin",
"/permission/admin/manage/identity", CarbonConstants.UI_PERMISSION_ACTION)).thenReturn(true);
Mockito.when(realm.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
Mockito.when(realm.getUserStoreManager()).thenReturn(userStoreManagerWithAb);
ClaimMapping claimMapping = new ClaimMapping();
claimMapping.setMappedAttribute("test1");
claimMapping.setMappedAttribute("test2");
claimMapping.setMappedAttribute("test3");
Claim claim = new Claim();
claim.setClaimUri("testURI");
claim.setValue("testClaim");
claimMapping.setClaim(claim);
Mockito.when(claimManager.getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT))
.thenReturn(new ClaimMapping[]{claimMapping});
Mockito.when(userStoreManagerWithAb.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
Mockito.when(userStoreManagerWithAb.isBulkImportSupported()).thenReturn(false);
UserRealmInfo realmInfo = userRealmProxy.getUserRealmInfo();
Assert.assertEquals(realmInfo.getEveryOneRole(), "everyone");
Assert.assertEquals(realmInfo.getAdminRole(), "admin");
}
示例4: isUserAuthorizedToConfigureProfile
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
private static boolean isUserAuthorizedToConfigureProfile(UserRealm realm, String currentUserName,
String targetUser, String permission)
throws UserStoreException {
boolean isAuthrized = false;
if (currentUserName == null) {
//do nothing
} else if (currentUserName.equals(targetUser)) {
isAuthrized = true;
} else {
AuthorizationManager authorizer = realm.getAuthorizationManager();
isAuthrized = authorizer.isUserAuthorized(currentUserName,
CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION + permission,
"ui.execute");
}
return isAuthrized;
}
示例5: getRegistryService
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
/**
* To get the registry service.
* @return RegistryService
* @throws RegistryException Registry Exception
*/
private RegistryService getRegistryService() throws RegistryException, UserStoreException {
RealmService realmService = new InMemoryRealmService();
AuthenticatorFrameworkDataHolder.getInstance().setRealmService(realmService);
UserStoreManager userStoreManager = AuthenticatorFrameworkDataHolder.getInstance().getRealmService()
.getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager();
Permission adminPermission = new Permission(PermissionUtils.ADMIN_PERMISSION_REGISTRY_PATH,
CarbonConstants.UI_PERMISSION_ACTION);
userStoreManager.addRole(ADMIN_ROLE + "t", new String[] { ADMIN_USER }, new Permission[] { adminPermission });
RegistryDataHolder.getInstance().setRealmService(realmService);
DeviceManagementDataHolder.getInstance().setRealmService(realmService);
InputStream is = BaseWebAppAuthenticatorFrameworkTest.class.getClassLoader()
.getResourceAsStream("carbon-home/repository/conf/registry.xml");
RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
context.setSetup(true);
return context.getEmbeddedRegistryService();
}
示例6: getRegistryForTenant
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
private Registry getRegistryForTenant() {
Registry registry = getRootRegistry();
HttpSession httpSession = ((HttpServletRequest) MessageContext.getCurrentMessageContext().getProperty(
HTTPConstants.MC_HTTP_SERVLETREQUEST)).getSession();
RegistryService registryService = WSDataHolder.getInstance().getRegistryService();
if (httpSession != null && registryService != null) {
if (PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId() ==
MultitenantConstants.SUPER_TENANT_ID) {
try {
Object tenantId = httpSession.getAttribute(REGISTRY_WS_API_TENANT);
if (tenantId != null) {
return registryService.getRegistry(
CarbonConstants.REGISTRY_SYSTEM_USERNAME, (Integer) tenantId);
}
} catch (Exception ignored) {
// We are not bothered about any errors in here.
}
}
}
return registry;
}
示例7: processFileUploadExecutorDefinitions
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
private void processFileUploadExecutorDefinitions(Component component , String action) throws
CarbonException{
if (component.getFileUploadExecutorConfigs() != null
&& component.getFileUploadExecutorConfigs().length > 0) {
FileUploadExecutorManager executorManager =
(FileUploadExecutorManager) fileUploadExecManagerTracker.getService();
if (executorManager == null) {
log.error("FileUploadExecutorManager service is not available");
return;
}
FileUploadExecutorConfig[] executorConfigs = component.getFileUploadExecutorConfigs();
for (FileUploadExecutorConfig executorConfig : executorConfigs) {
String[] mappingActions = executorConfig.getMappingActionList();
for (String mappingAction : mappingActions) {
if (CarbonConstants.ADD_UI_COMPONENT.equals(action)) {
executorManager.addExecutor(mappingAction,
executorConfig.getFUploadExecClass());
} else if (CarbonConstants.REMOVE_UI_COMPONENT.equals(action)) {
executorManager.removeExecutor(mappingAction);
}
}
}
}
}
示例8: getLoggedUserInfoAdminStub
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
/**
*
* @param backendServerURL
* @param session
* @return
* @throws AxisFault
*/
private LoggedUserInfoAdminStub getLoggedUserInfoAdminStub(String backendServerURL,
HttpSession session) throws AxisFault {
ServletContext servletContext = session.getServletContext();
ConfigurationContext configContext = (ConfigurationContext) servletContext
.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
if (configContext == null) {
String msg = "Configuration context is null.";
log.error(msg);
throw new AxisFault(msg);
}
return new LoggedUserInfoAdminStub(configContext, backendServerURL + "LoggedUserInfoAdmin");
}
示例9: getInitialContextProperties
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
protected Properties getInitialContextProperties(String userName, String password) {
Properties initialContextProperties = new Properties();
QpidServerDetails qpidServerDetails = EventBrokerHolder.getInstance().getQpidServerDetails();
initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY, QPID_ICF);
initialContextProperties.put(CarbonConstants.REQUEST_BASE_CONTEXT, "true");
String connectionURL = null;
if (MB_TYPE_LOCAL.equals(this.type)) {
connectionURL = qpidServerDetails.getTCPConnectionURL(userName, qpidServerDetails.getAccessKey());
} else {
connectionURL = "amqp://" + userName + ":" + this.accessKey
+ "@" + clientID + "/" + this.virtualHostName
+ "?brokerlist='tcp://" + this.hostName + ":" + this.qpidPort + "'";
}
initialContextProperties.put(CF_NAME_PREFIX + CF_NAME, connectionURL);
return initialContextProperties;
}
示例10: activate
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
protected void activate(ComponentContext cxt) {
try {
MutualSSLAuthenticator authenticator = new MutualSSLAuthenticator();
MutualSSLAuthenticatorServiceComponent.setBundleContext(cxt.getBundleContext());
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(CarbonConstants.AUTHENTICATOR_TYPE, authenticator.getAuthenticatorName());
cxt.getBundleContext().registerService(CarbonServerAuthenticator.class.getName(),
authenticator, props);
} catch (Exception e) {
log.error(e.getMessage(), e);
// throwing so that server will not start
throw new RuntimeException("Failed to start the MutualSSL Authenticator Bundle" +
e.getMessage(), e);
}
log.debug("Mutual SSL authenticator is activated");
}
示例11: WSRegistryServiceClient
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
public WSRegistryServiceClient(String cookie, ServletConfig config, HttpSession session)
throws RegistryException {
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.
getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
epr = backendServerURL + "WSRegistryService";
try{
stub = new WSRegistryServiceStub(configContext, epr);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
options.setManageSession(true);
options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
//Increase the time out when sending large attachments
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(1000000);
} catch (AxisFault axisFault) {
String msg = "Failed to initiate WSRegistry Service client. " + axisFault.getMessage();
log.error(msg, axisFault);
throw new RegistryException(msg, axisFault);
}
}
示例12: getIWAClient
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
/**
* @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;
}
示例13: HandlerManagementServiceClient
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
public HandlerManagementServiceClient(String cookie, ServletConfig config, HttpSession session)
throws RegistryException {
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.
getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String epr = backendServerURL + "HandlerManagementService";
try {
stub = new HandlerManagementServiceStub(configContext, epr);
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
} catch (AxisFault axisFault) {
String msg = "Failed to initiate handler management service client. " +
axisFault.getMessage();
log.error(msg, axisFault);
throw new RegistryException(msg, axisFault);
}
}
示例14: ResourceServiceClient
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
public ResourceServiceClient(ServletConfig config, HttpSession session)
throws RegistryException {
String cookie = (String)session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.
getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
epr = backendServerURL + "ResourceAdminService";
try {
stub = new ResourceAdminServiceStub(configContext, epr);
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
} catch (AxisFault axisFault) {
String msg = "Failed to initiate resource service client. " + axisFault.getMessage();
log.error(msg, axisFault);
throw new RegistryException(msg, axisFault);
}
}
示例15: activate
import org.wso2.carbon.CarbonConstants; //导入依赖的package包/类
protected void activate(ComponentContext ctxt) {
BundleContext bundleCtx = ctxt.getBundleContext();
// Publish the OSGi service
Dictionary props = new Hashtable();
props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
bundleCtx.registerService(AxisObserver.class.getName(), this, props);
PreAxisConfigurationPopulationObserver preAxisConfigObserver =
new PreAxisConfigurationPopulationObserver() {
public void createdAxisConfiguration(AxisConfiguration axisConfiguration) {
init(axisConfiguration);
axisConfiguration.addObservers(UrlMappingDeploymentInterceptor.this);
}
};
bundleCtx.registerService(PreAxisConfigurationPopulationObserver.class.getName(),
preAxisConfigObserver, null);
// Publish an OSGi service to listen tenant configuration context creation events
Dictionary properties = new Hashtable();
properties.put(CarbonConstants.AXIS2_CONFIG_SERVICE,
Axis2ConfigurationContextObserver.class.getName());
bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(),
new UrlMappingServiceListener(), properties);
}