Ignore:
Timestamp:
04/25/11 09:43:20 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #1739 - Login com certificado em atributo customizável.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/security/ExpressoCert/src/br/gov/serpro/cert/DigitalCertificate.java

    r3633 r4123  
    5858import java.io.OutputStreamWriter; 
    5959import java.security.AlgorithmParameters; 
     60import java.security.cert.CertificateEncodingException; 
    6061import java.util.regex.Matcher; 
    6162import java.util.regex.Pattern; 
     
    8990    private FileInputStream pkcs12Input; // stream da KeyStore pkcs12. Pode ser nulo. 
    9091    private String providerName; // Nome do SecurityProvider pkcs11 carregado. Pode ser nulo. 
    91     private String hostAddress; // Endereço do host, onde a página principal do 
     92    private URL pageAddress; // Endereço do host, onde a página principal do 
    9293    private static final String HOME_SUBDIR; // Subdiretório dentro do diretório home do usuário. Dependente de SO. 
    9394    private static final String EPASS_2000; // Caminho da biblioteca do token ePass2000. Dependente de SO. 
     
    164165     */ 
    165166    public DigitalCertificate() { 
    166         this.hostAddress = null; 
     167        this.pageAddress = null; 
    167168        this.parentFrame = null; 
    168169    } 
     
    173174     */ 
    174175    private DigitalCertificate(URL pageAddress) { 
    175         this.hostAddress = pageAddress.getHost(); 
     176        this.pageAddress = pageAddress; 
    176177        this.parentFrame = null; 
    177178    } 
    178179 
    179180    private DigitalCertificate(Frame parent) { 
    180         this.hostAddress = null; 
     181        this.pageAddress = null; 
    181182        this.parentFrame = parent; 
    182183    } 
     
    236237        this.selectedCertificateAlias = null; 
    237238        this.keyStore = null; 
    238         this.hostAddress = null; 
    239239        this.pkcs12Input = null; 
    240240        this.providerName = null; 
     
    647647     * Pega as credenciais de login do dono do certificado do serviço de verificação de certificados 
    648648     * @param   pin                     pin para acessar o token 
     649     * @param   where                   URL que será acessada para recuperar as credenciais 
    649650     * @return  resposta        Array de Strings em que: 
    650651     *                                          Indice 0: código de retorno; 
     
    656657     * @throws GeneralSecurityException 
    657658     */ 
    658     public String[] getCredentials(String pin) throws SSLHandshakeException, HttpException, IOException, GeneralSecurityException { 
     659 
     660    public String[] getCredentials(String pin, URL where) throws SSLHandshakeException, HttpException, IOException, GeneralSecurityException { 
    659661 
    660662        String[] resposta = null; 
     
    679681                    Integer.parseInt(System.getProperty("http.proxyPort"))); 
    680682        } 
    681         PostMethod httppost = new PostMethod("https://" + hostAddress + "/security/vercert.php"); 
    682  
     683 
     684        PostMethod httppost = new PostMethod(where.toExternalForm()); 
     685         
    683686        try { 
    684687            // Adiciona parâmetro certificado no método post, executa o método, pega a resposta do servidor 
     
    800803 
    801804    /** 
     805     * Get a PEM encoded instance of the user certificate 
     806     * @return PEM encoded Certificate 
     807     * @throws CertificateEncodingException 
     808     */ 
     809    public String getPEMCertificate() throws CertificateEncodingException { 
     810        return Base64Utils.der2pem(this.cert.getEncoded()); 
     811    } 
     812 
     813    /** 
    802814     * @param cert the cert to set 
    803815     */ 
Note: See TracChangeset for help on using the changeset viewer.