List of usage examples for java.lang SecurityException getMessage
public String getMessage()
From source file:net.bubble.common.utils.BeanContextUtil.java
/** * ?JDK??</br>//from w ww.jav a 2 s. c o m * Spring??AOP?JDK?? * @param proxy ? * @return Object * @throws CommonException jdk??? */ public Object getJdkDynamicProxyTargetObject(Object proxy) throws CommonException { try { Field field = proxy.getClass().getSuperclass().getDeclaredField("h"); field.setAccessible(true); AopProxy aopProxy = (AopProxy) field.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport) advised.get(aopProxy)).getTargetSource().getTarget(); return target; } catch (SecurityException e) { logger.error(e.getMessage(), e); throw new CommonException("The method of object with Dynamic jdk proxy can't be read !", e); } catch (NoSuchFieldException e) { logger.error(e.getMessage(), e); throw new CommonException("Can't find field in Dynamic jdk proxy object !", e); } catch (IllegalArgumentException e) { logger.error(e.getMessage(), e); throw new CommonException("Inject parameter to Dynamic jdk proxy object has error !", e); } catch (IllegalAccessException e) { logger.error(e.getMessage(), e); throw new CommonException("Access Dynamic jdk proxy object has error !", e); } catch (Exception e) { logger.error(e.getMessage(), e); throw new CommonException("Get Dynamic jdk proxy target object has error !", e); } }
From source file:org.jadira.scanner.classpath.types.JField.java
@Override public JType getType() throws ClasspathAccessException { final JType retVal; Class<?> clazz;/* w w w . j a va2 s . c o m*/ try { Field field = getActualField(); clazz = field.getType(); } catch (SecurityException e) { throw new ClasspathAccessException("Problem finding enclosing type: " + e.getMessage(), e); } if (clazz.isInterface()) { retVal = JInterface.getJInterface(clazz.getName(), getResolver()); } else if (clazz.isPrimitive()) { retVal = JPrimitiveClass.getJClass(clazz.getName(), getResolver()); } else if (clazz.isArray()) { retVal = JArrayClass.getJClass(clazz, getResolver()); } else { retVal = JClass.getJClass(clazz.getName(), getResolver()); } return retVal; }
From source file:org.exolab.castor.jdo.engine.jdo_descriptors.AddressJDODescriptor.java
/** * @param choice/*from w ww .ja va 2s . c o m*/ * @return jdo field descriptor for id */ private FieldDescriptor initId(final ClassChoice choice) { String idFieldName = "id"; FieldDescriptorImpl idFieldDescr; FieldMapping idFM = new FieldMapping(); TypeInfo idType = new TypeInfo(java.lang.Integer.class); // Set columns required (=not null) idType.setRequired(true); FieldHandler idHandler; try { idHandler = new FieldHandlerImpl(idFieldName, null, null, Address.class.getMethod("getId"), Address.class.getMethod("setId", new Class[] { int.class }), idType); } catch (SecurityException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } catch (MappingException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } catch (NoSuchMethodException e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } // Instantiate title field descriptor idFieldDescr = new FieldDescriptorImpl(idFieldName, idType, idHandler, false); idFieldDescr.addNature(FieldDescriptorJDONature.class.getName()); FieldDescriptorJDONature idJdoNature = new FieldDescriptorJDONature(idFieldDescr); idJdoNature.setSQLName(new String[] { idFieldName }); idJdoNature.setSQLType(new int[] { SQLTypeInfos.javaType2sqlTypeNum(java.lang.Integer.class) }); idJdoNature.setManyKey(null); idJdoNature.setDirtyCheck(false); idJdoNature.setReadOnly(false); // Set parent class descriptor idFieldDescr.setContainingClassDescriptor(this); idFieldDescr.setClassDescriptor(this); idFieldDescr.setIdentity(true); idFM.setIdentity(true); idFM.setDirect(false); idFM.setName("id"); idFM.setRequired(true); idFM.setSetMethod("setId"); idFM.setGetMethod("getId"); idFM.setType("integer"); Sql idSql = new Sql(); idSql.addName("id"); idSql.setType("integer"); idFM.setSql(idSql); // Add field mappings choice.addFieldMapping(idFM); return idFieldDescr; }
From source file:org.apache.maven.classpath.munger.validation.JarValidationUtilsTest.java
@Test public void testSignatureOnDifferentDirectoryEntries() throws Exception { byte[] TEST_DATA = (getClass().getName() + "#" + getCurrentTestName()).getBytes("UTF-8"); List<ZipEntry> entriesList = createTestZipEntries(); NamedPropertySource expected = JarValidationUtils.createJarSignature(createTestJar(entriesList, TEST_DATA)); entriesList.add(0, new ZipEntry("before/")); entriesList.add(new ZipEntry("after/")); NamedPropertySource actual = JarValidationUtils.createJarSignature(createTestJar(entriesList, TEST_DATA)); try {// w w w .j ava 2s . c om JarValidationUtils.validateJarSignature(expected, actual); fail("Unexpected success"); } catch (SecurityException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage()); } } }
From source file:com.invariantproperties.sandbox.springentitylistener.service.EncryptorBean.java
/** * Constructor creates secret key. In production we may want to avoid * keeping the secret key hanging around in memory for very long. *///from ww w . j av a 2 s. c om public EncryptorBean() { try { // create the PBE key KeySpec spec = new PBEKeySpec(PASSWORD, Base64.decode(SALT), 10000, 128); key = SecretKeyFactory.getInstance(PBE_ALGORITHM).generateSecret(spec); } catch (SecurityException ex) { // handle appropriately... System.out.println("encryptor bean ctor exception: " + ex.getMessage()); } catch (NoSuchAlgorithmException ex) { // handle appropriately... System.out.println("encryptor bean ctor exception: " + ex.getMessage()); } catch (InvalidKeySpecException ex) { // handle appropriately... System.out.println("encryptor bean ctor exception: " + ex.getMessage()); } }
From source file:com.apporiented.hermesftp.server.impl.FtpServerOptionsImpl.java
/** * {@inheritDoc}//from w w w . ja va 2s .c o m */ public SSLContext getSslContext() throws FtpConfigException { if (sslContext == null) { char[] ksPass; String ksFile = getProperty(OPT_SSL_KEYSTORE_FILE); if (ksFile == null || ksFile.length() == 0) { throw new FtpConfigException("Keystore file not defined."); } String ksPassStr = getProperty(OPT_SSL_KEYSTORE_PASS); ksPass = ksPassStr == null ? new char[0] : ksPassStr.toCharArray(); try { sslContext = SecurityUtil.createSslContext(ksFile, ksPass); } catch (SecurityException e) { throw new FtpConfigException(e.getMessage()); } } return sslContext; }
From source file:org.jadira.scanner.classpath.types.JOperation.java
public Method getActualMethod() throws ClasspathAccessException { try {/*from w w w . java 2 s .c o m*/ return getEnclosingType().getActualClass().getMethod(getName(), getMethodParamClasses(methodInfo)); } catch (SecurityException e) { throw new ClasspathAccessException("Problem obtaining method: " + e.getMessage(), e); } catch (NoSuchMethodException e) { throw new ClasspathAccessException("Problem finding method: " + e.getMessage(), e); } }
From source file:org.apache.maven.classpath.munger.validation.JarValidationUtilsTest.java
@Test public void testSignatureOnShuffledContents() throws Exception { byte[] TEST_DATA = (getClass().getName() + "#" + getCurrentTestName()).getBytes("UTF-8"); NamedPropertySource expected = JarValidationUtils.createJarSignature(createTestJar(TEST_DATA)); Random rnd = new Random(System.nanoTime()); for (int index = 0; index < Long.SIZE; index++) { shuffle(rnd, TEST_DATA);//from w w w.j a va 2 s . c o m NamedPropertySource actual = JarValidationUtils.createJarSignature(createTestJar(TEST_DATA)); try { JarValidationUtils.validateJarSignature(expected, actual); fail("Unexpected success for " + new String(TEST_DATA)); } catch (SecurityException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage()); } } } }
From source file:org.phenotips.data.rest.internal.DefaultPatientsFetchResourceImpl.java
/** * Given the patient's internal ID, retrieves the patient entity, if it exists and if the user has view rights, and * adds it to the set of patient entities. * * @param patientsBuilder a patient entity set builder * @param id an internal patient ID//from w w w . jav a 2 s . c o m */ private void addPatientFromId(@Nonnull final ImmutableSet.Builder<PrimaryEntity> patientsBuilder, @Nonnull final Object id) { try { // Try to get the patient entity. final PrimaryEntity patient = this.repository.get((String) id); // If user has view rights and patient with the provided ID exists, add patient to patient set. if (patient != null) { patientsBuilder.add(patient); } } catch (final SecurityException ex) { this.logger.warn("Failed to retrieve patient with ID [{}]: {}", id, ex.getMessage()); } }
From source file:org.appcelerator.titanium.analytics.TiAnalyticsService.java
private boolean canSend() { boolean result = false; //int type = netInfo.getType(); //int subType = netInfo.getSubType(); // TODO change defaults based on implied speed of network NetworkInfo netInfo = null;//from w w w. jav a2 s . c om try { netInfo = connectivityManager.getActiveNetworkInfo(); } catch (SecurityException e) { Log.w(TAG, "Connectivity permissions have been removed from AndroidManifest.xml: " + e.getMessage()); } if (netInfo != null && netInfo.isConnected() && !netInfo.isRoaming()) { result = true; } return result; }