Richard Dennis

Greenhorn
+ Follow
since Nov 05, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Dennis

i have uploaded fies to a server, and what i want to do is now some how display these on the xhtml page, but i only want to display the pdf files

currently i have


<p:media value="/resources/pdf/F86.pdf" width="125%" height="100%">

but obviously this will only display the file in the value section, but what i want to try and do is create a way where it go into the directory and select a pdf file in that folder, how would i do this, what are the features i need to research in order to complete this task, i am new so sorry if this is a simple question
11 years ago
JSF

Tim Holloway wrote:Where is the printer located? Attached to the client machine, or on the server?

On the client side, you can return the page wrapped in HTML with a javascript "print" button on it. On the server side, it may be a bit more complex.

Note that in either case, it won't be completely automatic because the components in question are designed to resist security exploits made in print requests. Yes, there are such things. Plus, if all else fails and an app just wants to be petty, mean, and nasty, it could emit thousands of pages of garbage text to the printer, so the protection mechanisms do things like ensure that such things aren't run in the middle of the night when nobody's there to stop them.




On the server side, it is a networked printer, i have the ip etc so was just hopping i would be able to send directly to it, and yes i understand it willn't be completly automatic, it don't need to be tbh
11 years ago
JSF
i have now managed to create an upload in jsf that allows the user to upload a txt file, i can also display what has been uploaded, what i need to know now is how can i print this text to a printer when a user presses a command button
11 years ago
JSF
Got it didnt add the needed libraries
11 years ago
JSF
i am having issues using the primefaces file upload, i have it set up, very much the same as the example version but it does not work, i never get the successful message and also where does it store the file once uploaded ?


heres my code so far :


web.xml








What have i missed out ?

Thanks
11 years ago
JSF
Hey guys i have created a php code that authenticates users via our LDAP server but i now instead of using PHP have to do this through glassfish

here is the working php code :

<?php

$authenticated = false;

# If that wasn't the case, then validate the username and password and set the session up.
if(!$authenticated && $_SERVER['PHP_AUTH_USER'] && $_SERVER['PHP_AUTH_PW']){
$ldap = ldap_connect("ldap://uni.ds.port.ac.uk") or die("Connection to AD failed.");

# This could be username@uni.ds.port.ac.uk instead but then anyone in AD could authenticate.
$username = "CN=".$_SERVER['PHP_AUTH_USER'].",OU=Students,OU=Users,OU=UNI,DC=uni,DC=ds,DC=port,DC=ac,DC=uk";

# Check you can bind with these credentials.
if($bind = ldap_bind($ldap, $username, $_SERVER['PHP_AUTH_PW'])) {
$result = ldap_search($ldap, "OU=Non Admin,OU=Staff,OU=Users,OU=UNI,DC=uni,DC=ds,DC=port,DC=ac,DC=uk", "CN=".$_SERVER['PHP_AUTH_USER']);
if($result){
$authenticated = 1;
}
}
}

# If they aren't already authenticated by now, ask the browser to authenticate them.
if(!$authenticated){
header('WWW-Authenticate: Basic realm="Active Directory Login"');
header('HTTP/1.0 401 Unauthorized');

# This will be output if they press 'cancel' on the prompt.
echo 'You have failed to authenticate. Please login with a valid Active Directory username and password. ('.ldap_error($ldap).')';
exit;
}

?>

Now i have to set up the glassfish sever, i am using netbeans to create a webapp that needs ldap authentication i have used, it is glassfish 3.1.2 btw, below is my code and set up i have used, but i can not get it to authenticate, what am i doing wrong ?

login.xhtml
<h:body>
<form method="post" action="j_security_check">
<p>You need to log in to access protected information.</p>
<table>
<tr>
<td>User name:</td>
<td><input type="text" name="j_username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="j_password" /></td>
</tr>
</table>
<p><input type="submit" value="Login" /></p>
</form>
</h:body>
loginError.xhtml
<h:body>
<p>Sorry--authentication failed. Please try again.</p>
</h:body>
secure/securePage.xhtml
<h:body>
This is a secure page
</h:body>

To create the actual Realm In Glassfish open the admin console (http://localhost:4848 in my dev environment). Select Configurations->server-config->Security->Realms click on new and start putting in the information. Type in a "Realm Name" whatever you want it to be called our case is MYREALM. The JAAS Context must be: ldapRealm the Directory is the ldap host ldap://hostname:389 and the Base DN is simply the DN that holds the users.

In my case it was ou=Company Users,dc=Company,dc=corp.

I left the "Assign Groups" empty.

The Additional properties section has these applicable properties (http://download.oracle.com/docs/cd/E19830-01/819-4712/ablpe/index.html):

search-filter="(sAMAccountName=%s)"
group-base-dn="cn=Application Users,ou=Company Groups,dc=Company,dc=corp"
search-bind-password="password"
group-search-filter="(member=%d)"
search-bind-dn="ldapuser"

Note that I have quotes on these properties. I noticed that I had to put the properties in quotes into the console form in order for it to work. I had to delete and recreate the realm whenever I wanted to make a change because whenever I clicked on "save" the form would append extra quotes to the Properties specific to this Class section.

Once the realm is created you can add the following to your web.xml file in order to use it:

<security-constraint>
<display-name>Application Users</display-name>
<web-resource-collection>
<web-resource-name>SecurePages</web-resource-name>
<description/>
<url-pattern>/faces/secure/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Application Users desc</description>
<role-name>Application Users</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>MYREALM</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description/>
<role-name>Application Users</role-name>
</security-role>
11 years ago
JSF
Thank you for your reply i will look into it now , and yes i don't need to display the document before printing just need to send it to a printer:)
11 years ago
Hey guys im doing a project using JSF to create a web app that allows a user to upload a file such as a pdf or word document and then send it to a printer

im really stuck now on how to send the file i have upload via primfaces with ajax, but how do i send this to a printer ?, actuall it has to be sent to a printer holding queue as the job will be manually released but how do i go about this ? anyone got some sample code to start me off ? i have downloaded the CUPS4J library but don't know where to start as im new to java


Thanks guys !
11 years ago