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


Java PermissionDeniedDataAccessException类代码示例

本文整理汇总了Java中org.springframework.dao.PermissionDeniedDataAccessException的典型用法代码示例。如果您正苦于以下问题:Java PermissionDeniedDataAccessException类的具体用法?Java PermissionDeniedDataAccessException怎么用?Java PermissionDeniedDataAccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: addBook

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Override
public int addBook(Book book) {
	// TODO Auto-generated method stub
	int rows = 0;
	String INSERT_BOOK = "insert into book values(:bookName,:ISBN,:publication,:price,:description,:author)";
	Map<String,Object>params=new HashMap<String,Object>();
	params.put("bookName", book.getBookName());
	params.put("ISBN", book.getISBN());
	params.put("publication", book.getPublication());
	params.put("price",book.getPrice());
	params.put("description",book.getDescription());
	params.put("author", book.getAuthor());
	rows=namedTemplate.update(INSERT_BOOK,params); 

	PermissionDeniedDataAccessException accessException;
	return rows;

}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-5.0,代码行数:19,代码来源:BookDAO_NamedParameter.java

示例2: login

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@RequestMapping(value = "/login.do", method = RequestMethod.POST)
public String login(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response,
                    @RequestParam("passwordSHA256") String passwordSHA256) {
	// 因为这个登录逻辑很简单, 于是直接写在Controller里 而不是写在专门的Service里.
	try {
		final String lStrPasswordSha256 = ConfigurationUtil.get("admin.password_sha256").trim();
		if (passwordSHA256.equalsIgnoreCase(lStrPasswordSha256)) {
			Calendar lCalendar = Calendar.getInstance();
			lCalendar.setTimeInMillis(System.currentTimeMillis());
			// Add 3 minutes from now, so session will expired after 3 minutes.
			lCalendar.add(Calendar.MINUTE, 3);
			request.getSession().setAttribute(ApplicationConstants.KEY_SESSION_EXPIRES_ON, lCalendar.getTimeInMillis());
			return "redirect:/admin/dashboard/";
		}
		response.setStatus(HttpServletResponse.SC_FORBIDDEN);
		throw new PermissionDeniedDataAccessException("Wrong password", null);
	} catch (Exception e) {
		mLogger.info(e.toString(), e);
		String lStrViewPath = login_view();
		modelMap.put("objException", e);
		return lStrViewPath;
	}
}
 
开发者ID:oing9179,项目名称:AndroidSDKLiteServer,代码行数:24,代码来源:AdminAuthController.java

示例3: login

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
public final VistaUserDetails login(final String vistaId, final String division, final String accessCode, final String verifyCode, String newVerifyCode, String confirmNewVerifyCode, final String remoteAddress, String remoteHostName) throws BadCredentialsException, DataAccessException {
    if (!hasLength(vistaId)) throw new BadCredentialsException("missing vistaId");
    if (!hasLength(division)) throw new BadCredentialsException("missing division");
    if (!hasLength(accessCode)) throw new BadCredentialsException("missing access code");
    if (!hasLength(verifyCode)) throw new BadCredentialsException("missing verify code");
    if (!hasLength(remoteAddress)) throw new BadCredentialsException("missing remote address");
    if (!hasLength(remoteHostName)) throw new BadCredentialsException("missing remote hostname");

    try {
        /*
         * We're using this special variable to get around nested connection requests (our connection pool only allows one connection for a given key at a time.)
         */
        ConnectionInfo info = getRpcTemplate().execute(new ConnectionInfoCallback(), RpcUriUtils.VISTA_RPC_BROKER_SCHEME + "://" + RpcUriUtils.toAuthority(vistaId, division, accessCode, verifyCode, newVerifyCode, confirmNewVerifyCode, remoteAddress, remoteHostName));
        if (info != null) {
        	return createVistaUserDetails(info.getHost(), vistaId, division, info.getUserDetails());
        }
    } catch (PermissionDeniedDataAccessException e) {
        translateException(e);
    }
    return null;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:22,代码来源:RpcTemplateUserDetailService.java

示例4: get

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
/** {@inheritDoc} */
public Requisition get(final String name) {
    checkGroupName(name);
    
    final File importFile = getImportFile(name);
    
    if (!importFile.exists()) {
        return null;
    }
    
    if (!importFile.canRead()) {
        throw new PermissionDeniedDataAccessException("Unable to read file "+importFile, null);
    }
    
    return CastorUtils.unmarshalWithTranslatedExceptions(Requisition.class, new FileSystemResource(importFile));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:DefaultManualProvisioningDao.java

示例5: save

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
/** {@inheritDoc} */
public void save(final String groupName, final Requisition group) {
    checkGroupName(groupName);
    
    final File importFile = getImportFile(groupName);
    
    if (importFile.exists()) {
        final Requisition currentData = get(groupName);
        if (currentData.getDateStamp().compare(group.getDateStamp()) > 0) {
            throw new OptimisticLockingFailureException("Data in file "+importFile+" is newer than data to be saved!");
        }
    }

    final FileWriter writer;
    try {
        writer = new FileWriter(importFile);
    } catch (final IOException e) {
        throw new PermissionDeniedDataAccessException("Unable to write file "+importFile, e);
    }
    CastorUtils.marshalWithTranslatedExceptions(group, writer);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:DefaultManualProvisioningDao.java

示例6: save

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
/** {@inheritDoc} */
public void save(final String groupName, final Requisition group) {
    checkGroupName(groupName);
    
    final File importFile = getImportFile(groupName);
    
    if (importFile.exists()) {
        final Requisition currentData = get(groupName);
        if (currentData.getDateStamp().compare(group.getDateStamp()) > 0) {
            throw new OptimisticLockingFailureException("Data in file "+importFile+" is newer than data to be saved!");
        }
    }

    final FileWriter writer;
    try {
        writer = new FileWriter(importFile);
    } catch (final IOException e) {
        throw new PermissionDeniedDataAccessException("Unable to write file "+importFile, e);
    }
    group.updateDateStamp();
    CastorUtils.marshalWithTranslatedExceptions(group, writer);
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:23,代码来源:DefaultManualProvisioningDao.java

示例7: doTranslate

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Override
protected DataAccessException doTranslate(String task, String sql, SQLException ex) {
	if (ex instanceof SQLTransientException) {
		if (ex instanceof SQLTransientConnectionException) {
			return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLTransactionRollbackException) {
			return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLTimeoutException) {
			return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
		}
	}
	else if (ex instanceof SQLNonTransientException) {
		if (ex instanceof SQLNonTransientConnectionException) {
			return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLDataException) {
			return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLIntegrityConstraintViolationException) {
			return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLInvalidAuthorizationSpecException) {
			return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLSyntaxErrorException) {
			return new BadSqlGrammarException(task, sql, ex);
		}
		else if (ex instanceof SQLFeatureNotSupportedException) {
			return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
		}
	}
	else if (ex instanceof SQLRecoverableException) {
		return new RecoverableDataAccessException(buildMessage(task, sql, ex), ex);
	}

	// Fallback to Spring's own SQL state translation...
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:SQLExceptionSubclassTranslator.java

示例8: statuses

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@DataProvider
public Object[][] statuses() {
    TitanMigrationManager happyMigrationManager = new TitanMigrationManager();
    TitanMigrationManager sadMigrationManager = new TitanMigrationManager();
    Whitebox.setInternalState(happyMigrationManager, IS_MIGRATION_COMPLETE_FIELD_NAME, true);
    Whitebox.setInternalState(sadMigrationManager, IS_MIGRATION_COMPLETE_FIELD_NAME, false);

    return new Object[][] { new Object[] { mockDbWithUp(), Status.UP, AcsMonitoringUtilities.HealthCode.AVAILABLE,
            happyMigrationManager },

            { mockDbWithException(new TransientDataAccessResourceException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNAVAILABLE, happyMigrationManager },

            { mockDbWithException(new QueryTimeoutException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNAVAILABLE, happyMigrationManager },

            { mockDbWithException(new DataSourceLookupFailureException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNREACHABLE, happyMigrationManager },

            { mockDbWithException(new PermissionDeniedDataAccessException("", null)), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.MISCONFIGURATION, happyMigrationManager },

            { mockDbWithException(new ConcurrencyFailureException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.ERROR, happyMigrationManager },

            { mockDbWithUp(), Status.DOWN, AcsMonitoringUtilities.HealthCode.MIGRATION_INCOMPLETE,
                    sadMigrationManager }, };
}
 
开发者ID:eclipse,项目名称:keti,代码行数:29,代码来源:AcsDbHealthIndicatorTest.java

示例9: translateExceptionIfPossible

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
	if (ex.getCause() instanceof SolrServerException) {
		SolrServerException solrServerException = (SolrServerException) ex.getCause();
		if (solrServerException.getCause() instanceof SolrException) {
			SolrException solrException = (SolrException) solrServerException.getCause();
			// solr 4.x moved ParseExecption from org.apache.lucene.queryParser to org.apache.lucene.queryparser.classic
			// therefore compare ShortClassName instead of using instanceof expression
			if (solrException.getCause() != null
					&& ClassUtils.getShortName(solrException.getCause().getClass()).equalsIgnoreCase("ParseException")) {
				return new InvalidDataAccessApiUsageException((solrException.getCause()).getMessage(),
						solrException.getCause());
			} else {
				ErrorCode errorCode = ErrorCode.getErrorCode(solrException.code());
				switch (errorCode) {
					case NOT_FOUND:
					case SERVICE_UNAVAILABLE:
					case SERVER_ERROR:
						return new DataAccessResourceFailureException(solrException.getMessage(), solrException);
					case FORBIDDEN:
					case UNAUTHORIZED:
						return new PermissionDeniedDataAccessException(solrException.getMessage(), solrException);
					case BAD_REQUEST:
						return new InvalidDataAccessApiUsageException(solrException.getMessage(), solrException);
					case UNKNOWN:
						return new UncategorizedSolrException(solrException.getMessage(), solrException);
					default:
						break;
				}
			}
		} else if (solrServerException.getCause() instanceof ConnectException) {
			return new DataAccessResourceFailureException(solrServerException.getCause().getMessage(),
					solrServerException.getCause());
		}
	}
	return null;
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:38,代码来源:SolrExceptionTranslator.java

示例10: verifyCodeNeedsChanging

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Test(expected = PermissionDeniedDataAccessException.class)
public void verifyCodeNeedsChanging() throws RpcException, IOException {
    when(mockConnectionFactory.getConnection(new RpcHost("localhost"), new AccessVerifyConnectionSpec("960", "foo", "bar", "123.45.67.89", "www.example.org"))).thenThrow(new VerifyCodeExpiredException(VerifyCodeExpiredException.VERIFY_CODE_EXPIRED_MESSAGE));

    RpcTemplate t = new RpcTemplate(mockConnectionFactory);

    t.execute("vrpcb://960:foo;[email protected]:9200/FOOBAR");
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:9,代码来源:TestRpcTemplate.java

示例11: translateException

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
protected void translateException(PermissionDeniedDataAccessException e) throws DataAccessException {
    if (e.getCause() instanceof gov.va.hmp.vista.rpc.broker.protocol.BadCredentialsException) {
        throw new BadCredentialsException(e.getCause().getMessage());
    } else if (e.getCause() instanceof VerifyCodeExpiredException) {
        throw new CredentialsExpiredException(e.getCause().getMessage());
    } else if (e.getCause() instanceof RpcContextAccessDeniedException) {
        throw new AuthenticationServiceException(e.getCause().getMessage(), e.getCause());
    } else if (e.getCause() instanceof ChangeVerifyCodeException) {
    	throw new AuthenticationServiceException(e.getCause().getMessage(), e.getCause());
    } else if (e.getCause() instanceof gov.va.hmp.vista.rpc.broker.protocol.LockedException) {
        throw new LockedException(e.getCause().getMessage());
    } else{
    	throw e;
    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:16,代码来源:RpcTemplateUserDetailService.java

示例12: testBadCredentials

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Test
public void testBadCredentials() {
    when(mockRpcTemplate.execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)))).thenThrow(new PermissionDeniedDataAccessException("", new BadCredentialsException()));

    try {
        s.login(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, null, null, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME);
        fail("expected a Spring Security BadCredentialsException");
    } catch (org.springframework.security.authentication.BadCredentialsException e) {
        // NOOP
    }

    verify(mockRpcTemplate).execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:14,代码来源:TestRpcTemplateUserDetailService.java

示例13: testVerifyCodeExpired

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Test
public void testVerifyCodeExpired() {
    when(mockRpcTemplate.execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)))).thenThrow(new PermissionDeniedDataAccessException("",new VerifyCodeExpiredException()));

    try {
        s.login(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, null, null, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME);
        fail("expected a Spring Security BadCredentialsException");
    } catch (CredentialsExpiredException e) {
        // NOOP
    }

    verify(mockRpcTemplate).execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:14,代码来源:TestRpcTemplateUserDetailService.java

示例14: testLocked

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Test
public void testLocked() {
    when(mockRpcTemplate.execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)))).thenThrow(new PermissionDeniedDataAccessException("", new LockedException("sfdsfwesdfsdf")));

    try {
        s.login(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, null, null, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME);
        fail("expected a Spring Security BadCredentialsException");
    } catch (org.springframework.security.authentication.LockedException e) {
        // NOOP
    }

    verify(mockRpcTemplate).execute(any(ConnectionCallback.class), eq("vrpcb://" + RpcUriUtils.toAuthority(MOCK_VISTA_ID, MOCK_DIVISION, MOCK_ACCESS_CODE, MOCK_VERIFY_CODE, MOCK_REMOTE_ADDRESS, MOCK_REMOTE_HOSTNAME)));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:14,代码来源:TestRpcTemplateUserDetailService.java

示例15: doResolveException

import org.springframework.dao.PermissionDeniedDataAccessException; //导入依赖的package包/类
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    if (shouldResolveException(request, response, handler, ex)) {
        ModelAndView modelAndView = super.doResolveException(request, response, handler, ex);
        if (modelAndView == null) {
            if (ex instanceof NotFoundException) {
                modelAndView = handleNotFound((NotFoundException) ex, request, response);
            } else if (ex instanceof BadRequestException) {
                modelAndView = handleBadRequest(ex, request, response);
            } else if (ex instanceof PermissionDeniedDataAccessException) {
            	SecurityContext ctx = SecurityContextHolder.getContext();
            	Authentication auth = ctx.getAuthentication();
            	if(auth instanceof VistaAuthenticationToken && StringUtils.hasText(((VistaAuthenticationToken)auth).getAppHandle()))
                {
            		modelAndView = handleCCOWTokenTimeout(ex, request, response);
                } else {
                	modelAndView = handleBadCredentials(ex, request, response);
                }
            	request.getSession().invalidate();
            } else {
                modelAndView = handleInternalServerError(ex, request, response);
            }
        }
        return modelAndView;
    }

    return null;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:29,代码来源:AjaxHandlerExceptionResolver.java


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