Example usage for java.security InvalidParameterException InvalidParameterException

List of usage examples for java.security InvalidParameterException InvalidParameterException

Introduction

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

Prototype

public InvalidParameterException(String msg) 

Source Link

Document

Constructs an InvalidParameterException with the specified detail message.

Usage

From source file:ar.com.zauber.commons.web.transformation.processors.dao.impl.SimpleStartsWithDocumentProviderDAO.java

/** @see DocumentProviderDAO#getDocumentProvider(String) */
public final DocumentProvider getDocumentProvider(final String url) {
    if (accept(url)) {
        return this.documentProvider;
    }//  www  .ja v a  2  s.  c o  m
    throw new InvalidParameterException("no document provider for: " + url);
}

From source file:org.zaproxy.zap.model.StructuralTableNode.java

@Override
public StructuralNode getParent() throws DatabaseException {
    if (parent == null && !this.isRoot()) {
        RecordStructure prs = Model.getSingleton().getDb().getTableStructure().read(rs.getSessionId(),
                rs.getStructureId());//w  w w . j a  v  a  2  s  .  co  m
        if (prs == null) {
            throw new InvalidParameterException(
                    "Failed to find parent sessionId=" + rs.getSessionId() + " parentId=" + rs.getParentId());
        }
        parent = new StructuralTableNode(prs);
    }
    return parent;
}

From source file:org.xdi.oxauth.model.crypto.signature.ECDSAKeyFactory.java

public ECDSAKeyFactory(SignatureAlgorithm signatureAlgorithm, String dnName) throws InvalidParameterException,
        NoSuchProviderException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
        SignatureException, InvalidKeyException, CertificateEncodingException {
    if (signatureAlgorithm == null) {
        throw new InvalidParameterException("The signature algorithm cannot be null");
    }//from   w  w  w. j  a  v a  2 s .  c  o  m

    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(signatureAlgorithm.getCurve());

    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "BC");
    keyGen.initialize(ecSpec, new SecureRandom());

    KeyPair keyPair = keyGen.generateKeyPair();
    JCEECPrivateKey privateKeySpec = (JCEECPrivateKey) keyPair.getPrivate();
    JCEECPublicKey publicKeySpec = (JCEECPublicKey) keyPair.getPublic();

    BigInteger x = publicKeySpec.getQ().getX().toBigInteger();
    BigInteger y = publicKeySpec.getQ().getY().toBigInteger();
    BigInteger d = privateKeySpec.getD();

    ecdsaPrivateKey = new ECDSAPrivateKey(d);
    ecdsaPublicKey = new ECDSAPublicKey(signatureAlgorithm, x, y);

    if (StringUtils.isNotBlank(dnName)) {
        // Create certificate
        GregorianCalendar startDate = new GregorianCalendar(); // time from which certificate is valid
        GregorianCalendar expiryDate = new GregorianCalendar(); // time after which certificate is not valid
        expiryDate.add(Calendar.YEAR, 1);
        BigInteger serialNumber = new BigInteger(1024, new Random()); // serial number for certificate

        X509V1CertificateGenerator certGen = new X509V1CertificateGenerator();
        X500Principal principal = new X500Principal(dnName);

        certGen.setSerialNumber(serialNumber);
        certGen.setIssuerDN(principal);
        certGen.setNotBefore(startDate.getTime());
        certGen.setNotAfter(expiryDate.getTime());
        certGen.setSubjectDN(principal); // note: same as issuer
        certGen.setPublicKey(keyPair.getPublic());
        certGen.setSignatureAlgorithm("SHA256WITHECDSA");

        X509Certificate x509Certificate = certGen.generate(privateKeySpec, "BC");
        certificate = new Certificate(signatureAlgorithm, x509Certificate);
    }
}

From source file:ips1ap101.ejb.core.mail.MailerBean.java

@Override
public Message sendMessage(String addressList, String subject, String text) throws MessagingException {
    if (EA.isMailingEnabled()) {
    } else {//from  w  w w.jav  a2 s. com
        return null;
    }
    if (StringUtils.isBlank(addressList)) {
        throw new InvalidParameterException("addressList");
    }
    if (StringUtils.isBlank(subject)) {
        throw new InvalidParameterException("subject");
    }
    if (StringUtils.isBlank(text)) {
        throw new InvalidParameterException("text");
    }
    Address[] internetAddressList = InternetAddress.parse(addressList, false);
    Date timeStamp = new Date();
    Message message = new MimeMessage(session);
    message.setFrom();
    message.setHeader("X-Mailer", "JavaMail");
    message.setRecipients(Message.RecipientType.TO, internetAddressList);
    message.setSentDate(timeStamp);
    message.setSubject(subject);
    message.setText(text);
    Transport.send(message);
    return message;
}

From source file:cn.vlabs.clb.server.ui.frameservice.pdf.PdfConvertAdapter.java

public void parseConfig(String cfp, Properties props) {
    File cff = new File(cfp);
    if (!cff.exists() || !cff.isFile() || !cff.canRead()) {
        throw (new InvalidParameterException("Configuration file unreadable."));
    }//from   w w  w .  j  a  v  a2s  .  c o  m
    BufferedReader cfr = null;
    try {
        cfr = new BufferedReader(new FileReader(cff));
        String line;
        while ((line = cfr.readLine()) != null) {
            processLine(line, props);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(cfr);
    }
}

From source file:org.easyxml.xml.Attribute.java

/**
 * Set the value of this attribute.//from  w  w w . j a  v  a 2s  .c om
 * 
 * @param value
 *            - New value to be set.
 */
public void setValue(String value) {
    if (value == null) {
        throw new InvalidParameterException("Value of an attribute cannot be null!");
    }
    this.value = StringEscapeUtils.escapeXml10(StringUtils.trim(value));
}

From source file:ar.com.zauber.commons.web.transformation.processors.dao.impl.ChainedDocumentProviderDAO.java

/** @see DocumentProviderDAO#getDocumentProvider(String) */
public final DocumentProvider getDocumentProvider(final String url) {
    for (DocumentProviderDAO dao : daos) {
        if (dao.accept(url)) {
            return dao.getDocumentProvider(url);
        }//from   w w w  .j  a  va  2 s.c om
    }
    if (defaultDocumentProviderDAO.accept(url)) {
        return defaultDocumentProviderDAO.getDocumentProvider(url);
    }
    throw new InvalidParameterException("no document provider for: " + url);
}

From source file:com.genericworkflownodes.knime.nodegeneration.model.meta.FeatureMeta.java

/**
 * Constructs the feature meta information given the node source directory.
 * //from w  w w . ja  va 2 s .  c om
 * @param sourceDirectory
 */
public FeatureMeta(NodesSourceDirectory sourceDirectory, GeneratedPluginMeta pluginMeta) {
    super(pluginMeta.getId(), pluginMeta.getGeneratedPluginVersion());
    try {
        name = pluginMeta.getName();

        description = FileUtils.readFileToString(sourceDirectory.getDescriptionFile());
        copyright = FileUtils.readFileToString(sourceDirectory.getCopyrightFile());
        license = FileUtils.readFileToString(sourceDirectory.getLicenseFile());
    } catch (IOException e) {
        throw new InvalidParameterException("Could not read meta information.\n" + e.getMessage());
    }
}

From source file:org.transdroid.core.gui.navigation.SetTransferRatesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (onRatesPickedListener == null)
        throw new InvalidParameterException(
                "Please first set the callback listener using setOnRatesPickedListener before opening the dialog.");
    final View transferRatesContent = getActivity().getLayoutInflater().inflate(R.layout.dialog_transferrates,
            null, false);/*from   w w  w  . ja va2s. c o m*/
    maxSpeedDown = (TextView) transferRatesContent.findViewById(R.id.maxspeeddown_text);
    maxSpeedUp = (TextView) transferRatesContent.findViewById(R.id.maxspeedup_text);
    bindButtons(transferRatesContent, maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button,
            R.id.down4Button, R.id.down5Button, R.id.down6Button, R.id.down7Button, R.id.down8Button,
            R.id.down9Button, R.id.down0Button);
    bindButtons(transferRatesContent, maxSpeedUp, R.id.up1Button, R.id.up2Button, R.id.up3Button,
            R.id.up4Button, R.id.up5Button, R.id.up6Button, R.id.up7Button, R.id.up8Button, R.id.up9Button,
            R.id.up0Button);
    ((Button) transferRatesContent.findViewById(R.id.ok_button)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            int maxDown = -1, maxUp = -1;
            try {
                maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
                maxUp = Integer.parseInt(maxSpeedUp.getText().toString());
            } catch (NumberFormatException e) {
            }
            if (maxDown <= 0 || maxUp <= 0) {
                onRatesPickedListener.onInvalidNumber();
            }
            onRatesPickedListener.onRatesPicked(maxDown, maxUp);
            dismiss();
        }
    });
    ((Button) transferRatesContent.findViewById(R.id.reset_button)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onRatesPickedListener.resetRates();
            dismiss();
        }
    });
    ((Button) transferRatesContent.findViewById(R.id.cancel_button)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    Dialog dialog = new Dialog(getActivity());
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(transferRatesContent);
    return dialog;
}

From source file:com.smash.revolance.ui.comparator.page.PageComparator.java

@Override
public PageComparison compare(PageBean page, PageBean reference) {
    if (reference == null) {
        throw new InvalidParameterException("Null page reference passed in for comparison.");
    }//from  www.j av  a 2s.c  om

    if (page == null) {
        throw new InvalidParameterException("Null page passed in for comparison.");
    }

    PageComparison comparison = new PageComparison(reference);
    comparison.setMatch(page);

    if (page == null) {
        comparison.setDiffType(DiffType.DELETED);
    } else if (reference == null) {
        comparison.setDiffType(DiffType.ADDED);
    } else {
        if (!urlEquals(reference, page)) {
            comparison.addPageDifferency(PageDiffType.URL);
        }

        if (!layoutEquals(reference, page)) {
            comparison.addPageDifferency(PageDiffType.LAYOUT);
        }

        if (!contentEquals(reference, page)) {
            comparison.addPageDifferency(PageDiffType.CONTENT);
        }

        if (!lookEquals(reference, page)) {
            comparison.addPageDifferency(PageDiffType.LOOK);
        }

        if (!titleEquals(reference, page)) {
            comparison.addPageDifferency(PageDiffType.TITLE);
        }

        if (comparison.getPageDifferencies().isEmpty()) {
            comparison.setDiffType(DiffType.BASE);
        } else {
            comparison.setDiffType(DiffType.CHANGED);
        }

        Collection<ElementComparison> comparisons = contentComparator.compare(reference.getContent(),
                page.getContent());
        for (ElementComparison elementComparison : comparisons) {
            comparison.addElementComparison(elementComparison);
        }

    }

    return comparison;
}