List of usage examples for java.lang SecurityException SecurityException
public SecurityException(Throwable cause)
From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java
public static String readContent(HttpServletRequest request) throws ServletException, IOException, SecurityException { String payload;/* ww w. java 2s . c om*/ /* * Content can only be read once from servlet request. In order to * access it multiple times the content must be stored in request after * it has been read. */ payload = (String) request.getAttribute(GWT_RPC_REQUEST_CONTENT_ATTR_NAME); if (payload == null) { if (!containsStrongName(request)) { throw new SecurityException("Request does not contain required strong name header"); } payload = RPCServletUtils.readContentAsGwtRpc(request); request.setAttribute(GWT_RPC_REQUEST_CONTENT_ATTR_NAME, payload); } return payload; }
From source file:be.fedict.eid.idp.sp.wsfed.WSFedAuthenticationResponseServiceBean.java
@Override public void validateServiceCertificate(SamlAuthenticationPolicy authenticationPolicy, List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("validate saml response policy=" + authenticationPolicy.getUri() + " cert.chain.size=" + certificateChain.size());/* w w w . j a va 2s.c om*/ String idpIdentity = ConfigServlet.getIdpIdentity(); if (null != idpIdentity && !idpIdentity.trim().isEmpty()) { LOG.debug("validate IdP Identity with " + idpIdentity); String fingerprint; try { fingerprint = DigestUtils.shaHex(certificateChain.get(0).getEncoded()); } catch (CertificateEncodingException e) { throw new SecurityException(e); } if (!fingerprint.equals(idpIdentity)) { throw new SecurityException( "IdP Identity " + "thumbprint mismatch: got: " + fingerprint + " expected: " + idpIdentity); } } }
From source file:be.fedict.eid.idp.sp.saml2.AuthenticationResponseServiceBean.java
@Override public void validateServiceCertificate(SamlAuthenticationPolicy authenticationPolicy, List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("validate saml response policy=" + authenticationPolicy.getUri() + " cert.chain.size=" + certificateChain.size());/* w w w.j ava2 s . c om*/ String idpIdentity = ConfigServlet.getIdpIdentity(); if (null != idpIdentity && !idpIdentity.trim().isEmpty()) { LOG.debug("validate IdP Identity with " + idpIdentity); String fingerprint; try { fingerprint = DigestUtils.shaHex(certificateChain.get(0).getEncoded()); } catch (CertificateEncodingException e) { throw new SecurityException(e); } if (!fingerprint.equals(idpIdentity)) { throw new EJBException( "IdP Identity " + "thumbprint mismatch: got: " + fingerprint + " expected: " + idpIdentity); } } }
From source file:nl.surfnet.coin.selfservice.interceptor.AuthorityScopeInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (TOKEN_CHECK_METHODS.contains(request.getMethod().toUpperCase())) { String token = request.getParameter(TOKEN_CHECK); String sessionToken = (String) request.getSession().getAttribute(TOKEN_CHECK); if (StringUtils.isBlank(token) || !token.equals(sessionToken)) { throw new SecurityException(String.format( "Token from session '%s' does not match token '%s' from request", sessionToken, token)); }/* ww w .java 2s .co m*/ } return true; }
From source file:be.fedict.eid.applet.service.impl.AuthenticationChallenge.java
/** * Gives back the authentication challenge. This challenge is checked for * freshness and can be consumed only once. * //from ww w . j ava2 s . c om * @param session * @param maxMaturity * @return */ public static byte[] getAuthnChallenge(HttpSession session, Long maxMaturity) { AuthenticationChallenge authenticationChallenge = (AuthenticationChallenge) session .getAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE); if (null == authenticationChallenge) { throw new SecurityException("no challenge in session"); } session.removeAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE); Date now = new Date(); if (null == maxMaturity) { maxMaturity = DEFAULT_MAX_MATURITY; } long dt = now.getTime() - authenticationChallenge.getTimestamp().getTime(); if (dt > maxMaturity) { throw new SecurityException("maximum challenge maturity reached"); } byte[] challenge = authenticationChallenge.getChallenge(); return challenge; }
From source file:org.apache.myfaces.renderkit.html.util.NonBufferingAddResource.java
/** * the context path for the web-app.<br /> * You can set the context path only once, every subsequent set will throw an SecurityException *///from w w w . jav a 2 s.co m public void setContextPath(String contextPath) { if (_contextPath != null) { throw new SecurityException("context path already set"); } _contextPath = contextPath; }
From source file:eu.openanalytics.rsb.security.JmxSecurityAuthenticator.java
@Override public Subject authenticate(final Object credentials) { try {//from w ww. j a va2 s . c om final String[] info = (String[]) credentials; final Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(info[0], info[1])); final User authenticatedUser = (User) authentication.getPrincipal(); if ((isRsbAdminPrincipal(authenticatedUser)) || (isRsbAdminRole(authenticatedUser))) { final Subject s = new Subject(); s.getPrincipals().add(new JMXPrincipal(authentication.getName())); return s; } else { throw new SecurityException("Authenticated user " + authenticatedUser + " is not an RSB admin"); } } catch (final Exception e) { LOGGER.error("Error when trying to authenticate JMX credentials of type: " + credentials.getClass(), e); throw new SecurityException(e); } }
From source file:com.auditbucket.helper.SecurityHelper.java
public Company getCompany() { String userName = getLoggedInUser(); SystemUser su = sysUserService.findByName(userName); if (su == null) throw new SecurityException("Not authorised"); return su.getCompany(); }
From source file:com.logsniffer.app.StartupAppConfig.java
/** * Checks the home dir under ${logsniffer.home} for write access, creates it * if necessary and writes a template config.properties. * /*from www .j a va2 s .co m*/ * @return home directory representation * @throws Exception */ @Bean public LogSnifferHome homeDir() throws Exception { File logSnifferHomeDirFile = new File(logSnifferHomeDir); logger.info("Starting Logsniffer {} with home directory {}", version, logSnifferHomeDirFile.getPath()); if (!logSnifferHomeDirFile.exists()) { logger.info("Home directory is't present, going to create it"); try { logSnifferHomeDirFile.mkdirs(); } catch (Exception e) { logger.error("Failed to create home directory \"" + logSnifferHomeDirFile.getPath() + "\". Logsniffer can't operate without a write enabled home directory. Please create the home directory manually and grant the user Logsniffer is running as the write access.", e); throw e; } } else if (!logSnifferHomeDirFile.canWrite()) { logger.error( "Configured home directory \"{}\" isn't write enabled. Logsniffer can't operate without a write enabled home directory. Please grant the user Logsniffer is running as the write access.", logSnifferHomeDirFile.getPath()); throw new SecurityException( "Configured home directory \"" + logSnifferHomeDirFile.getPath() + "\" isn't write enabled."); } File homeConfigProps = new File(logSnifferHomeDirFile, "config.properties"); if (!homeConfigProps.exists()) { FileOutputStream fo = new FileOutputStream(homeConfigProps); try { new Properties().store(fo, "Place here Logsniffer settings"); } finally { fo.close(); } } return new LogSnifferHome() { @Override public File getHomeDir() { return new File(logSnifferHomeDir); } }; }
From source file:org.sharetask.security.UserDetailsByNameService.java
public UserDetails loadUserDetails(T authentication) throws UsernameNotFoundException { if (authentication instanceof ClientAuthenticationToken) { final CommonProfile profile = (CommonProfile) ((ClientAuthenticationToken) authentication) .getUserProfile();/*from w w w . jav a 2 s . co m*/ UserInformation user = this.userInformationRepository.findByUsername(profile.getEmail()); if (user == null) { return null; } else { final Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); for (final Role role : user.getRoles()) { authorities.add(new SimpleGrantedAuthority(role.name())); } return buildUserDetails(profile.getEmail(), authorities); } } else { throw new SecurityException("Wrong authentication object"); } }