当前位置: 首页>>代码示例>>Java>>正文


Java PrivilegedCarbonContext.getTenantDomain方法代码示例

本文整理汇总了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();
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:23,代码来源:LoginLogoutApiV10.java

示例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();
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:23,代码来源:LoginLogoutApiV10.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:10,代码来源:DeviceMgtAPIUtils.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:10,代码来源:APIUtil.java

示例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;
}
 
开发者ID:wso2,项目名称:product-iots,代码行数:13,代码来源:APIUtil.java

示例6: getTenantDomainOftheUser

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getTenantDomainOftheUser() {
    PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    return threadLocalCarbonContext.getTenantDomain();
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:5,代码来源:APIUtil.java

示例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);
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:7,代码来源:AuthenticationContext.java

示例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();
}
 
开发者ID:wso2,项目名称:product-iots,代码行数:8,代码来源:APIUtil.java

示例9: getAuthenticatedUserTenantDomain

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * @return TenantDomain
 */
public static String getAuthenticatedUserTenantDomain() {
    PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    return threadLocalCarbonContext.getTenantDomain();
}
 
开发者ID:wso2,项目名称:product-iots,代码行数:8,代码来源:APIUtil.java

示例10: getAuthenticatedUserTenantDomain

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
public static String getAuthenticatedUserTenantDomain() {
    PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    return threadLocalCarbonContext.getTenantDomain();
}
 
开发者ID:wso2,项目名称:product-iots,代码行数:5,代码来源:APIUtil.java


注:本文中的org.wso2.carbon.context.PrivilegedCarbonContext.getTenantDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。