List of usage examples for java.lang SecurityException SecurityException
public SecurityException(Throwable cause)
From source file:org.apache.juddi.v3.client.subscription.SubscriptionCallbackListener.java
/** * Starts a embedded Jetty web server (comes with the JDK) using the * Endpoint API.//from w w w . j a va 2s.c o m * * @param client * @param cfg_node_name * @param endpoint this is the url that a UDDI server would use to * connect to the client's subscription listener service Recommend * specifying a port that is firewall friendly * @param keydomain * @param autoregister * @param behavior * @param serviceKey * @return null, if and only if callbackBusinessService was null, * otherwise the modified callbackBusinessService is returned. Clients * can then use it to continue the registration process. * @throws ServiceAlreadyStartedException * @throws SecurityException * @throws ConfigurationException * @throws TransportException * @throws DispositionReportFaultMessage * @throws java.rmi.UnexpectedException * @throws org.apache.juddi.v3.client.subscription.RegistrationAbortedException * @throws java.net.MalformedURLException * @throws org.apache.juddi.v3.client.subscription.UnableToSignException * @see Endpoint */ public static synchronized BindingTemplate start(UDDIClient client, String cfg_node_name, String endpoint, String keydomain, boolean autoregister, String serviceKey, SignatureBehavior behavior) throws ServiceAlreadyStartedException, SecurityException, ConfigurationException, TransportException, DispositionReportFaultMessage, RemoteException, UnexpectedException, RegistrationAbortedException, UnableToSignException, MalformedURLException { if (instance == null) { instance = new SubscriptionCallbackListener(); } if (ep != null && ep.isPublished()) { throw new ServiceAlreadyStartedException(); } URL url = null; try { url = new URL(endpoint); } catch (Exception ex) { log.warn("Callback endpoint couldn't be parsed, generating a random one: " + ex.getMessage()); url = new URL( "http://" + GetHostname() + ":" + GetRandomPort(4000) + "/" + UUID.randomUUID().toString()); } endpoint = url.toString(); //if (endpoint == null || endpoint.equals("")) { // endpoint = "http://" + GetHostname() + ":" + GetRandomPort(url.getPort()) + "/" + UUID.randomUUID().toString(); int attempts = 5; if (ep == null) { while ((ep == null || !ep.isPublished()) && attempts > 0) { try { ep = Endpoint.publish(endpoint, instance); callback = endpoint; } catch (Exception be) { log.info("trouble starting callback at " + endpoint + ", trying again with a random port: " + be.getMessage()); log.debug(be); attempts--; //if (be instanceof java.net.BindException) { url = new URL( "http://" + url.getHost() + ":" + GetRandomPort(url.getPort()) + "/" + url.getPath()); endpoint = url.toString(); } } } if (ep == null || !ep.isPublished()) { log.warn("Unable to start callback endpoint, aborting"); throw new SecurityException("unable to start endpoint, view previous errors for reason"); } log.info("Endpoint started at " + callback); BindingTemplate bt = new BindingTemplate(); bt.setAccessPoint(new AccessPoint()); bt.getAccessPoint().setValue(callback); bt.getAccessPoint().setUseType("endPoint"); TModelInstanceInfo instanceInfo = new TModelInstanceInfo(); instanceInfo.setTModelKey("uddi:uddi.org:transport:http"); bt.setTModelInstanceDetails(new TModelInstanceDetails()); bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo); bt.setServiceKey(serviceKey); if (keydomain.endsWith(":")) { bt.setBindingKey(keydomain + GetHostname() + "_subscription_callback"); } else { bt.setBindingKey(keydomain + ":" + GetHostname() + "_subscription_callback"); } if (autoregister) { bt = registerBinding(client, cfg_node_name, bt, behavior); } return bt; }
From source file:com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.java
/** * Double check the master secret of an SSL session must not be null, or * else a {@link SecurityException} will be thrown. * @param sock connected socket//w ww. j a v a 2 s . c o m */ private void verifyMasterSecret(final Socket sock) { if (sock instanceof SSLSocket) { SSLSocket ssl = (SSLSocket) sock; SSLSession session = ssl.getSession(); if (session != null) { String className = session.getClass().getName(); if ("sun.security.ssl.SSLSessionImpl".equals(className)) { try { Class<?> clazz = Class.forName(className); Method method = clazz.getDeclaredMethod("getMasterSecret"); method.setAccessible(true); Object masterSecret = method.invoke(session); if (masterSecret == null) { session.invalidate(); if (log.isDebugEnabled()) { log.debug("Invalidated session " + session); } throw log(new SecurityException("Invalid SSL master secret")); } } catch (ClassNotFoundException e) { failedToVerifyMasterSecret(e); } catch (NoSuchMethodException e) { failedToVerifyMasterSecret(e); } catch (IllegalAccessException e) { failedToVerifyMasterSecret(e); } catch (InvocationTargetException e) { failedToVerifyMasterSecret(e.getCause()); } } } } return; }
From source file:gxu.software_engineering.shen10.market.service.impl.ItemServiceImpl.java
private void modifiable(Item i, long uid) { Assert.notNull(i, "????"); if (i.getSeller().getId() != uid) { throw new SecurityException("?????"); }/* w w w. j av a2 s .c om*/ if (i.isBlocked()) { throw new RuntimeException("?????????"); } if (i.isDeal()) { throw new RuntimeException("???????"); } }
From source file:de.juwimm.cms.authorization.remote.AuthorizationServiceSpringImpl.java
/** * @see de.juwimm.cms.authorization.remote.AuthorizationServiceSpring#login(java.lang.String, * java.lang.String, java.lang.Integer) *///from www . j ava2 s .c o m @Override protected UserLoginValue handleLogin(String userName, String passwd, Integer siteId) throws Exception { // try { if (log.isDebugEnabled()) { log.debug("Try to login \"" + AuthenticationHelper.getUserName() + "\" at " + siteId); } SiteHbm site = null; try { site = super.getSiteHbmDao().load(siteId); } catch (Exception exe) { throw new SecurityException("Invalid SiteId"); } UserHbm user = null; try { user = super.getUserHbmDao().load(AuthenticationHelper.getUserName()); } catch (Exception ex) { throw new SecurityException("Invalid Principal"); } if (!user.isMasterRoot() && !user.getSites().contains(site)) { throw new SecurityException("User is not a member of the given site!"); } user.setActiveSite(site); user.setLoginDate((System.currentTimeMillis())); LoginContext lc = new LoginContext("juwimm-cms-security-domain", new InternalCallbackHandler(passwd)); lc.login(); /* * if(log.isDebugEnabled()) { Subject subj = lc.getSubject(); * Principal[] prip = (Principal[]) subj.getPrincipals().toArray(new * Principal[0]); Group groupPrincipal = null; for(int i = 0; i < * prip.length; i++) { if(prip[i] instanceof Group) { groupPrincipal = * ((Group) prip[i]); Enumeration group = groupPrincipal.members(); * while(group.hasMoreElements()) { Principal rolePrincipal = * ((Principal) group.nextElement()); String role = * rolePrincipal.getName(); log.debug("User is in role: " + role); } } * else { //log.warn("Found one Principal other then a group - is is: " + * prip[i].getName()); } } } */ if (log.isInfoEnabled()) log.info("Login User " + user.getUserId() + " at site " + site.getSiteId() + " (" + site.getShortName().trim() + ")"); // UserLoginValue ulv = user.getUserLoginValue(); UserLoginValue ulv = super.getUserHbmDao().getUserLoginValue(user); ulv.setSiteName(site.getName()); ulv.setSiteConfigXML(site.getConfigXML()); return ulv; // } catch (Exception e) { // throw new UserException(e.getMessage()); // } }
From source file:org.onecmdb.core.utils.wsdl.OneCMDBWebServiceImpl.java
public int historyCount(String auth, CiBean bean, RfcQueryCriteria criteria) { long start = System.currentTimeMillis(); log.info("WSDL: history(" + auth + ", " + criteria + ")"); // Update all beans. ISession session = onecmdb.getSession(auth); if (session == null) { throw new SecurityException("No Session found! Try to do auth() first!"); }/*from w w w. j a v a 2 s . com*/ // Find the ci if provided. IModelService modelSvc = (IModelService) session.getService(IModelService.class); ICi ci = null; if (bean != null) { if (bean.getId() != null) { ci = modelSvc.find(new ItemId(bean.getId())); if (ci == null) { throw new IllegalArgumentException("CI with id <" + bean.getId() + "> not found"); } } else if (bean.getAlias() != null) { ci = modelSvc.findCi(new Path<String>(bean.getAlias())); if (ci == null) { throw new IllegalArgumentException("CI with alias <" + bean.getAlias() + "> not found"); } } } ICcb ccbSvc = (ICcb) session.getService(ICcb.class); int count = ccbSvc.queryRFCForCiCount(ci, criteria); long stop = System.currentTimeMillis(); log.info("WSDL: historyCount completed in " + (stop - start) + "ms returned + " + count); return (count); }
From source file:de.itsvs.cwtrpc.core.DefaultExtendedSerializationPolicyProvider.java
protected String getPolicyPath(String relativeModuleBasePath, String strongName) throws SecurityException { final StringBuilder strongNamePathBuilder; final String resultingPath; strongNamePathBuilder = new StringBuilder(); strongNamePathBuilder.append(relativeModuleBasePath); strongNamePathBuilder.append(strongName); if (strongNamePathBuilder.indexOf("/..") >= 0) { throw new SecurityException("Specified combination of module base Url and " + "strong name contains relative path to " + "sub directory: " + strongNamePathBuilder); }/* w w w . j av a 2s. c o m*/ resultingPath = SerializationPolicyLoader.getSerializationPolicyFileName(strongNamePathBuilder.toString()); return resultingPath; }
From source file:com.jaspersoft.jasperserver.war.xmla.XmlaContentFinderImpl.java
public Properties getMondrianConnectionProperties(Map<String, Object> dataSourceProperties, String role) { MondrianConnection monConn = lookupXmlaConnection(null, (String) dataSourceProperties.get("DataSourceInfo")); Util.PropertyList connectProperties = olapConnectionService.getMondrianConnectProperties(null, monConn); // Checking access if (!DataSourcesConfig.DataSource.AUTH_MODE_UNAUTHENTICATED .equalsIgnoreCase((String) dataSourceProperties.get("AuthenticationMode")) && null == role) { throw new XmlaException(XmlaConstants.CLIENT_FAULT_FC, XmlaConstants.HSB_ACCESS_DENIED_CODE, XmlaConstants.HSB_ACCESS_DENIED_FAULT_FS, new SecurityException("Access denied for data source needing authentication")); }//from ww w .j av a 2s . c o m if (role != null && role.trim().length() != 0) { connectProperties.put(RolapConnectionProperties.Role.toString(), role); } Properties properties = new Properties(); for (Pair<String, String> pair : connectProperties) { properties.put(pair.getKey(), pair.getValue()); } return properties; }
From source file:com.bittorrent.mpetazzoni.client.SharedTorrent.java
/** * Create a new shared torrent from meta-info binary data. * * @param torrent The meta-info byte data. * @param parent The parent directory or location the torrent files. * @param seeder Whether we're a seeder for this torrent or not (disables * validation).//from w ww. j a v a2s .co m * @throws FileNotFoundException If the torrent file location or * destination directory does not exist and can't be created. * @throws IOException If the torrent file cannot be read or decoded. */ public SharedTorrent(byte[] torrent, File parent, boolean seeder) throws FileNotFoundException, IOException { super(torrent, seeder); if (parent == null || !parent.isDirectory()) { throw new IllegalArgumentException("Invalid parent directory!"); } String parentPath = parent.getCanonicalPath(); try { this.pieceLength = this.decoded_info.get("piece length").getInt(); this.piecesHashes = ByteBuffer.wrap(this.decoded_info.get("pieces").getBytes()); if (this.piecesHashes.capacity() / Torrent.PIECE_HASH_SIZE * (long) this.pieceLength < this.getSize()) { throw new IllegalArgumentException( "Torrent size does not " + "match the number of pieces and the piece size!"); } } catch (InvalidBEncodingException ibee) { throw new IllegalArgumentException("Error reading torrent meta-info fields!"); } List<FileStorage> files = new LinkedList<FileStorage>(); long offset = 0L; for (Torrent.TorrentFile file : this.files) { File actual = new File(parent, file.file.getPath()); if (!actual.getCanonicalPath().startsWith(parentPath)) { throw new SecurityException("Torrent file path attempted " + "to break directory jail!"); } actual.getParentFile().mkdirs(); files.add(new FileStorage(actual, offset, file.size)); offset += file.size; } this.bucket = new FileCollectionStorage(files, this.getSize()); this.random = new Random(System.currentTimeMillis()); this.stop = false; this.uploaded = 0; this.downloaded = 0; this.left = this.getSize(); this.initialized = false; this.pieces = new Piece[0]; this.rarest = Collections.synchronizedSortedSet(new TreeSet<Piece>()); this.completedPieces = new BitSet(); this.requestedPieces = new BitSet(); }
From source file:org.LexGrid.LexBIG.caCore.applicationservice.impl.LexEVSApplicationServiceImpl.java
/** * Execute the given method on the specified LexBig object. * * @param object - Object// w ww . jav a2 s .co m * @param methodName - String * @param parameterClasses -String[] * @param args - Object[] * * @return the object * * @throws ApplicationException the application exception */ public Object executeRemotely(Object object, String methodName, String[] parameterClasses, Object[] args) throws ApplicationException { if (!LexEVSCaCoreUtils.isLexBigClass(object.getClass())) { throw new SecurityException("Cannot execute method on non-LexBig object"); } try { int i = 0; Class[] parameterTypes = new Class[parameterClasses.length]; for (String paramClass : parameterClasses) { parameterTypes[i++] = ClassUtils.forName(paramClass, LexEvsServiceLocator.getInstance().getSystemResourceService().getClassLoader()); } Method objMethod = object.getClass().getMethod(methodName, parameterTypes); Object result = objMethod.invoke(object, args); result = replaceWithShell(result); //Wrap up the result and the current state of the object //and return it. We will use the object on the client side //to update the proxy state. if (updateClientProxyTarget) { return new RemoteExecutionResults(object, result); } else { return result; } } catch (Exception e) { throw new ApplicationException("Failed to execute LexBig method remotely", e); } }
From source file:be.agiv.security.AGIVSecurity.java
/** * Constructor for X509 credentials. The certificate and corresponding * private key are loaded from a PKCS#12 keystore file. * /*from w w w. j a v a 2 s.c om*/ * @param ipStsLocation * the location of the IP-STS WS-Trust web service. * @param rStsLocation * the location of the R-STS WS-Trust web service. * @param rStsRealm * the AGIV R-STS realm. * @param pkcs12File * the PKCS#12 keystore file. * @param pkcs12Password * the PKCS#12 keystore password. * @throws SecurityException * gets thrown in case of a PKCS#12 keystore error. * @see AGIVSecurity#AGIVSecurity(String, String, X509Certificate, * PrivateKey) */ public AGIVSecurity(String ipStsLocation, String rStsLocation, String rStsRealm, File pkcs12File, String pkcs12Password) throws SecurityException { this.ipStsLocation = ipStsLocation; this.rStsLocation = rStsLocation; this.rStsRealm = rStsRealm; this.username = null; this.password = null; InputStream pkcs12InputStream; try { pkcs12InputStream = new FileInputStream(pkcs12File); } catch (FileNotFoundException e) { throw new SecurityException("PKCS#12 file does not exist: " + pkcs12File.getAbsolutePath()); } Provider sunJSSEProvider = Security.getProvider("SunJSSE"); try { KeyStore keyStore; if (null != sunJSSEProvider) { // avoid older BouncyCastle implementations keyStore = KeyStore.getInstance("PKCS12", sunJSSEProvider); } else { keyStore = KeyStore.getInstance("PKCS12"); } keyStore.load(pkcs12InputStream, pkcs12Password.toCharArray()); Enumeration<String> aliases = keyStore.aliases(); String alias = aliases.nextElement(); this.certificate = (X509Certificate) keyStore.getCertificate(alias); this.privateKey = (PrivateKey) keyStore.getKey(alias, pkcs12Password.toCharArray()); } catch (Exception e) { LOG.error("error loading PKCS#12 keystore: " + e.getMessage(), e); throw new SecurityException("error loading PKCS#12 certificate: " + e.getMessage(), e); } this.externalIpStsClient = null; this.secureConversationTokens = new ConcurrentHashMap<String, SecurityToken>(); this.rStsSecurityTokens = new ConcurrentHashMap<String, SecurityToken>(); this.stsListeners = new CopyOnWriteArrayList<STSListener>(); }