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


Java HttpServletResponse.SC_FORBIDDEN属性代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.SC_FORBIDDEN属性的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.SC_FORBIDDEN属性的具体用法?Java HttpServletResponse.SC_FORBIDDEN怎么用?Java HttpServletResponse.SC_FORBIDDEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.servlet.http.HttpServletResponse的用法示例。


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

示例1: getErrorMessageByStatusCode

private String getErrorMessageByStatusCode(String requestPath, final int statusCode) {
	String errMessage;
	switch (statusCode) {
       case HttpServletResponse.SC_NOT_FOUND:
           errMessage = MessageFormat.format(ERROR_PATH_NOT_FOUND, requestPath);
           break;
       case HttpServletResponse.SC_UNAUTHORIZED:
           errMessage = MessageFormat.format(ERROR_WRONG_CREDENTIALS, requestPath);
           break;
       case HttpServletResponse.SC_FORBIDDEN:
           errMessage = MessageFormat.format(ERROR_UNAUTHORIZED, requestPath);
           break;
       default:
           errMessage = MessageFormat.format(ERROR_UNEXPECTED_RESPONSE, requestPath);
       }
	return errMessage;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:17,代码来源:DefaultHTTPResponseValidator.java

示例2: authenticate

@Override
public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
{
    return _authenticatedUser != null || (response.isCommitted() &&
            (response.getStatus() == HttpServletResponse.SC_UNAUTHORIZED ||
                    response.getStatus() == HttpServletResponse.SC_FORBIDDEN));
}
 
开发者ID:curityio,项目名称:oauth-filter-for-java,代码行数:7,代码来源:AuthenticatedUserRequestWrapper.java

示例3: validateCurrentUser

protected void validateCurrentUser()
{
    String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
    // check the current user access rights
    if (!facetService.isSearchAdmin(currentUser))
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Access denied.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:9,代码来源:AbstractSolrFacetConfigAdminWebScript.java

示例4: buildModel

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting workflow instance id from request parameters
    String workflowInstanceId = params.get("workflow_instance_id");
    
    // determine if instance should be cancelled or deleted
    boolean forced = getForced(req);

    if (canUserEndWorkflow(workflowInstanceId))
    {
        if (forced)
        {
            workflowService.deleteWorkflow(workflowInstanceId);
        }
        else
        {
            workflowService.cancelWorkflow(workflowInstanceId);
        }
        
        return null;
    }
    else
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Failed to " + 
                    (forced ? "delete" : "cancel") + " workflow instance with id: " + workflowInstanceId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:WorkflowInstanceDelete.java

示例5: executeImpl

@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        boolean canRead = quickShareService.canRead(sharedId);
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("canRead", canRead);
        return result;            
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: "+sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:34,代码来源:ReadGet.java

示例6: executeImpl

@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        return quickShareService.getMetaData(sharedId);
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: "+sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:QuickShareMetaDataGet.java

示例7: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
    if (nodeRef == null)
    {
        String msg = "A valid NodeRef must be specified!";
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
    }
    
    try
    {
        QuickShareDTO dto = quickShareService.shareContent(nodeRef);
        
        Map<String, Object> model = new HashMap<String, Object>(1);
        model.put("sharedDTO", dto);
        return model;
    }
    catch (InvalidNodeRefException inre)
    {
    	throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:ShareContentPost.java

示例8: login

protected Map<String, Object> login(final String username, String password)
{
    try
    {
        // get ticket
        authenticationService.authenticate(username, password.toCharArray());

        eventPublisher.publishEvent(new EventPreparator(){
            @Override
            public Event prepareEvent(String user, String networkId, String transactionId)
            {
            	// TODO need to fix up to pass correct seqNo and alfrescoClientId
                return new RepositoryEventImpl(-1l, "login", transactionId, networkId, new Date().getTime(),
                		username, null);
            }
        });
        
        // add ticket to model for javascript and template access
        Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
        model.put("username", username);
        model.put("ticket",  authenticationService.getCurrentTicket());
        
        return model;
    }
    catch(AuthenticationException e)
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Login failed");
    }
    finally
    {
        AuthenticationUtil.clearCurrentSecurityContext();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:33,代码来源:AbstractLoginBean.java

示例9: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();
    
    // Current user
    String userID = AuthenticationUtil.getFullyAuthenticatedUser();
    if (userID == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_UNAUTHORIZED, "Web Script ["
                    + req.getServiceMatch().getWebScript().getDescription()
                    + "] requires user authentication.");
    }

    NodeRef nodeRefToBeRestored = parseRequestForNodeRef(req);
    if (nodeRefToBeRestored == null)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "nodeRef not recognised. Could not restore.");
    }
    
    // check if the current user has the permission to restore the node
    validatePermission(nodeRefToBeRestored, userID);
    
    RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(nodeRefToBeRestored);

    // Handling of some error scenarios
    if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_ARCHIVE_NODE))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_PERMISSION))
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_DUPLICATE_CHILD_NODE_NAME))
    {
        throw new WebScriptException(HttpServletResponse.SC_CONFLICT, "Unable to restore archive node: " + nodeRefToBeRestored +". Duplicate child node name");
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_PARENT) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INTEGRITY) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_OTHER))
    {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    
    model.put("restoreNodeReport", report);
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:48,代码来源:ArchivedNodePut.java

示例10: authenticate

public boolean authenticate(RequiredAuthentication required, boolean isGuest)
{
    // first look for the username key in the session - we add this by hand for some portals
    // when the WebScriptPortletRequest is created
    String portalUser = (String)req.getPortletSession().getAttribute(WebScriptPortletRequest.ALFPORTLETUSERNAME);
    if (portalUser == null)
    {
        portalUser = req.getRemoteUser();
    }
    
    if (logger.isDebugEnabled())
    {
        logger.debug("JSR-168 Remote user: " + portalUser);
    }
    
    if (isGuest || portalUser == null)
    {
        if (logger.isDebugEnabled())
            logger.debug("Authenticating as Guest");
        
        // authenticate as guest
        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    }
    else
    {
        if (logger.isDebugEnabled())
            logger.debug("Authenticating as user " + portalUser);

        UserTransaction txn = null;
        try
        {
        	txn = txnService.getUserTransaction();
        	txn.begin();

        	if (!unprotAuthenticationService.authenticationExists(portalUser))
        	{
        		throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "User " + portalUser + " is not a known Alfresco user");
        	}
        	AuthenticationUtil.setFullyAuthenticatedUser(portalUser);
        }
        catch (Throwable err)
        {
        	throw new AlfrescoRuntimeException("Error authenticating user: " + portalUser, err);
        }
        finally
        {
        	try
        	{
        		if (txn != null)
        		{
        			txn.rollback();
        		}
        	}
        	catch (Exception tex)
        	{
        		// nothing useful we can do with this
        	}
        }
    }
    
    return true;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:62,代码来源:JSR168PortletAuthenticatorFactory.java

示例11: execute

@Override
public void execute(final WebScriptRequest req, final WebScriptResponse res) throws IOException
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of template vars (params)
    final Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        Pair<String, NodeRef> pair = quickShareSerivce.getTenantNodeRefFromSharedId(sharedId);
        final String tenantDomain = pair.getFirst();
        final NodeRef nodeRef = pair.getSecond();

        TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>()
        {
            public Void doWork() throws Exception
            {
                if (! nodeService.getAspects(nodeRef).contains(QuickShareModel.ASPECT_QSHARE))
                {
                    throw new InvalidNodeRefException(nodeRef);
                }
                
                executeImpl(nodeRef, params, req, res, null);
                
                return null;
            }
        }, tenantDomain);
        
        if (logger.isDebugEnabled())
        {
            logger.debug("QuickShare - retrieved content: "+sharedId+" ["+nodeRef+"]");
        }

    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: "+sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:54,代码来源:QuickShareContentGet.java

示例12: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
        final String tenantDomain = pair.getFirst();
        final NodeRef nodeRef = pair.getSecond();
        
        String siteId = siteService.getSiteShortName(nodeRef);
        
        Map<String, Object> model = new HashMap<String, Object>(3);
        model.put("sharedId", sharedId);
        model.put("nodeRef", nodeRef.toString());
        model.put("siteId", siteId);
        model.put("tenantDomain", tenantDomain);
        
        if (logger.isInfoEnabled())
        {
            logger.info("QuickShare - get shared context: "+sharedId+" ["+model+"]");
        }
        
        return model;
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:ShareContentGet.java

示例13: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }

    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }

    try
    {
        NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();

        String sharedBy = (String) nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDBY);
        if (!quickShareService.canDeleteSharedLink(nodeRef, sharedBy))
        {
            throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Can't perform unshare action: " + sharedId);
        }
        quickShareService.unshareContent(sharedId);

        Map<String, Object> model = new HashMap<>(1);
        model.put("success", Boolean.TRUE);
        return model;
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: " + sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:42,代码来源:UnshareContentDelete.java

示例14: patchProperties

protected void patchProperties(FileInfo nodeInfo, String path) throws WebDAVServerException
{
    failedProperty = null;
    for (PropertyAction action : m_propertyActions)
    {
        if (action.getProperty().isProtected())
        {
            failedProperty = action.getProperty();
            break;
        }
    }

    Map<QName, String> deadProperties = null;
    for (PropertyAction propertyAction : m_propertyActions)
    {
        int statusCode;
        String statusCodeDescription;
        WebDAVProperty property = propertyAction.getProperty();

        if (failedProperty == null)
        {
            PropertyDefinition propDef = getDAVHelper().getDictionaryService().getProperty(property.createQName());
            
            boolean deadProperty = propDef == null || (!propDef.getContainerClass().isAspect() && !getDAVHelper().getDictionaryService().isSubClass(getNodeService().getType(nodeInfo.getNodeRef()), 
                    propDef.getContainerClass().getName()));
            
            if (deadProperty && deadProperties == null)
            {
                deadProperties = loadDeadProperties(nodeInfo.getNodeRef());
            }

            if (PropertyAction.SET == propertyAction.getAction())
            {
                if (deadProperty)
                {
                    deadProperties.put(property.createQName(), property.getValue());
                }
                else
                {
                    getNodeService().setProperty(nodeInfo.getNodeRef(), property.createQName(), property.getValue());
                }
            }
            else if (PropertyAction.REMOVE == propertyAction.getAction())
            {
                if (deadProperty)
                {
                    deadProperties.remove(property.createQName());
                }
                else
                {
                    getNodeService().removeProperty(nodeInfo.getNodeRef(), property.createQName());
                }
            }
            else
            {
                throw new WebDAVServerException(HttpServletResponse.SC_BAD_REQUEST);
            }
            statusCode = HttpServletResponse.SC_OK;
            statusCodeDescription = WebDAV.SC_OK_DESC;
        }
        else if (failedProperty == property)
        {
            statusCode = HttpServletResponse.SC_FORBIDDEN;
            statusCodeDescription = WebDAV.SC_FORBIDDEN_DESC;
        }
        else
        {
            statusCode = WebDAV.WEBDAV_SC_FAILED_DEPENDENCY;
            statusCodeDescription = WebDAV.WEBDAV_SC_FAILED_DEPENDENCY_DESC;
        }

        propertyAction.setResult(statusCode, statusCodeDescription);
    }
    if (deadProperties != null)
    {
        persistDeadProperties(nodeInfo.getNodeRef(), deadProperties);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:78,代码来源:PropPatchMethod.java


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