Example usage for java.security GeneralSecurityException getMessage

List of usage examples for java.security GeneralSecurityException getMessage

Introduction

In this page you can find the example usage for java.security GeneralSecurityException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.nokia.example.pepperfarm.client.PepperFarmMainScreenActivity.java

@Override
public void onStart() {
    Log.i(LOG_TAG, "onStart");
    super.onStart();
    try {//from   w  ww.  j a v a2 s .c  o m
        if (purchaseHandler != null) {
            if (!purchaseHandler.npayAvailable) {
                purchaseHandler.connectToService(this);
            }
        } else {
            purchaseHandler = new Payment(this);
            purchaseHandler.connectToService(this);
            Log.i(LOG_TAG, "Npay initialization SUCCESS, waiting for service connection");
        }
    } catch (GeneralSecurityException e) {
        Log.e(LOG_TAG, "Npay initialization FAILED: " + e.getMessage(), e);
    }
}

From source file:com.fortmoon.utils.SymmetricCypher.java

public String decypher(String cipher) {
    try {//from   w ww. jav a 2 s  .  com
        Cipher jceCipher = Cipher.getInstance(cipherTransformation);
        jceCipher.init(2, secretKeySpec);
        byte ciphertext[] = cipher.getBytes();
        byte decodedText[] = Base64.decodeBase64(ciphertext);
        byte cleartext[] = jceCipher.doFinal(decodedText);
        String res = new String(cleartext);

        return res;

    } catch (GeneralSecurityException gse) {
        throw new EncryptionRuntimeException((new StringBuilder("Failed to decrypt: ")).append(cipher)
                .append(" exception: ").append(gse.getMessage()).toString(), gse);
    }
}

From source file:com.nokia.example.pepperfarm.client.ProductListActivity.java

private void connectToService() {
    try {//from   w w w . java  2 s .c o m
        if (purchaseHandler != null) {
            if (!purchaseHandler.npayAvailable) {
                purchaseHandler.connectToService(this);
            }
        } else {
            purchaseHandler = new Payment(this);
            purchaseHandler.connectToService(this);
            Log.i(LOG_TAG, "Npay initialization SUCCESS, waiting for service connection");
        }
    } catch (GeneralSecurityException e) {
        Log.e(LOG_TAG, "Npay initialization FAILED: " + e.getMessage(), e);
    }
}

From source file:io.cloudslang.content.httpclient.build.conn.SSLConnectionSocketFactoryBuilder.java

protected void createKeystore(SSLContextBuilder sslContextBuilder, boolean useClientCert) {
    if (useClientCert) {
        KeyStore clientKeyStore;/* w  w  w .j  av a2  s  . co m*/
        try {
            clientKeyStore = createKeyStore(new URL(keystore), keystorePassword);
            sslContextBuilder.loadKeyMaterial(clientKeyStore, keystorePassword.toCharArray());
        } catch (UnrecoverableKeyException | IOException ue) {
            throw new IllegalArgumentException(ue.getMessage() + ". " + BAD_KEYSTORE_ERROR, ue);
        } catch (GeneralSecurityException gse) {
            throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_KEYSTORE_ERROR, gse);
        }
    }
}

From source file:io.cloudslang.content.httpclient.build.conn.SSLConnectionSocketFactoryBuilder.java

protected void createTrustKeystore(SSLContextBuilder sslContextBuilder, boolean useTrustCert) {
    if (useTrustCert) {
        KeyStore trustKeyStore;/*from   w w w. j ava  2s .co m*/
        try {
            //todo should we do this 'create' in each and every step?
            trustKeyStore = createKeyStore(new URL(trustKeystore), trustPassword);
            sslContextBuilder.loadTrustMaterial(trustKeyStore);
        } catch (IOException ioe) {
            throw new IllegalArgumentException(ioe.getMessage() + ". " + BAD_TRUST_KEYSTORE_ERROR, ioe);
        } catch (GeneralSecurityException gse) {
            throw new IllegalArgumentException(gse.getMessage() + ". " + INVALID_TRUST_KEYSTORE_ERROR, gse);
        }
    }
}

From source file:org.glite.slcs.dn.impl.SimplePatternBuilder.java

/**
 * Validates and returns the normalized DN.
 * //from  w  w w .  j  a  v  a2s  .c  o m
 * @param dn
 *            The subject DN to validate and normalize.
 * @return The validated, normalized DN.
 * @throws SLCSException
 *             if a validation error occurs.
 */
public String validateDN(String dn) throws SLCSException {
    X509PrincipalUtil utility = new X509PrincipalUtil();
    X509Principal principal;
    try {
        principal = utility.createX509Principal(dn);
        String principalName = principal.getName();
        LOG.debug("X509Principal: " + principalName);
        return principalName;
    } catch (GeneralSecurityException e) {
        LOG.error(e);
        throw new ServiceException("Invalid DN " + dn + ": " + e.getMessage(), e.getCause());
    }
}

From source file:de.j4velin.encrypter.EncryptedFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, final Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == REQUEST_OUTPUT) {
            String expectedFilename;
            if (data.hasExtra(Intent.EXTRA_TITLE)) {
                expectedFilename = data.getStringExtra(Intent.EXTRA_TITLE);
            } else {
                expectedFilename = selectedFile.name;
            }//from   w  ww. j a  va2s.  c o  m
            try {
                CryptoUtil.decrypt(getContext(), selectedFile, data.getData(), expectedFilename);
            } catch (GeneralSecurityException e) {
                Snackbar.make(((MainActivity) getActivity()).getCoordinatorLayout(),
                        getString(R.string.error_security, e.getMessage()), Snackbar.LENGTH_LONG).show();
            } catch (FileNotFoundException e) {
                Snackbar.make(((MainActivity) getActivity()).getCoordinatorLayout(),
                        R.string.error_file_not_found, Snackbar.LENGTH_LONG).show();
            } catch (IOException e) {
                Snackbar.make(((MainActivity) getActivity()).getCoordinatorLayout(),
                        getString(R.string.error_io, e.getMessage()), Snackbar.LENGTH_LONG).show();
            }
        }
    }
}

From source file:org.kuali.rice.kns.util.ActionFormUtilMap.java

/**
 * Encrypts a value passed from the ui./*from  ww w.  j  a  v  a  2s . co m*/
 * @param value - clear text
 * @return String - encrypted text
 */
public String encryptValue(Object value) {
    String encrypted = "";
    if (value != null) {
        encrypted = value.toString();
    }

    try {
        if (CoreApiServiceLocator.getEncryptionService().isEnabled()) {
            encrypted = CoreApiServiceLocator.getEncryptionService().encrypt(value);
        }
    } catch (GeneralSecurityException e) {
        throw new RuntimeException("Unable to encrypt value in action form: " + e.getMessage());
    }

    return encrypted;
}

From source file:org.eclipse.kura.core.deployment.download.impl.HttpDownloadCountingOutputStream.java

private void testConnectionProtocol(URLConnection urlConnection) throws IOException, KuraConnectException {
    try {/*from  ww  w.  j  av a2 s .co m*/
        if (urlConnection instanceof HttpsURLConnection) {
            ((HttpsURLConnection) urlConnection)
                    .setSSLSocketFactory(this.m_sslManagerService.getSSLSocketFactory());
        } else if (!(urlConnection instanceof HttpURLConnection)) {
            postProgressEvent(this.options.getClientId(), getByteCount(), this.totalBytes,
                    DOWNLOAD_STATUS.FAILED, "The request URL is not supported");
            throw new KuraConnectException("Unsupported protocol!");
        }
    } catch (GeneralSecurityException e) {
        postProgressEvent(this.options.getClientId(), getByteCount(), this.totalBytes, DOWNLOAD_STATUS.FAILED,
                e.getMessage());
        throw new KuraConnectException(e, "Unsupported protocol!");
    }
}

From source file:org.kuali.kfs.coa.document.AccountDelegateMaintainableImpl.java

/**
 * This method returns the field value of a given field, converting the value to a String and encrypting it if necessary
 * /* w  ww. j  av a  2 s .co  m*/
 * @param fieldName
 * @param ddService
 * @return string field value for a lock
 */
protected String retrieveFieldValueForLock(String fieldName, DataDictionaryService ddService,
        EncryptionService encryptionService) {
    Object fieldValue = ObjectUtils.getPropertyValue(this.businessObject, fieldName);
    if (fieldValue == null) {
        fieldValue = "";
    }

    // check if field is a secure
    if (SpringContext.getBean(BusinessObjectAuthorizationService.class)
            .attributeValueNeedsToBeEncryptedOnFormsAndLinks(getBoClass(), fieldName)) {
        try {
            fieldValue = encryptionService.encrypt(fieldValue);
        } catch (GeneralSecurityException e) {
            LOG.error("Unable to encrypt secure field for locking representation " + e.getMessage());
            throw new RuntimeException(
                    "Unable to encrypt secure field for locking representation " + e.getMessage());
        }
    }
    return String.valueOf(fieldValue);
}