本文整理汇总了Java中org.wso2.carbon.automation.engine.context.beans.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.wso2.carbon.automation.engine.context.beans包,在下文中一共展示了User类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendSecuredStockQuoteRequest
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public OMElement sendSecuredStockQuoteRequest(User userInfo, String trpUrl, String symbol ,boolean teant) throws Exception {
boolean isTenant = teant;
String keyStorePath;
String userCertAlias;
String encryptionUser;
String keyStorePassword;
if (isTenant) {
keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security"
+ File.separator + "keystore" + File.separator + "wso2carbon.jks";// need to include tenants certificate
userCertAlias = "wso2carbon";
encryptionUser = "wso2carbon";
keyStorePassword = "wso2carbon";
} else {
keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores"
+ File.separator + "products" + File.separator + "wso2carbon.jks";
userCertAlias = "wso2carbon";
encryptionUser = "wso2carbon";
keyStorePassword = "wso2carbon";
}
return secureClient.sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, "getQuote"
, createSimpleStockQuoteRequest(symbol), null,userCertAlias, encryptionUser, keyStorePath, keyStorePassword);
}
示例2: initTest
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(userMode);
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64
.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
String auth_string = "Basic " + encoded;
String anaytics_https_url = automationContext.getContextUrls().getWebAppURLHttps()
.replace("9443", String.valueOf(Constants.HTTPS_ANALYTICS_PORT))
.replace("/t/" + automationContext.getContextTenant().getDomain(), "") + "/";
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
this.analyticsClient = new RestClient(anaytics_https_url, Constants.APPLICATION_JSON, auth_string);
if (this.userMode == TestUserMode.TENANT_ADMIN) {
HttpResponse response = client
.post(Constants.AndroidSenseEnrollment.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, "");
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
}
示例3: sendSecuredRequest
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public OMElement sendSecuredRequest(User userInfo, String trpUrl, int securityPolicyId,
OMElement payload, String action) throws Exception {
//todo isTenat
boolean isTenant = false;
String policyPath = TestConfigurationProvider.getSecurityPolicyLocation() + File.separator +
"scenario" + securityPolicyId + "-policy.xml";
String keyStorePath;
String userCertAlias;
String encryptionUser;
String keyStorePassword;
if (isTenant) {
keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "security"
+ File.separator + "keystore" + File.separator + "clients.jks";
userCertAlias = "clients";
encryptionUser = "service";
keyStorePassword = "automation";
} else {
keyStorePath = TestConfigurationProvider.getResourceLocation() + File.separator + "keystores"
+ File.separator + "products" + File.separator + "wso2carbon.jks";
userCertAlias = "wso2carbon";
encryptionUser = "wso2carbon";
keyStorePassword = "wso2carbon";
}
return secureClient.sendReceive(userInfo.getUserName(), userInfo.getPassword(), trpUrl, action
, payload, policyPath, userCertAlias, encryptionUser, keyStorePath, keyStorePassword);
}
示例4: addNonAdminUser
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
@BeforeTest(alwaysRun = true)
public void addNonAdminUser() throws Exception {
AutomationContext esbContext = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);
String sessionCookie = new LoginLogoutClient(esbContext).login();
ResourceAdminServiceClient resourceAdmin = new ResourceAdminServiceClient(esbContext.getContextUrls().getBackEndUrl(), sessionCookie);
UserManagementClient userManagementClient = new UserManagementClient(esbContext.getContextUrls().getBackEndUrl(), sessionCookie);
//done this change due to a bug in UM - please refer to carbon dev mail
// "G-Reg integration test failures due to user mgt issue."
String[] permissions = {"/permission/admin/configure/",
"/permission/admin/login",
"/permission/admin/manage/",
"/permission/admin/monitor",
"/permission/protected"};
if (!userManagementClient.roleNameExists(ROLE_NAME)) {
userManagementClient.addRole(ROLE_NAME, null, permissions);
resourceAdmin.addResourcePermission("/", ROLE_NAME, "3", "1");
resourceAdmin.addResourcePermission("/", ROLE_NAME, "2", "1");
resourceAdmin.addResourcePermission("/", ROLE_NAME, "4", "1");
resourceAdmin.addResourcePermission("/", ROLE_NAME, "5", "1");
}
userManagementClient.addUser("nonadminuser", "password", new String[]{ROLE_NAME}, null);
//check user creation
nonAdminUser = new User();
nonAdminUser.setUserName("nonadminuser");
nonAdminUser.setPassword("password");
}
示例5: restartGracefully
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public synchronized void restartGracefully() throws AutomationFrameworkException {
try {
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, superUser.getUserName(), superUser.getPassword());
} catch (XPathExpressionException var5) {
throw new AutomationFrameworkException("restart failed", var5);
}
long time = System.currentTimeMillis() + 300000L;
// while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) {
// ;
// }
time = System.currentTimeMillis();
while(System.currentTimeMillis() < time + 5000L) {
;
}
try {
ClientConnectionUtil.waitForPort(Integer.parseInt((String)this.automationContext.getInstance().getPorts().get("https")), (String)this.automationContext.getInstance().getHosts().get("default"));
ClientConnectionUtil.waitForLogin(this.automationContext);
} catch (XPathExpressionException var4) {
throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4);
}
}
示例6: init
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
protected void init(TestUserMode userMode) throws Exception {
automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode);
String tenantDomain = automationContext.getContextTenant().getDomain();
backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants
.HTTPS_GATEWAY_PORT)).replace("/t/" + tenantDomain , "");
backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants
.HTTP_GATEWAY_PORT)).replace("/t/" + tenantDomain , "");
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64
.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
accessToken = OAuthUtil.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(),
currentUser.getPassword());
accessTokenString = "Bearer " + accessToken;
}
示例7: getCurrentUserInfo
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
/**
* This method will return current user loggedIn
*
* @return user - the tenant user
* @throws XPathExpressionException
*/
public User getCurrentUserInfo() throws XPathExpressionException {
if (userInfo == null) {
userInfo = getCurrentTenantInfo().getContextUser();
}
return userInfo;
}
示例8: restartGracefully
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public synchronized void restartGracefully() throws AutomationFrameworkException {
try {
int time = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl()
.replaceAll("(:\\d+)", ":" + time);
User e = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, e.getUserName(), e.getPassword());
} catch (XPathExpressionException var5) {
throw new AutomationFrameworkException("restart failed", var5);
}
long time1 = System.currentTimeMillis() + 300000L;
while (!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time1) {
;
}
time1 = System.currentTimeMillis();
while (System.currentTimeMillis() < time1 + 5000L) {
;
}
try {
ClientConnectionUtil.waitForPort(
Integer.parseInt((String) this.automationContext.getInstance().getPorts().get("https")),
RESTART_TIMEOUT, true, (String) this.automationContext.getInstance().getHosts().get("default"));
ClientConnectionUtil.waitForLogin(this.automationContext);
} catch (XPathExpressionException var4) {
throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4);
}
}
示例9: getUser
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
protected static User getUser(){
Assert.assertNotNull( "User is not created. Please create the user first", nonAdminUser);
return nonAdminUser;
}
示例10: startServerUsingCarbonHome
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap) throws AutomationFrameworkException {
if(this.process == null) {
this.portOffset = this.checkPortAvailability(commandMap);
Process tempProcess = null;
try {
if(!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
System.setProperty("carbon.home", carbonHome);
}
File commandDir = new File(carbonHome);
log.info("Starting carbon server............. ");
String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
String[] parameters = this.expandServerStartupCommandList(commandMap);
String[] cmdArray;
if(System.getProperty("os.name").toLowerCase().contains("windows")) {
commandDir = new File(carbonHome + File.separator + "bin");
cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat"};
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir);
} else {
cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh"};
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir);
}
this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
this.inputStreamHandler.start();
this.errorStreamHandler.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
CarbonServerManagerExtension.this.serverShutdown(CarbonServerManagerExtension.this.portOffset);
} catch (Exception var2) {
CarbonServerManagerExtension.log.error("Error while server shutdown ..", var2);
}
}
});
ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, DEFAULT_START_STOP_WAIT_MS, false, (String)this
.automationContext.getInstance().getHosts().get("default"));
long time = System.currentTimeMillis() + 60000L;
// while(true) {
// if(this.inputStreamHandler.getOutput().contains("Mgt Console URL") || System.currentTimeMillis() >= time) {
// int httpsPort = defaultHttpsPort + this.portOffset;
// String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
// User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
// ClientConnectionUtil.waitForLogin(backendURL, superUser);
// log.info("Server started successfully.");
// break;
// }
// }
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.waitForLogin(backendURL, superUser);
} catch (XPathExpressionException | IOException var13) {
throw new IllegalStateException("Unable to start server", var13);
}
this.process = tempProcess;
}
}
示例11: startServerUsingCarbonHome
import org.wso2.carbon.automation.engine.context.beans.User; //导入依赖的package包/类
public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap)
throws AutomationFrameworkException {
if (this.process == null) {
this.portOffset = this.checkPortAvailability(commandMap);
Process tempProcess = null;
try {
if (!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
System.setProperty("carbon.home", carbonHome);
}
File e = new File(carbonHome);
log.info("Starting carbon server............. ");
String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
String[] parameters = this.expandServerStartupCommandList(commandMap);
String[] cmdArray;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
e = new File(carbonHome + File.separator + "bin");
cmdArray = new String[] { "cmd.exe", "/c", scriptName + ".bat" };
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, e);
} else {
cmdArray = new String[] { "sh", "bin/" + scriptName + ".sh" };
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[]) null, e);
}
this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
this.inputStreamHandler.start();
this.errorStreamHandler.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
StratosServerManager.this.serverShutdown(StratosServerManager.this.portOffset);
} catch (Exception var2) {
log.error("Error while server shutdown ..", var2);
}
}
});
ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, 300000L, false,
(String) this.automationContext.getInstance().getHosts().get("default"));
long time = System.currentTimeMillis() + 60000L;
while (true) {
if (this.inputStreamHandler.getOutput().contains("Mgt Console URL")
|| System.currentTimeMillis() >= time) {
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl()
.replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.waitForLogin(backendURL, superUser);
log.info("Server started successfully.");
break;
}
}
} catch (XPathExpressionException | IOException var13) {
throw new IllegalStateException("Unable to start server", var13);
}
this.process = tempProcess;
}
}