本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例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 }, };
}
示例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;
}
示例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");
}
示例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;
}
}
示例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)));
}
示例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)));
}
示例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)));
}
示例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;
}