Example usage for org.bouncycastle.util Strings toUpperCase

List of usage examples for org.bouncycastle.util Strings toUpperCase

Introduction

In this page you can find the example usage for org.bouncycastle.util Strings toUpperCase.

Prototype

public static String toUpperCase(String string) 

Source Link

Document

A locale independent version of toUpperCase.

Usage

From source file:com.chortitzer.lab.semillas.utils.Utils.java

public static String getMesUpperCase(Integer mes) {
    return Strings.toUpperCase(getMes(mes));
}

From source file:fr.paris.lutece.plugins.appointment.web.AppointmentApp.java

License:Open Source License

/**
 * Get the page to notify the user that the appointment has been created
 * //from  ww  w. j a v  a  2s.c  om
 * @param request
 *            The request
 * @return The XPage to display
 */
@View(VIEW_GET_APPOINTMENT_CREATED)
public XPage getAppointmentCreated(HttpServletRequest request) {
    int nIdForm = Integer.parseInt(request.getParameter(PARAMETER_ID_FORM));
    int nIdAppointment = Integer.parseInt(request.getParameter(PARAMETER_ID_APPOINTMENT));
    AppLogService.debug("n Id Appointment :" + nIdAppointment);
    Appointment appointment = AppointmentService.findAppointmentById(nIdAppointment);
    FormMessage formMessages = FormMessageService.findFormMessageByIdForm(nIdForm);
    Slot slot = SlotService.findSlotById(appointment.getIdSlot());
    AppointmentFormDTO form = FormService.buildAppointmentForm(nIdForm, 0, 0);
    String strTimeBegin = slot.getStartingDateTime().toLocalTime().toString();
    String strTimeEnd = slot.getEndingDateTime().toLocalTime().toString();
    String strReference = StringUtils.EMPTY;
    if (!StringUtils.isEmpty(form.getReference())) {
        strReference = Strings.toUpperCase(form.getReference().trim()) + " - ";
    }
    strReference += appointment.getReference();
    formMessages.setTextAppointmentCreated(
            formMessages.getTextAppointmentCreated().replaceAll(MARK_REF, strReference)
                    .replaceAll(MARK_DATE_APP,
                            slot.getStartingDateTime().toLocalDate().format(Utilities.getFormatter()))
                    .replaceAll(MARK_TIME_BEGIN, strTimeBegin).replaceAll(MARK_TIME_END, strTimeEnd));
    Map<String, Object> model = new HashMap<String, Object>();
    AppointmentDTO appointmentDTO = AppointmentService.buildAppointmentDTOFromIdAppointment(nIdAppointment);
    appointmentDTO
            .setListResponse(AppointmentResponseService.findAndBuildListResponse(nIdAppointment, request));
    appointmentDTO.setMapResponsesByIdEntry(
            AppointmentResponseService.buildMapFromListResponse(appointmentDTO.getListResponse()));
    model.put(MARK_LIST_RESPONSE_RECAP_DTO,
            AppointmentUtilities.buildListResponse(appointmentDTO, request, getLocale(request)));
    model.put(MARK_DATE_APPOINTMENT, slot.getDate().format(Utilities.getFormatter()));
    model.put(MARK_STARTING_TIME_APPOINTMENT, slot.getStartingTime());
    model.put(MARK_ENDING_TIME_APPOINTMENT, slot.getEndingTime());
    model.put(MARK_USER, UserService.findUserById(appointment.getIdUser()));
    model.put(MARK_PLACES, appointment.getNbPlaces());
    model.put(MARK_FORM, form);
    model.put(MARK_FORM_MESSAGES, formMessages);
    return getXPage(TEMPLATE_APPOINTMENT_CREATED, getLocale(request), model);
}

From source file:org.jruby.ext.openssl.impl.pem.MiscPEMGenerator.java

License:Open Source License

private PemObject createPemObject(Object o) throws IOException {
    String type;//  ww  w .j  a va 2s . c  om
    byte[] encoding;

    if (o instanceof PemObject) {
        return (PemObject) o;
    }
    if (o instanceof PemObjectGenerator) {
        return ((PemObjectGenerator) o).generate();
    }
    if (o instanceof X509CertificateHolder) {
        type = "CERTIFICATE";
        encoding = ((X509CertificateHolder) o).getEncoded();
    } else if (o instanceof X509CRLHolder) {
        type = "X509 CRL";
        encoding = ((X509CRLHolder) o).getEncoded();
    } else if (o instanceof PrivateKeyInfo) {
        PrivateKeyInfo info = (PrivateKeyInfo) o;
        ASN1ObjectIdentifier algOID = info.getPrivateKeyAlgorithm().getAlgorithm();

        if (algOID.equals(PKCSObjectIdentifiers.rsaEncryption)) {
            type = "RSA PRIVATE KEY";
            encoding = info.parsePrivateKey().toASN1Primitive().getEncoded();
        } else if (algOID.equals(dsaOids[0]) || algOID.equals(dsaOids[1])) {
            type = "DSA PRIVATE KEY";

            DSAParameter p = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
            ASN1EncodableVector v = new ASN1EncodableVector();

            v.add(new ASN1Integer(BigInteger.ZERO));
            v.add(new ASN1Integer(p.getP()));
            v.add(new ASN1Integer(p.getQ()));
            v.add(new ASN1Integer(p.getG()));

            BigInteger x = ASN1Integer.getInstance(info.parsePrivateKey()).getValue();
            BigInteger y = p.getG().modPow(x, p.getP());

            v.add(new ASN1Integer(y));
            v.add(new ASN1Integer(x));

            encoding = new DERSequence(v).getEncoded();
        } else if (algOID.equals(X9ObjectIdentifiers.id_ecPublicKey)) {
            type = "EC PRIVATE KEY";
            encoding = info.parsePrivateKey().toASN1Primitive().getEncoded();
        } else {
            throw new IOException("Cannot identify private key");
        }
    } else if (o instanceof SubjectPublicKeyInfo) {
        type = "PUBLIC KEY";
        encoding = ((SubjectPublicKeyInfo) o).getEncoded();
    } else if (o instanceof X509AttributeCertificateHolder) {
        type = "ATTRIBUTE CERTIFICATE";
        encoding = ((X509AttributeCertificateHolder) o).getEncoded();
    } else if (o instanceof PKCS10CertificationRequest) {
        type = "CERTIFICATE REQUEST";
        encoding = ((PKCS10CertificationRequest) o).getEncoded();
    } else if (o instanceof ContentInfo) {
        type = "PKCS7";
        encoding = ((ContentInfo) o).getEncoded();
    }
    //
    // NOTE: added behaviour to provide backwards compatibility with 1.47 :
    //
    else if (o instanceof java.security.cert.X509Certificate) // 1.47 compatibility
    {
        type = "CERTIFICATE";
        try {
            encoding = ((java.security.cert.X509Certificate) o).getEncoded();
        } catch (CertificateEncodingException e) {
            throw new PemGenerationException("Cannot encode object: " + e.toString());
        }
    } else if (o instanceof java.security.cert.X509CRL) // 1.47 compatibility
    {
        type = "X509 CRL";
        try {
            encoding = ((java.security.cert.X509CRL) o).getEncoded();
        } catch (CRLException e) {
            throw new PemGenerationException("Cannot encode object: " + e.toString());
        }
    } else if (o instanceof java.security.KeyPair) // 1.47 compatibility
    {
        return createPemObject(((java.security.KeyPair) o).getPrivate());
    } else if (o instanceof java.security.PrivateKey) // 1.47 compatibility
    {
        PrivateKeyInfo info = new PrivateKeyInfo(
                (ASN1Sequence) ASN1Primitive.fromByteArray(((java.security.Key) o).getEncoded()));

        if (o instanceof java.security.interfaces.RSAPrivateKey) {
            type = "RSA PRIVATE KEY";

            encoding = info.parsePrivateKey().toASN1Primitive().getEncoded();
        } else if (o instanceof java.security.interfaces.DSAPrivateKey) {
            type = "DSA PRIVATE KEY";

            DSAParameter p = DSAParameter.getInstance(info.getPrivateKeyAlgorithm().getParameters());
            ASN1EncodableVector v = new ASN1EncodableVector();

            v.add(new DERInteger(0));
            v.add(new DERInteger(p.getP()));
            v.add(new DERInteger(p.getQ()));
            v.add(new DERInteger(p.getG()));

            BigInteger x = ((java.security.interfaces.DSAPrivateKey) o).getX();
            BigInteger y = p.getG().modPow(x, p.getP());

            v.add(new DERInteger(y));
            v.add(new DERInteger(x));

            encoding = new DERSequence(v).getEncoded();
        } else if (((java.security.PrivateKey) o).getAlgorithm().equals("ECDSA")) {
            type = "EC PRIVATE KEY";

            encoding = info.parsePrivateKey().toASN1Primitive().getEncoded();
        } else {
            throw new IOException("Cannot identify private key");
        }
    } else if (o instanceof java.security.PublicKey) // 1.47 compatibility
    {
        type = "PUBLIC KEY";

        encoding = ((java.security.PublicKey) o).getEncoded();
    } else if (o instanceof X509AttributeCertificate) // 1.47 compatibility
    {
        type = "ATTRIBUTE CERTIFICATE";
        encoding = ((X509AttributeCertificate) o).getEncoded();
    }
    //
    //
    //
    else {
        throw new PemGenerationException("unknown object passed - can't encode.");
    }

    if (encryptor != null) // NEW STUFF (NOT IN OLD)
    {
        String dekAlgName = Strings.toUpperCase(encryptor.getAlgorithm());

        // Note: For backward compatibility
        if (dekAlgName.equals("DESEDE")) {
            dekAlgName = "DES-EDE3-CBC";
        }

        byte[] iv = encryptor.getIV();
        byte[] encData = encryptor.encrypt(encoding);

        List<PemHeader> headers = new ArrayList<PemHeader>(2);

        headers.add(new PemHeader("Proc-Type", "4,ENCRYPTED"));
        headers.add(new PemHeader("DEK-Info", dekAlgName + "," + getHexEncoded(iv)));

        return new PemObject(type, headers, encData);
    }
    return new PemObject(type, encoding);
}