Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SHA1 digest error  RSS feed

 
upendra rathore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Tomacat 5.0.28 on JVM 1.5.0_06-b05. If I run
the main method of EmailApp its works fine.
But if import this class in sendmail.jsp its shows me an error : SHA1 digest error for javax/mail/Authenticator.class

Please help me,

=============
EmailApi.java
==============
package com.sso;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
public class EmailApp extends SMTPAuthenticator {
public static void main(String args[]) throws Exception {
String[] emailList = {"user@gmail.com"};
String cMailText="" ;
cMailText=cMailText + "<table width=465 height=535 border=3 cellpadding=1 cellspacing=1 bgcolor=#0066CC><tr><td>;";
cMailText=cMailText + "<table width=465 height=535 border=3 cellpadding=1 cellspacing=1 bordercolor=#0033FF bgcolor=#0066CC>";
cMailText=cMailText + "<tr><td>";
cMailText=cMailText + "<table width=462 height=530 border=0 cellpadding=3 cellspacing=4 bordercolor=#006600 bgcolor=#84C125><tr>";
cMailText=cMailText + "<td width=456 bgcolor=#FFFFFF><div align=center><img src=http://server.domain.com/downloads/logo.gif alt=domain.com width=228 height=96 longdesc=http://domain.com />";
cMailText=cMailText + "</div></td>";
cMailText=cMailText + "</tr>";
cMailText=cMailText + "<tr>";
cMailText=cMailText + "<td><p align=justify style=font-size:x-small;color:#000066;font:'Arial'> Dear Valued Customer,</p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:'Arial'>Welcome to <strong>www.domain.com</strong>.</p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:'Arial'>Your new password is (<strong>XIRJNGTRYE</strong> </p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:'Arial'>Please change your password on first login. This is for your security purpose.</p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:Arial>If your mobile number (0) is changed or not updated with us, please contact our nearest branch with a <a href=downloads/form.pdf>prescribed form</a> to update your mobile number, so in future if you forget your password, you can just reset your password using your mobile. </p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:Arial>To reset your password using your mobile just create a new message i.e. <strong>MASTER PASSWORD <your trading code></strong> and send it to <strong>56767</strong>, with-in seconds you will get your new password.</p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#0066CC;font:Arial> "<strong> As Always, striving to serve you better " </strong> </p>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#000066;font:Arial><span ><a href=mailto:backoffice@domain.com>backoffice@domain.com</a></span></p></td>";
cMailText=cMailText + "</tr></table>";
cMailText=cMailText + "<p align=justify style=font-size:x-small;color:#FFCC00;font:'Courier New', Courier, monospace>";
cMailText=cMailText + " "This e-mail is confidential and may also be privileged. If you are not the intended recipient, please notify us immediately; you should not copy or use it for any purpose, nor disclose its contents to any other person " </p>";
cMailText=cMailText + "</td></tr></table>";
EmailApp smtpMailSender = new EmailApp();
smtpMailSender.postMail( emailList, "usr-subject", cMailText, "user@domain.com" );

System.out.println("Sucessfully Sent mail to All Users");
}


public void postMail( String recipients[ ], String subject,
String message , String from) throws MessagingException {
boolean debug = true;
Properties props = new Properties();
props.put("mail.smtp.host", "mail.domain.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "45");

Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props,auth);
session.setDebug(debug);

// create a message
Message msg = new MimeMessage(session);

// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]); }
msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/html");
Transport.send(msg);
}
}
=======================
SMTPAuthenticator.java
=======================

package com.sso;
import javax.mail.PasswordAuthentication;

public class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = "user@domain.com";
String password = "password";
try {
return new PasswordAuthentication(username, password);
} catch (Exception e) {
return null;}
}

}
===============
[ July 22, 2008: Message edited by: David O'Meara ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Login and specific domain details removed
 
upendra rathore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
Login and specific domain details removed


You mean I should set
String username="user@domain.com" ;
String password="password";

not my actual userid and password...

in my SMTPAuthenticator class ?
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi upendra rathore welcome to Javaranch,
Firstly UseCodeTags.
Your code is too unreadable.
No Dave means that use generic terms instead of your real login as it will be exposed to all.

And take some time to read the Ask Good Questions link in my signature below.
[ July 22, 2008: Message edited by: Amit Ghorpade ]
 
upendra rathore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to all, as I am first time posting my error code so I don't know about all those things.

I am re-positing what acutally I am facing as an error.
 
upendra rathore
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My jsp code is showing an error pointing where I am importing the class.

<%@ page import="com.sso.EmailApp"%>

SHA1 digest error for javax/mail/Authenticator.class

I have Tomacat 5.0.28 on JVM 1.5.0_06-b05.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!