本文整理汇总了Java中org.wso2.carbon.context.PrivilegedCarbonContext.getTenantDomain方法的典型用法代码示例。如果您正苦于以下问题:Java PrivilegedCarbonContext.getTenantDomain方法的具体用法?Java PrivilegedCarbonContext.getTenantDomain怎么用?Java PrivilegedCarbonContext.getTenantDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.context.PrivilegedCarbonContext
的用法示例。
在下文中一共展示了PrivilegedCarbonContext.getTenantDomain方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: login
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
* Login
*/
@POST
@Path("/login")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response login() {
//create session if not found
HttpSession httpSession = httpServletRequest.getSession();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = carbonContext.getUsername();
httpSession.setAttribute("userName", username);
String tenantDomain = carbonContext.getTenantDomain();
httpSession.setAttribute("tenantDomain", tenantDomain);
int tenantId = carbonContext.getTenantId();
httpSession.setAttribute("tenantId", tenantId);
auditLog.info(String.format(
"User [name] %s of tenant [id] %s [domain] %s is logged-in into WSO2 Machine Learner. "
+ "Granted session id is %s", username, tenantId, tenantDomain, httpSession.getId()));
return Response.status(Response.Status.OK).entity("User logged in: " + username).build();
}
示例2: logout
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
* Logout.
*/
@POST
@Path("/logout")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response logout() {
HttpSession session = httpServletRequest.getSession();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = carbonContext.getUsername();
String tenantDomain = carbonContext.getTenantDomain();
int tenantId = carbonContext.getTenantId();
if (session != null) {
session.invalidate();
}
auditLog.info(String.format(
"User [name] %s of tenant [id] %s [domain] %s is logged-out from WSO2 Machine Learner. "
+ "Granted session id is %s", username, tenantId, tenantDomain, session == null ? null
: session.getId()));
return Response.status(Response.Status.OK).entity("User logged out: " + carbonContext.getUsername()).build();
}
示例3: getAuthenticatedUser
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username != null && username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
示例4: getAuthenticatedUser
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
示例5: getAuthenticatedUser
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
* @return username of the current user
*/
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
示例6: getTenantDomainOftheUser
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getTenantDomainOftheUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return threadLocalCarbonContext.getTenantDomain();
}
示例7: isAthenticated
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static boolean isAthenticated() {
// If the user-name, tenant Domain and tenant ID is not set in carbon context, conclude as not authenticated.
// This is done to authenticate each request.
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return (carbonContext.getUsername()!= null && carbonContext.getTenantDomain() != null && carbonContext.getTenantId() != 0);
}
示例8: getTenantDomainOftheUser
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
* @return tenant domain of the user
*/
public static String getTenantDomainOftheUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return threadLocalCarbonContext.getTenantDomain();
}
示例9: getAuthenticatedUserTenantDomain
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
* @return TenantDomain
*/
public static String getAuthenticatedUserTenantDomain() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return threadLocalCarbonContext.getTenantDomain();
}
示例10: getAuthenticatedUserTenantDomain
import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getAuthenticatedUserTenantDomain() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
return threadLocalCarbonContext.getTenantDomain();
}