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


Java CallContext.getUsername方法代码示例

本文整理汇总了Java中org.apache.chemistry.opencmis.commons.server.CallContext.getUsername方法的典型用法代码示例。如果您正苦于以下问题:Java CallContext.getUsername方法的具体用法?Java CallContext.getUsername怎么用?Java CallContext.getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.chemistry.opencmis.commons.server.CallContext的用法示例。


在下文中一共展示了CallContext.getUsername方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getService

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入方法依赖的package包/类
@Override
public CmisService getService(CallContext context) {
	// authentication can go here
	String user = context.getUsername();
	String password = context.getPassword();
	log.debug("User: {}", user);
	log.debug("Password: {}", password);

	// if the authentication fails, throw a CmisPermissionDeniedException

	// create a new service object (can also be pooled or stored in a ThreadLocal)
	CmisServiceImpl service = new CmisServiceImpl(repository);

	// add the CMIS service wrapper
	// (The wrapper catches invalid CMIS requests and sets default values
	// for parameters that have not been provided by the client.)
	CmisServiceWrapper<CmisService> wrapperService = new CmisServiceWrapper<CmisService>(service, DEFAULT_MAX_ITEMS_TYPES,
			DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);

	// hand over the call context to the service object
	service.setCallContext(context);

	return wrapperService;
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:25,代码来源:CmisServiceFactory.java

示例2: authenticate

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入方法依赖的package包/类
/**
 * Takes user and password from the CallContext and checks them.
 */
public synchronized String authenticate(CallContext context) {
    // check user and password
    if (!authenticate(context.getUsername(), context.getPassword())) {
        throw new CmisPermissionDeniedException("Invalid username or password.");
    }

    return context.getUsername();
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:12,代码来源:FileBridgeUserManager.java

示例3: beforeCall

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入方法依赖的package包/类
@Override
    public void beforeCall()
    {
        AuthenticationUtil.pushAuthentication();
        if (authentication != null)
        {
            // Use the previously-obtained authentication
            AuthenticationUtil.setFullAuthentication(authentication);
        }
        else
        {
        	CallContext context = getContext();
            if (context == null)
            {
                // Service not opened, yet
                return;
            }
            // Sticky sessions?
            if (connector.openHttpSession())
            {
                // create a session -> set a cookie
                // if the CMIS client supports cookies that might help in clustered environments
                ((HttpServletRequest)context.get(CallContext.HTTP_SERVLET_REQUEST)).getSession();
            }
            
            // Authenticate
            if (authentication != null)
            {
                // We have already authenticated; just reuse the authentication
                AuthenticationUtil.setFullAuthentication(authentication);
            }
            else
            {
                // First check if we already are authenticated
                if (AuthenticationUtil.getFullyAuthenticatedUser() == null)
                {
                    // We have to go to the repo and authenticate
                    String user = context.getUsername();
                    String password = context.getPassword();
                    Authorization auth = new Authorization(user, password);
                    if (auth.isTicket())
                    {
                        connector.getAuthenticationService().validate(auth.getTicket());
                    }
                    else
                    {
                        connector.getAuthenticationService().authenticate(auth.getUserName(), auth.getPasswordCharArray());
                    }
                }
                this.authentication = AuthenticationUtil.getFullAuthentication();
            }
            
//            // TODO: How is the proxy user working.
//            //       Until we know what it is meant to do, it's not available
//            String currentUser = connector.getAuthenticationService().getCurrentUserName();
//            String user = getContext().getUsername();
//            String password = getContext().getPassword();
//            if (currentUser != null && currentUser.equals(connector.getProxyUser()))
//            {
//                if (user != null && user.length() > 0)
//                {
//                    AuthenticationUtil.setFullyAuthenticatedUser(user);
//                }
//            }
        }
    }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:67,代码来源:AlfrescoCmisServiceImpl.java

示例4: getService

import org.apache.chemistry.opencmis.commons.server.CallContext; //导入方法依赖的package包/类
@Override
public CmisService getService(CallContext context) {
    //Called for each service request, context contains username, password etc.
    //The registry clients are stored in the map "sessions"
    //If there is an existing session, use it. Otherwise make a new one.

    CMISRepository repository = null;
    //String username = "test";

    String ip = ((RequestFacade)context.get(context.HTTP_SERVLET_REQUEST)).getRemoteAddr();
    String url = ((RequestFacade)context.get(context.HTTP_SERVLET_REQUEST)).getRequestURL().toString();

    String tenant = MultitenantUtils.getTenantDomain((RequestFacade)context.get(context.HTTP_SERVLET_REQUEST));
    String username = context.getUsername();

    if (username != null) {
        username = MultitenantUtils.getTenantAwareUsername(username);
    }

    UserInfo userInfoObj = new UserInfo(ip, username, tenant);

    if(url.contains(uriPart)) {
        repository = getRepo(userInfoObj);

        if (repository == null)
            throw new CmisRuntimeException("User is not authenticated to the repository to view the content");

    } else if(sessions.containsKey(userInfoObj)) {
            repository = sessions.get(userInfoObj);
        //TODO check for session timeout
    } else {
        try {
            repository = new CMISRepository(acquireGregRepository(context, tenant, username), pathManager, typeManager);
            //put to sessions for future reference
            sessions.put(new UserInfo(ip, username, tenant), repository);

        } catch (RegistryException e) {
            e.printStackTrace();
            throw new CmisRuntimeException(e.getMessage(), e);

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
            throw new CmisRuntimeException(axisFault.getMessage());
        }
    }

    CmisServiceWrapper<CMISService> serviceWrapper = new CmisServiceWrapper<CMISService>(
            createGregService(repository, context), DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES,
            DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS);

    serviceWrapper.getWrappedService().setCallContext(context);
    return serviceWrapper;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:54,代码来源:CMISServiceFactory.java


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