/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Valid
* Check user input. We are mostly concerned with characters
* we know will cause problems for the sub-system.
* multi-byte characters will be screened out by the gui.
*/
public class Valid {
/* JSTYLED */
/* JSTYLED */
// lpadmin used to only take 14.
// MAXHOSTNAMELEN + MAXPATHLEN seems reasonable.
// it's not enforced ...
//
// main for testing
//
try {
}
catch (Exception e)
{
}
}
//
// Valid comment
//
{
return (false);
return (false);
// Causes problems in lpadmin
if (c.equals(",")) {
return (false);
}
if (c.equals("-")) {
return (false);
}
}
//
// Valid local printer name
//
{
return (false);
return (false);
return (false);
if (c.equals(".")) {
return (false);
}
if (c.equals("!")) {
return (false);
}
if (c.equals("=")) {
return (false);
}
// Keywords for the sub-system
return (false);
return (false);
}
//
// Valid remote printer name
//
{
return (false);
return (false);
return (false);
// Keywords for the sub-system
return (false);
return (false);
if (c.equals(".")) {
return (false);
}
if (c.equals("!")) {
return (false);
}
if (c.equals("=")) {
return (false);
}
}
//
// Valid device
// Does it exist and is it writable.
//
throws Exception
{
int exitvalue;
return (false);
return (false);
return (true);
if (exitvalue != 0)
return (false);
return (true);
}
//
// Valid Printer Make
// Does a directory of that name exist, and is it readable.
//
throws Exception
{
int exitvalue;
return (false);
return (false);
if (exitvalue != 0)
return (false);
return (true);
}
//
// Valid printer type
//
throws Exception
{
int exitvalue;
return (false);
return (false);
return (false);
return (false);
}
return (false);
}
if (exitvalue != 0)
return (false);
return (true);
}
//
// Valid destination
//
{
if (d == null)
return (false);
if (d.length() == 0)
return (false);
if (d.length() > validdestinationlength)
return (false);
}
//
// Valid Server name
//
{
if (s == null)
return (false);
if (s.length() == 0)
return (false);
if (s.length() > validservernamelength)
return (false);
if (c.equals("!")) {
return (false);
}
if (c.equals("=")) {
return (false);
}
}
//
// Users
//
{
if (u == null) {
return (false);
}
if (u.length == 0) {
return (false);
}
for (int i = 0; i < u.length; i++) {
if (u[i] == null) {
return (false);
}
if (u[i].length() == 0) {
return (false);
}
if (u[i].length() > validusernamelength) {
return (false);
}
return (false);
}
}
return (true);
}
//
// User
//
{
if (u == null) {
return (false);
}
if (u.length() == 0) {
return (false);
}
if (u == null) {
return (false);
}
if (u.length() == 0) {
return (false);
}
if (u.length() > validusernamelength) {
return (false);
}
return (false);
}
return (true);
}
//
// Check to see if a string contains an invalid character
//
{
// Can't start with a hyphen
return (false);
return (false);
}
}
return (true);
}
}