[JBoss Seam] - Re: Seam mail - How to use the default
by rmemoria
Actually the code above check if the mailFrom argument is null.
If it's null it recovers from the mail-service.xml
public class SendMail {
|
| public static Session newMailSession() {
| try {
| Object ctx = new InitialContext().lookup("java:/Mail");
|
| return (Session)PortableRemoteObject.narrow(ctx, Session.class);
| } catch (javax.naming.NamingException e) {
| e.printStackTrace();
| return null;
| }
| }
|
| public static void sendMessage(String mailFrom, String mailTo, String subject, String msg, boolean htmlText)
| {
| try
| {
| Session session = newMailSession();
| Message message = new MimeMessage(session);
|
| if (mailFrom == null)
| mailFrom = session.getProperty("mail.from"); message.setFrom( new InternetAddress(mailFrom));
|
| InternetAddress to[] = new InternetAddress[1];
| to[0] = new InternetAddress(mailTo);
| message.setRecipients(Message.RecipientType.TO, to);
| message.setSubject(subject);
| message.setSentDate(new Date());
|
| String textType;
| if (htmlText)
| textType = "text/html";
| else textType = "text/plain";
| message.setContent(msg, textType);
|
| Transport trans = session.getTransport("smtp");
|
| trans.connect(session.getProperty("mail.smtp.host"),
| session.getProperty("mail.smtp.user"),
| session.getProperty("mail.smtp.password"));
| trans.sendMessage(message, message.getAllRecipients());
| trans.close();
| }
| catch (Exception e)
| {
| e.printStackTrace();
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4010639#4010639
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4010639
19Â years, 2Â months
[JBoss Seam] - Re: Help about permissions with seam-security
by gaboo
I can get permission to works with inline restrictions like this :
in xtml page :
<h:outputText value="TEST permission (test/bwa)"
| rendered="#{s:hasPermission('test','bwa', null)}"/>
| <br/>
| <h:outputText value="TEST permission (test/toto)"
| rendered="#{s:hasPermission('test','toto', null)}"/>
| <br/>
| <h:outputText value="TEST role admin"
| rendered="#{s:hasRole('admin')}"/>
|
rules :
| rule TestBwaRule
| when
| c: PermissionCheck(name == "test", action == "bwa")
| Role(name == "admin")
| then
| c.grant();
| end;
|
|
| rule TestBwaRule1
| when
| c: PermissionCheck(name == "test", action == "toto")
| then
| c.grant();
| end;
But no way with page level restriction in pages.xml.
Not sure what is wrong. Would be good to add such an example in seamspace ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4010636#4010636
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4010636
19Â years, 2Â months
[JBoss Seam] - Help about permissions with seam-security
by gaboo
Hello !
I'm trying the latest seam with seam-security.
Using roles is pretty easy, but I haven't managed using permissions yet.
It's really hard to write rules when you're new to JBoss Rules.
How can I debug my rules ?
I know they does not work. Is there a jboss rules "verbose+debug" mode, which could help writing, underderstanding and debuging seam-security rules ?
I also added some restrictions to pages.xml.
No way either to verify it's correct as I have no feedback.
I have this in pages.xml
| <page view-id="/userList.xhtml">
| <restrict/>
| </page>
| <page view-id="/userList.*">
| <restrict/>
| </page>
And this in my rules file :
package Permissions;
|
| import java.security.Principal;
|
| import org.jboss.seam.security.PermissionCheck;
| import org.jboss.seam.security.Role;
|
| rule CanUserViewUserList
| when
| c: PermissionCheck(page : name, name == "/userList.xhtml", action == "render")
| Role(name == "admin")
| then
| System.out.println("test : " + page);
| c.grant();
| end;
And a potential bug I think : in seamspace example, if you are not logged in and try to access
http://localhost:8080/seam-space/comment.xhtml
It works but the file is downloaded (usgin firefox).
If you go to http://localhost:8080/seam-space/comment.seam : you indeed get a org.jboss.seam.security.NotLoggedInException.
Thank you !
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4010631#4010631
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4010631
19Â years, 2Â months