com.ibm.as400.access.PermissionAccessDLO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
The newest version!
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: PermissionAccessDLO.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2004 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.access;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;
/**
* the PermissionAccessDLO class is provided to retrieve the
* user's permission information.
*
**/
class PermissionAccessDLO extends PermissionAccess
{
/**
* Constructs a PermissionAccessDLO object.
* @param system
*
**/
public PermissionAccessDLO(AS400 system)
{
super(system);
}
/**
* Adds the authorized user or user permission.
* @param objName The object the authorized user will be added to.
* @param permission The permission of the new authorized user.
* @exception AS400Exception If the server returns an error message.
* @exception AS400SecurityException If a security or authority error occurs.
* @exception ConnectionDroppedException If the connection is dropped unexpectedly.
* @exception ErrorCompletingRequestException If an error occurs before the request is completed.
* @exception InterruptedException If this thread is interrupted.
* @exception IOException If an error occurs while communicating with the server.
* @exception PropertyVetoException If the change is vetoed.
* @exception ServerStartupException If the server cannot be started.
* @exception UnknownHostException If the server cannot be located.
*
**/
public void addUser(String objName,UserPermission permission)
throws AS400Exception,
AS400SecurityException,
ConnectionDroppedException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ServerStartupException,
UnknownHostException,
PropertyVetoException
{
objName = toUpperCasePath(objName); //@A2C: toUpperCase()
CommandCall addUser= getAddCommand(as400_,objName,permission);
if (addUser.run()!=true)
{
AS400Message[] msgList = addUser.getMessageList();
throw new AS400Exception(msgList);
}
return;
}
// @B3a - New Method.
/**
* Prepares the object name for parsing by the IBM i Command Analyzer.
* @param objName The name of an object.
* @return A version of the name that is parsable by the Command Analyzer.
*
**/
protected final String expandQuotes(String objName)
{
return expandQuotes0(objName);
}
// @B3a - New Method.
/**
* If the name contains single-quotes, doubles up the single-quotes.
* Regardless, encloses the entire name in single-quotes.
* This prepares the name for parsing by the IBM i Command Analyzer.
* @param objName The name of an object.
* @return A version of the name that is parsable by the Command Analyzer.
*
**/
static String expandQuotes0(String objName)
{ // @B4c
StringBuffer buf = new StringBuffer(objName);
// First, if the name contains single-quotes, double-up the quotes.
if (objName.indexOf('\'') != -1) {
for (int i=objName.length()-1; i>=0; i--) {
if (buf.charAt(i) == '\'') { buf.insert(i,'\''); }
}
}
// Finally, enclose the entire name in single-quotes.
buf.insert(0,'\'');
buf.append('\'');
return buf.toString();
}
/**
* Returns the command to add a authorized user.
* @param objName The object the authorized user will be added to.
* @param permission The permission of the new authorized user.
* @return The command to add authorized user.
*
**/
private static CommandCall getAddCommand(AS400 sys, String objName,UserPermission permission)
{
DLOPermission dloPermission = (DLOPermission)permission;
String userProfile=dloPermission.getUserID();
String authorityLevel=dloPermission.getDataAuthority();
try
{
objName = CharConverter.convertIFSQSYSPathnameToJobPathname(objName, sys.getCcsid());
}
catch(Exception e)
{
Trace.log(Trace.WARNING, "Unable to convert QDLS pathname to correct job CCSID.", e);
}
int index1 = objName.indexOf('/',1);
int index2=objName.lastIndexOf('/');
String name=objName.substring(index2+1);
String folder;
if (index1+1
* *NONE - The object has no sensitivity restrictions.
* *PERSONAL - The object contains information intended for the user as an individual.
* *PRIVATE - The object contains information that should be accessed only by the owner.
* *CONFIDENTIAL - The object contains information that should be handled according to company procedures.
*
* @exception AS400Exception If the server returns an error message.
* @exception AS400SecurityException If a security or authority error occurs.
* @exception ConnectionDroppedException If the connection is dropped unexpectedly.
* @exception ErrorCompletingRequestException If an error occurs before the request is completed.
* @exception InterruptedException If this thread is interrupted.
* @exception IOException If an error occurs while communicating with the server.
* @exception PropertyVetoException If the change is vetoed.
* @exception ServerStartupException If the server cannot be started.
* @exception UnknownHostException If the server cannot be located.
**/
public synchronized void setSensitivity(String objName,int sensitivityLevel)
throws AS400Exception,
AS400SecurityException,
ConnectionDroppedException,
ErrorCompletingRequestException,
InterruptedException,
IOException,
ServerStartupException,
UnknownHostException,
PropertyVetoException
{
objName = toUpperCasePath(objName); //@A2A
try
{
objName = CharConverter.convertIFSQSYSPathnameToJobPathname(objName, as400_.getCcsid());
}
catch(Exception e)
{
Trace.log(Trace.WARNING, "Unable to convert QDLS pathname to correct job CCSID.", e);
}
String name,folder;
int index1 = objName.indexOf('/',1);
int index2=objName.lastIndexOf('/');
name=objName.substring(index2+1);
if (index1+1
© 2015 - 2025 Weber Informatics LLC | Privacy Policy