List of usage examples for java.lang SecurityException SecurityException
public SecurityException(Throwable cause)
From source file:de.qaware.campus.secpro.web.passwords.SecurePasswords.java
/** * Encrypt the given plaintext string using the master password. * * @param plaintext the plain text password * @return the Base64 encoded encrypted password. *///from w w w . ja va 2s . c o m public String encrypt(String plaintext) { try { Key key = getKey(); Ciphertext ciphertext = CryptoUtil.encrypt(key, Plaintext.fromString(plaintext)); return ciphertext.toBase64(); } catch (CryptoException e) { throw new SecurityException(e); } }
From source file:be.fedict.eid.dss.model.bean.IdentityIntegrityServiceBean.java
public void checkNationalRegistrationCertificate(List<X509Certificate> certificateChain) throws SecurityException { LOG.debug("validate national registry certificate: " + certificateChain.get(0).getSubjectX500Principal()); XKMS2Client xkms2Client = this.trustValidationService.getXkms2Client(); String xkmsUrl = this.configuration.getValue(ConfigProperty.XKMS_URL, String.class); if (null == xkmsUrl || xkmsUrl.trim().isEmpty()) { LOG.warn("no XKMS URL configured!"); return;/* w w w . j a v a 2 s. c o m*/ } String xkmsTrustDomain = this.configuration.getValue(ConfigProperty.IDENTITY_TRUST_DOMAIN, String.class); if (null != xkmsTrustDomain && xkmsTrustDomain.trim().isEmpty()) { xkmsTrustDomain = null; } LOG.debug("Trust domain=" + xkmsTrustDomain); try { LOG.debug("validating certificate chain"); if (null != xkmsTrustDomain) { xkms2Client.validate(xkmsTrustDomain, certificateChain); } else { xkms2Client.validate(certificateChain); } } catch (ValidationFailedException e) { LOG.warn("invalid certificate"); throw new SecurityException("invalid certificate"); } catch (Exception e) { LOG.warn("eID Trust Service error: " + e.getMessage(), e); throw new SecurityException("eID Trust Service error"); } }
From source file:com.googlecode.android_scripting.jsonrpc.JsonRpcServer.java
@Override protected void handleConnection(Socket socket) throws Exception { RpcReceiverManager receiverManager = mRpcReceiverManagerFactory.create(); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()), 8192); PrintWriter writer = new PrintWriter(socket.getOutputStream(), true); boolean passedAuthentication = false; String data;//ww w . ja v a 2 s. c o m while ((data = reader.readLine()) != null) { Log.v("Received: " + data); JSONObject request = new JSONObject(data); int id = request.getInt("id"); String method = request.getString("method"); JSONArray params = request.getJSONArray("params"); // First RPC must be _authenticate if a handshake was specified. if (!passedAuthentication && mHandshake != null) { if (!checkHandshake(method, params)) { SecurityException exception = new SecurityException("Authentication failed!"); send(writer, JsonRpcResult.error(id, exception)); shutdown(); throw exception; } passedAuthentication = true; send(writer, JsonRpcResult.result(id, true)); continue; } MethodDescriptor rpc = receiverManager.getMethodDescriptor(method); if (rpc == null) { send(writer, JsonRpcResult.error(id, new RpcError("Unknown RPC."))); continue; } try { send(writer, JsonRpcResult.result(id, rpc.invoke(receiverManager, params))); } catch (Throwable t) { Log.e("Invocation error.", t); send(writer, JsonRpcResult.error(id, t)); } } }
From source file:nl.nn.adapterframework.pipes.IsUserInRolePipe.java
protected void assertUserIsInRole(IPipeLineSession session) throws SecurityException { if (!session.isUserInRole(getRole())) { throw new SecurityException(getLogPrefix(session) + "user is not in role [" + getRole() + "]"); }/*from w w w . j a va2 s. c om*/ }
From source file:gxu.software_engineering.shen10.market.service.impl.RecordServiceImpl.java
@Override @Transactional(readOnly = false)/*from www . ja v a 2 s.com*/ public Record create(long itemId, long sellerId, String extra) { Item item = itemDao.find(itemId); Assert.notNull(item, "????"); if (item.isDeal()) { throw new RuntimeException("???????"); } if (item.isBlocked()) { throw new RuntimeException( "?????????"); } if (item.getSeller().isBlocked()) { throw new RuntimeException("??????"); } if (!item.getSeller().getId().equals(sellerId)) { throw new SecurityException("?????"); } Record record = new Record(); record.setOccurTime(new Date()); record.setExtra(extra); record.setItem(item); recordDao.persist(record); item.setDeal(true); itemDao.merge(item); return record; }
From source file:org.onecmdb.core.utils.xpath.commands.AbstractPathCommand.java
public JXPathContext getXPathContext() { if (this.xPathContext == null) { log.debug("Create new OneCMDbContext"); ISession session = this.oneCmdbContext.getSession(getAuth()); if (session == null) { throw new SecurityException("No Session found! Try to do auth() first!"); }/*from w ww. j a v a 2 s . c o m*/ /* IModelService mSvc = (IModelService)session.getService(IModelService.class); this.xPathContext = JXPathContext.newContext(new OneCMDBContext(new OneCMDBContextBeanProvider(mSvc))); */ this.context.put("session", session); this.xPathContext = JXPathContext.newContext(new OneCMDBContext(this.context, session)); this.xPathContext.setFactory(new OneCMDBFactory()); } return (this.xPathContext); }
From source file:com.auditbucket.registration.service.FortressService.java
private Company getCompany() { String userName = securityHelper.getUserName(true, false); SystemUser su = sysUserService.findByName(userName); if (su == null) { throw new SecurityException("Invalid user or password"); }// w w w. j a v a2s .com return su.getCompany(); }
From source file:org.apache.hadoop.hive.llap.daemon.impl.LlapTokenChecker.java
@VisibleForTesting static LlapTokenInfo getTokenInfoInternal(String kerberosName, List<LlapTokenIdentifier> tokens) { assert (tokens != null && !tokens.isEmpty()) || kerberosName != null; if (tokens == null) { return new LlapTokenInfo(kerberosName, null, true); }/*from ww w . jav a 2 s. c o m*/ String userName = kerberosName, appId = null; boolean isSigningRequired = false; for (LlapTokenIdentifier llapId : tokens) { String newUserName = llapId.getOwner().toString(); if (userName != null && !userName.equals(newUserName)) { throw new SecurityException("Ambiguous user name from credentials - " + userName + " and " + newUserName + " from " + llapId + ((kerberosName == null) ? ("; has kerberos credentials for " + kerberosName) : "")); } userName = newUserName; String newAppId = llapId.getAppId(); if (!StringUtils.isEmpty(newAppId)) { if (!StringUtils.isEmpty(appId) && !appId.equals(newAppId)) { throw new SecurityException("Ambiguous app ID from credentials - " + appId + " and " + newAppId + " from " + llapId); } appId = newAppId; } isSigningRequired = isSigningRequired || llapId.isSigningRequired(); } assert userName != null; return new LlapTokenInfo(userName, appId, isSigningRequired); }
From source file:net.sourceforge.subsonic.service.MediaFileService.java
/** * Returns a media file instance for the given file. If possible, a cached value is returned. * * @param file A file on the local file system. * @return A media file instance./*www.j ava 2 s. c o m*/ * @throws SecurityException If access is denied to the given file. */ public MediaFile getMediaFile(File file) { // Look in fast memory cache first. Element element = mediaFileMemoryCache.get(file); MediaFile result = element == null ? null : (MediaFile) element.getObjectValue(); if (result != null) { return result; } if (!securityService.isReadAllowed(file)) { throw new SecurityException("Access denied to file " + file); } // Secondly, look in database. result = mediaFileDao.getMediaFile(file.getPath()); if (result != null) { result = checkLastModified(result); mediaFileMemoryCache.put(new Element(file, result)); return result; } // Not found, must read from disk. result = createMediaFile(file); // Put in cache and database. mediaFileMemoryCache.put(new Element(file, result)); mediaFileDao.createOrUpdateMediaFile(result); return result; }
From source file:no.digipost.api.EbmsReferenceExtractor.java
public Map<String, Reference> getReferences(final SoapMessage message) { List<String> hrefs = getHrefsToInclude(message); Map<String, Reference> references = new HashMap<String, Reference>(); SoapHeaderElement wssec = message.getSoapHeader().examineHeaderElements(Constants.WSSEC_HEADER_QNAME) .next();/*from w ww . j av a2 s. c o m*/ Element element = (Element) Marshalling.unmarshal(jaxb2Marshaller, wssec, Object.class); Document doc = ((DOMSource) (message.getEnvelope().getSource())).getNode().getOwnerDocument(); for (String href : hrefs) { List<Node> refs = XpathUtil.getDOMXPath("//ds:Reference[@URI='" + href + "']", element); if (refs.size() == 0) { List<Node> parts = XpathUtil.getDOMXPath("//*[@Id='" + href.substring(1) + "']", message.getDocument().getDocumentElement()); if (parts.size() > 0) { String refId = parts.get(0).getAttributes() .getNamedItemNS(Constants.WSSEC_UTILS_NAMESPACE, "Id").getNodeValue(); refs = XpathUtil.getDOMXPath("//ds:Reference[@URI='#" + refId + "']", element); } } if (refs.size() > 0) { Reference ref = Marshalling.unmarshal(jaxb2Marshaller, refs.get(0), Reference.class); String name = "attachment"; Element elm = doc.getElementById(href.replace("#", "")); if (elm != null) { name = elm.getLocalName().toLowerCase(); } references.put(name, ref); } else { throw new SecurityException("Missing reference for " + href); } } return references; }