2006년 5월 1일 월요일

Kerberos V5 Tutorial

http://web.mit.edu/kerberos/www/krb5-1.3/krb5-1.3.1/doc/krb5-user.html

--------------------------------------------------------------------------------
Node:Top, Next:Copyright, Previous:(dir), Up:(dir)

Copyright:
Introduction:
Kerberos V5 Tutorial:
Kerberos V5 Reference:
Kerberos Glossary:


--------------------------------------------------------------------------------
Node:Copyright, Next:Introduction, Previous:Top, Up:Top

Copyright
Copyright © 1985-2002 by the Massachusetts Institute of Technology.

Export of software employing encryption from the United States of America may require a specific license from the United States Government. It is the responsibility of any person or organization contemplating export to obtain such a license before exporting.
WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Furthermore if you modify this software you must label your software as modified software and not distribute it in such a fashion that it might be confused with the original MIT software. M.I.T. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

The following copyright and permission notice applies to the OpenVision Kerberos Administration system located in kadmin/create, kadmin/dbutil, kadmin/passwd, kadmin/server, lib/kadm5, and portions of lib/rpc:

Copyright, OpenVision Technologies, Inc., 1996, All Rights Reserved
WARNING: Retrieving the OpenVision Kerberos Administration system source code, as described below, indicates your acceptance of the following terms. If you do not agree to the following terms, do not retrieve the OpenVision Kerberos administration system.

You may freely use and distribute the Source Code and Object Code compiled from it, with or without modification, but this Source Code is provided to you "AS IS" EXCLUSIVE OF ANY WARRANTY, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY OTHER WARRANTY, WHETHER EXPRESS OR IMPLIED. IN NO EVENT WILL OPENVISION HAVE ANY LIABILITY FOR ANY LOST PROFITS, LOSS OF DATA OR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, INCLUDING, WITHOUT LIMITATION, THOSE RESULTING FROM THE USE OF THE SOURCE CODE, OR THE FAILURE OF THE SOURCE CODE TO PERFORM, OR FOR ANY OTHER REASON.

OpenVision retains all copyrights in the donated Source Code. OpenVision also retains copyright to derivative works of the Source Code, whether created by OpenVision or by a third party. The OpenVision copyright notice must be preserved if derivative works are made based on the donated Source Code.

OpenVision Technologies, Inc. has donated this Kerberos Administration system to MIT for inclusion in the standard Kerberos 5 distribution. This donation underscores our commitment to continuing Kerberos technology development and our gratitude for the valuable work which has been performed by MIT and the Kerberos community.

The implementation of the Yarrow pseudo-random number generator in src/lib/crypto/yarrow has the following copyright:

Copyright 2000 by Zero-Knowledge Systems, Inc.

Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Zero-Knowledge Systems, Inc. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Zero-Knowledge Systems, Inc. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

ZERO-KNOWLEDGE SYSTEMS, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ZERO-KNOWLEDGE SYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

The implementation of the AES encryption algorithm in src/lib/crypto/aes has the following copyright:

Copyright (c) 2001, Dr Brian Gladman , Worcester, UK. All rights reserved.

LICENSE TERMS

The free distribution and use of this software in both source and binary form is allowed (with or without changes) provided that:


distributions of this source code include the above copyright notice, this list of conditions and the following disclaimer;
distributions in binary form include the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other associated materials;
the copyright holder's name is not used to endorse products built using this software without specific written permission.
DISCLAIMER

This software is provided 'as is' with no explcit or implied warranties in respect of any properties, including, but not limited to, correctness and fitness for purpose.

Kerberos V5 includes documentation and software developed at the University of California at Berkeley, which includes this copyright notice:
Copyright © 1983 Regents of the University of California.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:


Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
All advertising materials mentioning features or use of this software must display the following acknowledgement:
This product includes software developed by the University of California, Berkeley and its contributors.
Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notices and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.



--------------------------------------------------------------------------------
Node:Introduction, Next:Kerberos V5 Tutorial, Previous:Copyright, Up:Top

Introduction
Kerberos V5 is an authentication system developed at MIT. Kerberos is named for the three-headed watchdog from Greek mythology, who guarded the entrance to the underworld.

Under Kerberos, a client (generally either a user or a service) sends a request for a ticket to the Key Distribution Center (KDC). The KDC creates a ticket-granting ticket (TGT) for the client, encrypts it using the client's password as the key, and sends the encrypted TGT back to the client. The client then attempts to decrypt the TGT, using its password. If the client successfully decrypts the TGT (i.e., if the client gave the correct password), it keeps the decrypted TGT, which indicates proof of the client's identity.

The TGT, which expires at a specified time, permits the client to obtain additional tickets, which give permission for specific services. The requesting and granting of these additional tickets is user-transparent.

Since Kerberos negotiates authenticated, and optionally encrypted, communications between two points anywhere on the internet, it provides a layer of security that is not dependent on which side of a firewall either client is on. Since studies have shown that half of the computer security breaches in industry happen from inside firewalls, MIT's Kerberos V5 plays a vital role in maintaining your network security.

The Kerberos V5 package is designed to be easy to use. Most of the commands are nearly identical to UNIX network programs you already use. Kerberos V5 is a single-sign-on system, which means that you have to type your password only once per session, and Kerberos does the authenticating and encrypting transparently.

What is a Ticket?:
What is a Kerberos Principal?:


--------------------------------------------------------------------------------
Node:What is a Ticket?, Next:What is a Kerberos Principal?, Previous:Introduction, Up:Introduction

What is a Ticket?
Your Kerberos credentials, or "tickets", are a set of electronic information that can be used to verify your identity. Your Kerberos tickets may be stored in a file, or they may exist only in memory.

The first ticket you obtain is a ticket-granting ticket, which permits you to obtain additional tickets. These additional tickets give you permission for specific services. The requesting and granting of these additional tickets happens transparently.

A good analogy for the ticket-granting ticket is a three-day ski pass that is good at four different resorts. You show the pass at whichever resort you decide to go to (until it expires), and you receive a lift ticket for that resort. Once you have the lift ticket, you can ski all you want at that resort. If you go to another resort the next day, you once again show your pass, and you get an additional lift ticket for the new resort. The difference is that the Kerberos V5 programs notice that you have the weekend ski pass, and get the lift ticket for you, so you don't have to perform the transactions yourself.



--------------------------------------------------------------------------------
Node:What is a Kerberos Principal?, Previous:What is a Ticket?, Up:Introduction

What is a Kerberos Principal?
A Kerberos principal is a unique identity to which Kerberos can assign tickets. Principals can have an arbitrary number of components. Each component is separated by a component separator, generally `/'. The last component is the realm, separated from the rest of the principal by the realm separator, generally `@'. If there is no realm component in the principal, then it will be assumed that the principal is in the default realm for the context in which it is being used.

Traditionally, a principal is divided into three parts: the primary, the instance, and the realm. The format of a typical Kerberos V5 principal is primary/instance@REALM.

The primary is the first part of the principal. In the case of a user, it's the same as your username. For a host, the primary is the word host.
The instance is an optional string that qualifies the primary. The instance is separated from the primary by a slash (/). In the case of a user, the instance is usually null, but a user might also have an additional principal, with an instance called admin, which he/she uses to administrate a database. The principal jennifer@ATHENA.MIT.EDU is completely separate from the principal jennifer/admin@ATHENA.MIT.EDU, with a separate password, and separate permissions. In the case of a host, the instance is the fully qualified hostname, e.g., daffodil.mit.edu.
The realm is your Kerberos realm. In most cases, your Kerberos realm is your domain name, in upper-case letters. For example, the machine daffodil.example.com would be in the realm EXAMPLE.COM.


--------------------------------------------------------------------------------
Node:Kerberos V5 Tutorial, Next:Kerberos V5 Reference, Previous:Introduction, Up:Top

Kerberos V5 Tutorial
This tutorial is intended to familiarize you with the Kerberos V5 client programs. We will represent your prompt as "shell%". So an instruction to type the "ls" command would be represented as follows:

shell% ls

In these examples, we will use sample usernames, such as jennifer and david, sample hostnames, such as daffodil and trillium, and sample domain names, such as mit.edu and example.com. When you see one of these, substitute your username, hostname, or domain name accordingly.

Setting Up to Use Kerberos V5:
Ticket Management:
Password Management:
Kerberos V5 Applications:


--------------------------------------------------------------------------------
Node:Setting Up to Use Kerberos V5, Next:Ticket Management, Previous:Kerberos V5 Tutorial, Up:Kerberos V5 Tutorial

Setting Up to Use Kerberos V5
Your system administrator will have installed the Kerberos V5 programs in whichever directory makes the most sense for your system. We will use /usr/local throughout this guide to refer to the top-level directory Kerberos V5 directory. We will therefor use /usr/local/bin to denote the location of the Kerberos V5 user programs. In your installation, the directory name may be different, but whatever the directory name is, you should make sure it is included in your path. You will probably want to put it ahead of the directories /bin and /usr/bin so you will get the Kerberos V5 network programs, rather than the standard UNIX versions, when you type their command names.



--------------------------------------------------------------------------------
Node:Ticket Management, Next:Password Management, Previous:Setting Up to Use Kerberos V5, Up:Kerberos V5 Tutorial

Ticket Management
On many systems, Kerberos is built into the login program, and you get tickets automatically when you log in. Other programs, such as rsh, rcp, telnet, and rlogin, can forward copies of your tickets to the remote host. Most of these programs also automatically destroy your tickets when they exit. However, MIT recommends that you explicitly destroy your Kerberos tickets when you are through with them, just to be sure. One way to help ensure that this happens is to add the kdestroy command to your .logout file. Additionally, if you are going to be away from your machine and are concerned about an intruder using your permissions, it is safest to either destroy all copies of your tickets, or use a screensaver that locks the screen.

Kerberos Ticket Properties:
Obtaining Tickets with kinit:
Viewing Your Tickets with klist:
Destroying Your Tickets with kdestroy:


--------------------------------------------------------------------------------
Node:Kerberos Ticket Properties, Next:Obtaining Tickets with kinit, Previous:Ticket Management, Up:Ticket Management

Kerberos Ticket Properties
There are various properties that Kerberos tickets can have:

If a ticket is forwardable, then the KDC can issue a new ticket with a different network address based on the forwardable ticket. This allows for authentication forwarding without requiring a password to be typed in again. For example, if a user with a forwardable TGT logs into a remote system, the KDC could issue a new TGT for that user with the netword address of the remote system, allowing authentication on that host to work as though the user were logged in locally.

When the KDC creates a new ticket based on a forwardable ticket, it sets the forwarded flag on that new ticket. Any tickets that are created based on a ticket with the forwarded flag set will also have their forwarded flags set.

A proxiable ticket is similar to a forwardable ticket in that it allows a service to take on the identity of the client. Unlike a forwardable ticket, however, a proxiable ticket is only issued for specific services. In other words, a ticket-granting ticket cannot be issued based on a ticket that is proxiable but not forwardable.

A proxy ticket is one that was issued based on a proxiable ticket.

A postdated ticket is issued with the invalid flag set. After the starting time listed on the ticket, it can be presented to the KDC to obtain valid tickets.

Tickets with the postdateable flag set can be used to issue postdated tickets.

Renewable tickets can be used to obtain new session keys without the user entering their password again. A renewable ticket has two expiration times. The first is the time at which this particular ticket expires. The second is the latest possible expiration time for any ticket issued based on this renewable ticket.

A ticket with the initial flag set was issued based on the authentication protocol, and not on a ticket-granting ticket. Clients that wish to ensure that the user's key has been recently presented for verification could specify that this flag must be set to accept the ticket.

An invalid ticket must be rejected by application servers. Postdated tickets are usually issued with this flag set, and must be validated by the KDC before they can be used.

A preauthenticated ticket is one that was only issued after the client requesting the ticket had authenticated itself to the KDC.

The hardware authentication flag is set on a ticket which required the use of hardware for authentication. The hardware is expected to be possessed only by the client which requested the tickets.

If a ticket has the transit policy checked flag set, then the KDC that issued this ticket implements the transited-realm check policy and checked the transited-realms list on the ticket. The transited-realms list contains a list of all intermediate realms between the realm of the KDC that issued the first ticket and that of the one that issued the current ticket. If this flag is not set, then the application server must check the transited realms itself or else reject the ticket.

The okay as delegate flag indicates that the server specified in the ticket is suitable as a delegate as determined by the policy of that realm. A server that is acting as a delegate has been granted a proxy or a forwarded TGT. This flag is a new addition to the Kerberos V5 protocol and is not yet implemented on MIT servers.

An anonymous ticket is one in which the named principal is a generic principal for that realm; it does not actually specify the individual that will be using the ticket. This ticket is meant only to securely distribute a session key. This is a new addition to the Kerberos V5 protocol and is not yet implemented on MIT servers.



--------------------------------------------------------------------------------
Node:Obtaining Tickets with kinit, Next:Viewing Your Tickets with klist, Previous:Kerberos Ticket Properties, Up:Ticket Management

Obtaining Tickets with kinit
If your site is using the Kerberos V5 login program, you will get Kerberos tickets automatically when you log in. If your site uses a different login program, you may need to explicitly obtain your Kerberos tickets, using the kinit program. Similarly, if your Kerberos tickets expire, use the kinit program to obtain new ones.

To use the kinit program, simply type kinit and then type your password at the prompt. For example, Jennifer (whose username is jennifer) works for Bleep, Inc. (a fictitious company with the domain name mit.edu and the Kerberos realm ATHENA.MIT.EDU). She would type:

shell% kinit
Password for jennifer@ATHENA.MIT.EDU: <-- [Type jennifer's password here.]
shell%

If you type your password incorrectly, kinit will give you the following error message:

shell% kinit
Password for jennifer@ATHENA.MIT.EDU: <-- [Type the wrong password here.]
kinit: Password incorrect
shell%

and you won't get Kerberos tickets.

Notice that kinit assumes you want tickets for your own username in your default realm. Suppose Jennifer's friend David is visiting, and he wants to borrow a window to check his mail. David needs to get tickets for himself in his own realm, EXAMPLE.COM.1 He would type:

shell% kinit david@EXAMPLE.COM
Password for david@EXAMPLE.COM: <-- [Type david's password here.]
shell%

David would then have tickets which he could use to log onto his own machine. Note that he typed his password locally on Jennifer's machine, but it never went over the network. Kerberos on the local host performed the authentication to the KDC in the other realm.

If you want to be able to forward your tickets to another host, you need to request forwardable tickets. You do this by specifying the -f option:

shell% kinit -f
Password for jennifer@ATHENA.MIT.EDU: <-- [Type your password here.]
shell%

Note that kinit does not tell you that it obtained forwardable tickets; you can verify this using the klist command (see Viewing Your Tickets with klist).

Normally, your tickets are good for your system's default ticket lifetime, which is ten hours on many systems. You can specify a different ticket lifetime with the -l option. Add the letter s to the value for seconds, m for minutes, h for hours, or d for days. For example, to obtain forwardable tickets for david@EXAMPLE.COM that would be good for three hours, you would type:

shell% kinit -f -l 3h david@EXAMPLE.COM
Password for david@EXAMPLE.COM: <-- [Type david's password here.]
shell%

You cannot mix units; specifying a lifetime of 3h30m would result in an error. Note also that most systems specify a maximum ticket lifetime. If you request a longer ticket lifetime, it will be automatically truncated to the maximum lifetime.



--------------------------------------------------------------------------------
Node:Viewing Your Tickets with klist, Next:Destroying Your Tickets with kdestroy, Previous:Obtaining Tickets with kinit, Up:Ticket Management

Viewing Your Tickets with klist
The klist command shows your tickets. When you first obtain tickets, you will have only the ticket-granting ticket. (See What is a Ticket?.) The listing would look like this:

shell% klist
Ticket cache: /tmp/krb5cc_ttypa
Default principal: jennifer@ATHENA.MIT.EDU

Valid starting Expires Service principal
06/07/04 19:49:21 06/08/04 05:49:19 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
shell%

The ticket cache is the location of your ticket file. In the above example, this file is named /tmp/krb5cc_ttypa. The default principal is your kerberos principal. (see What is a Kerberos Principal?)

The "valid starting" and "expires" fields describe the period of time during which the ticket is valid. The service principal describes each ticket. The ticket-granting ticket has the primary krbtgt, and the instance is the realm name.

Now, if jennifer connected to the machine daffodil.mit.edu, and then typed klist again, she would have gotten the following result:

shell% klist
Ticket cache: /tmp/krb5cc_ttypa
Default principal: jennifer@ATHENA.MIT.EDU

Valid starting Expires Service principal
06/07/04 19:49:21 06/08/04 05:49:19 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
06/07/04 20:22:30 06/08/04 05:49:19 host/daffodil.mit.edu@ATHENA.MIT.EDU
shell%

Here's what happened: when jennifer used telnet to connect to the host daffodil.mit.edu, the telnet program presented her ticket-granting ticket to the KDC and requested a host ticket for the host daffodil.mit.edu. The KDC sent the host ticket, which telnet then presented to the host daffodil.mit.edu, and she was allowed to log in without typing her password.

Suppose your Kerberos tickets allow you to log into a host in another domain, such as trillium.example.com, which is also in another Kerberos realm, EXAMPLE.COM. If you telnet to this host, you will receive a ticket-granting ticket for the realm EXAMPLE.COM, plus the new host ticket for trillium.example.com. klist will now show:

shell% klist
Ticket cache: /tmp/krb5cc_ttypa
Default principal: jennifer@ATHENA.MIT.EDU

Valid starting Expires Service principal
06/07/04 19:49:21 06/08/04 05:49:19 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
06/07/04 20:22:30 06/08/04 05:49:19 host/daffodil.mit.edu@ATHENA.MIT.EDU
06/07/04 20:24:18 06/08/04 05:49:19 krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU
06/07/04 20:24:18 06/08/04 05:49:19 host/trillium.example.com@ATHENA.MIT.EDU
shell%

You can use the -f option to view the flags that apply to your tickets. The flags are:

F
Forwardable
f
forwarded
P
Proxiable
p
proxy
D
postDateable
d
postdated
R
Renewable
I
Initial
i
invalid
H
Hardware authenticated
A
preAuthenticated
T
Transit policy checked
O
Okay as delegate
a
anonymous
Here is a sample listing. In this example, the user jennifer obtained her initial tickets (I), which are forwardable (F) and postdated (d) but not yet validated (i). (See kinit Reference, for more information about postdated tickets.)

shell% klist -f
Ticket cache: /tmp/krb5cc_320
Default principal: jennifer@ATHENA.MIT.EDU

Valid starting Expires Service principal
31/07/05 19:06:25 31/07/05 19:16:25 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
Flags: FdiI
shell%

In the following example, the user david's tickets were forwarded (f) to this host from another host. The tickets are reforwardable (F).

shell% klist -f
Ticket cache: /tmp/krb5cc_p11795
Default principal: david@EXAMPLE.COM

Valid starting Expires Service principal
07/31/05 11:52:29 07/31/05 21:11:23 krbtgt/EXAMPLE.COM@EXAMPLE.COM
Flags: Ff
07/31/05 12:03:48 07/31/05 21:11:23 host/trillium.example.com@EXAMPLE.COM
Flags: Ff
shell%



--------------------------------------------------------------------------------
Node:Destroying Your Tickets with kdestroy, Previous:Viewing Your Tickets with klist, Up:Ticket Management

Destroying Your Tickets with kdestroy
Your Kerberos tickets are proof that you are indeed yourself, and tickets can be stolen. If this happens, the person who has them can masquerade as you until they expire. For this reason, you should destroy your Kerberos tickets when you are away from your computer.

Destroying your tickets is easy. Simply type kdestroy.

shell% kdestroy
shell%

If kdestroy fails to destroy your tickets, it will beep and give an error message. For example, if kdestroy can't find any tickets to destroy, it will give the following message:

shell% kdestroy
kdestroy: No credentials cache file found while destroying cache
shell%



--------------------------------------------------------------------------------
Node:Password Management, Next:Kerberos V5 Applications, Previous:Ticket Management, Up:Kerberos V5 Tutorial

Password Management
Your password is the only way Kerberos has of verifying your identity. If someone finds out your password, that person can masquerade as you--send email that comes from you, read, edit, or delete your files, or log into other hosts as you--and no one will be able to tell the difference. For this reason, it is important that you choose a good password (see Password Advice), and keep it secret. If you need to give access to your account to someone else, you can do so through Kerberos. (See Granting Access to Your Account.) You should never tell your password to anyone, including your system administrator, for any reason. You should change your password frequently, particularly any time you think someone may have found out what it is.

Changing Your Password:
Password Advice:
Granting Access to Your Account:


--------------------------------------------------------------------------------
Node:Changing Your Password, Next:Password Advice, Previous:Password Management, Up:Password Management

Changing Your Password
To change your Kerberos password, use the kpasswd command. It will ask you for your old password (to prevent someone else from walking up to your computer when you're not there and changing your password), and then prompt you for the new one twice. (The reason you have to type it twice is to make sure you have typed it correctly.) For example, user david would do the following:

shell% kpasswd
Password for david: <- Type your old password.
Enter new password: <- Type your new password.
Enter it again: <- Type the new password again.
Password changed.
shell%

If david typed the incorrect old password, he would get the following message:

shell% kpasswd
Password for david: <- Type the incorrect old password.
kpasswd: Password incorrect while getting initial ticket
shell%

If you make a mistake and don't type the new password the same way twice, kpasswd will ask you to try again:

shell% kpasswd
Password for david: <- Type the old password.
Enter new password: <- Type the new password.
Enter it again: <- Type a different new password.
kpasswd: Password mismatch while reading password
shell%

Once you change your password, it takes some time for the change to propagate through the system. Depending on how your system is set up, this might be anywhere from a few minutes to an hour or more. If you need to get new Kerberos tickets shortly after changing your password, try the new password. If the new password doesn't work, try again using the old one.



--------------------------------------------------------------------------------
Node:Password Advice, Next:Granting Access to Your Account, Previous:Changing Your Password, Up:Password Management

Password Advice
Your password can include almost any character you can type (except control keys and the "enter" key). A good password is one you can remember, but that no one else can easily guess. Examples of bad passwords are words that can be found in a dictionary, any common or popular name, especially a famous person (or cartoon character), your name or username in any form (e.g., forward, backward, repeated twice, etc.), your spouse's, child's, or pet's name, your birth date, your social security number, and any sample password that appears in this (or any other) manual. MIT recommends that your password be at least 6 characters long, and contain UPPER- and lower-case letters, numbers, and/or punctuation marks. Some passwords that would be good if they weren't listed in this manual include:

some initials, like "GykoR-66." for "Get your kicks on Route 66."
an easy-to-pronounce nonsense word, like "slaRooBey" or "krang-its"
a misspelled phrase, like "2HotPeetzas!" or "ItzAGurl!!!"
Note: don't actually use any of the above passwords. They're only meant to show you how to make up a good password. Passwords that appear in a manual are the first ones intruders will try. Kerberos V5 allows your system administrators to automatically reject bad passwords, based on certain criteria, such as a password dictionary or a minimum length. For example, if the user jennifer, who had a policy "strict" that required a minimum of 8 characaters, chose a password that was less than 8 characters, Kerberos would give an error message like the following:

shell% kpasswd
Password for jennifer: <- Type your old password here.

jennifer's password is controlled by the policy strict, which
requires a minimum of 8 characters from at least 3 classes (the five classes
are lowercase, uppercase, numbers, punctuation, and all other characters).

Enter new password: <- Type an insecure new password.
Enter it again: <- Type it again.

kpasswd: Password is too short while attempting to change password.
Please choose another password.

Enter new password: <- Type a good password here.
Enter it again: <- Type it again.
Password changed.
shell%

Your system administrators can choose the message that is displayed if you choose a bad password, so the message you see may be different from the above example.



--------------------------------------------------------------------------------
Node:Granting Access to Your Account, Previous:Password Advice, Up:Password Management

Granting Access to Your Account
If you need to give someone access to log into your account, you can do so through Kerberos, without telling the person your password. Simply create a file called .k5login in your home directory. This file should contain the Kerberos principal (See What is a Kerberos Principal?.) of each person to whom you wish to give access. Each principal must be on a separate line. Here is a sample .k5login file:

jennifer@ATHENA.MIT.EDU
david@EXAMPLE.COM

This file would allow the users jennifer and david to use your user ID, provided that they had Kerberos tickets in their respective realms. If you will be logging into other hosts across a network, you will want to include your own Kerberos principal in your .k5login file on each of these hosts.

Using a .k5login file is much safer than giving out your password, because:

You can take access away any time simply by removing the principal from your .k5login file.
Although the user has full access to your account on one particular host (or set of hosts if your .k5login file is shared, e.g., over NFS), that user does not inherit your network privileges.
Kerberos keeps a log of who obtains tickets, so a system administrator could find out, if necessary, who was capable of using your user ID at a particular time.
One common application is to have a .k5login file in root's home directory, giving root access to that machine to the Kerberos principals listed. This allows system administrators to allow users to become root locally, or to log in remotely as root, without their having to give out the root password, and without anyone having to type the root password over the network.



--------------------------------------------------------------------------------
Node:Kerberos V5 Applications, Previous:Password Management, Up:Kerberos V5 Tutorial

Kerberos V5 Applications
Kerberos V5 is a single-sign-on system. This means that you only have to type your password once, and the Kerberos V5 programs do the authenticating (and optionally encrypting) for you. The way this works is that Kerberos has been built into each of a suite of network programs. For example, when you use a Kerberos V5 program to connect to a remote host, the program, the KDC, and the remote host perform a set of rapid negotiations. When these negotiations are completed, your program has proven your identity on your behalf to the remote host, and the remote host has granted you access, all in the space of a few seconds.
The Kerberos V5 applications are versions of existing UNIX network programs with the Kerberos features added.

Overview of Additional Features:
telnet:
rlogin:
FTP:
rsh:
rcp:
ksu:


--------------------------------------------------------------------------------
Node:Overview of Additional Features, Next:telnet, Previous:Kerberos V5 Applications, Up:Kerberos V5 Applications

Overview of Additional Features
The Kerberos V5 network programs are those programs that connect to another host somewhere on the internet. These programs include rlogin, telnet, ftp, rsh, rcp, and ksu. These programs have all of the original features of the corresponding non-Kerberos rlogin, telnet, ftp, rsh, rcp, and su programs, plus additional features that transparently use your Kerberos tickets for negotiating authentication and optional encryption with the remote host. In most cases, all you'll notice is that you no longer have to type your password, because Kerberos has already proven your identity.

The Kerberos V5 network programs allow you the options of forwarding your tickets to the remote host (if you obtained forwardable tickets with the kinit program; see Obtaining Tickets with kinit), and encrypting data transmitted between you and the remote host.

This section of the tutorial assumes you are familiar with the non-Kerberos versions of these programs, and highlights the Kerberos functions added in the Kerberos V5 package.



--------------------------------------------------------------------------------
Node:telnet, Next:rlogin, Previous:Overview of Additional Features, Up:Kerberos V5 Applications

telnet
The Kerberos V5 telnet command works exactly like the standard UNIX telnet program, with the following Kerberos options added:

-f
forwards a copy of your tickets to the remote host.
-F
forwards a copy of your tickets to the remote host, and marks them re-forwardable from the remote host.
-k realm
requests tickets for the remote host in the specified realm, instead of determining the realm itself.
-K
uses your tickets to authenticate to the remote host, but does not log you in.
-a
attempt automatic login using your tickets. telnet will assume the same username unless you explicitly specify another.
-x
turns on encryption.
For example, if david wanted to use the standard UNIX telnet to connect to the machine daffodil.mit.edu, he would type:

shell% telnet daffodil.example.com
Trying 128.0.0.5 ...
Connected to daffodil.example.com.
Escape character is '^]'.

NetBSD/i386 (daffodil) (ttyp3)

login: david
Password: <- david types his password here
Last login: Fri Jun 21 17:13:11 from trillium.mit.edu
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.

NetBSD 1.1: Tue May 21 00:31:42 EDT 1996

Welcome to NetBSD!
shell%

Note that the machine daffodil.example.com asked for david's password. When he typed it, his password was sent over the network unencrypted. If an intruder were watching network traffic at the time, that intruder would know david's password.

If, on the other hand, jennifer wanted to use the Kerberos V5 telnet to connect to the machine trillium.mit.edu, she could forward a copy of her tickets, request an encrypted session, and log on as herself as follows:

shell% telnet -a -f -x trillium.mit.edu
Trying 128.0.0.5...
Connected to trillium.mit.edu.
Escape character is '^]'.
[ Kerberos V5 accepts you as ``jennifer@mit.edu'' ]
[ Kerberos V5 accepted forwarded credentials ]
What you type is protected by encryption.
Last login: Tue Jul 30 18:47:44 from {No value for `RANDOMHOST'}.example.com
Athena Server (sun4) Version 9.1.11 Tue Jul 30 14:40:08 EDT 2002

shell%

Note that jennifer's machine used Kerberos to authenticate her to trillium.mit.edu, and logged her in automatically as herself. She had an encrypted session, a copy of her tickets already waiting for her, and she never typed her password.

If you forwarded your Kerberos tickets, telnet automatically destroys them when it exits. The full set of options to Kerberos V5 telnet are discussed in the Reference section of this manual. (see telnet Reference)



--------------------------------------------------------------------------------
Node:rlogin, Next:FTP, Previous:telnet, Up:Kerberos V5 Applications

rlogin
The Kerberos V5 rlogin command works exactly like the standard UNIX rlogin program, with the following Kerberos options added:

-f
forwards a copy of your tickets to the remote host.
-F
forwards a copy of your tickets to the remote host, and marks them re-forwardable from the remote host.
-k realm
requests tickets for the remote host in the specified realm, instead of determining the realm itself.
-x
encrypts the input and output data streams (the username is sent unencrypted)
For example, if david wanted to use the standard UNIX rlogin to connect to the machine daffodil.example.com, he would type:

shell% rlogin daffodil.example.com -l david
Password: <- david types his password here
Last login: Fri Jun 21 10:36:32 from :0.0
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.

NetBSD 1.1: Tue May 21 00:31:42 EDT 1996

Welcome to NetBSD!
shell%

Note that the machine daffodil.example.com asked for david's password. When he typed it, his password was sent over the network unencrypted. If an intruder were watching network traffic at the time, that intruder would know david's password.

If, on the other hand, jennifer wanted to use Kerberos V5 rlogin to connect to the machine trillium.mit.edu, she could forward a copy of her tickets, mark them as not forwardable from the remote host, and request an encrypted session as follows:

shell% rlogin trillium.mit.edu -f -x
This rlogin session is using DES encryption for all data transmissions.
Last login: Thu Jun 20 16:20:50 from daffodil
Athena Server (sun4) Version 9.1.11 Tue Jul 30 14:40:08 EDT 2002
shell%

Note that jennifer's machine used Kerberos to authenticate her to trillium.mit.edu, and logged her in automatically as herself. She had an encrypted session, a copy of her tickets were waiting for her, and she never typed her password.

If you forwarded your Kerberos tickets, rlogin automatically destroys them when it exits. The full set of options to Kerberos V5 rlogin are discussed in the Reference section of this manual. (see rlogin Reference)



--------------------------------------------------------------------------------
Node:FTP, Next:rsh, Previous:rlogin, Up:Kerberos V5 Applications

FTP
The Kerberos V5 FTP program works exactly like the standard UNIX FTP program, with the following Kerberos features added:

-k realm
requests tickets for the remote host in the specified realm, instead of determining the realm itself.
-f
requests that your tickets be forwarded to the remote host. The -f argument must be the last argument on the command line.
protect level
(issued at the ftp> prompt) sets the protection level. "Clear" is no protection; "safe" ensures data integrity by verifying the checksum, and "private" encrypts the data. Encryption also ensures data integrity.
For example, suppose jennifer wants to get her RMAIL file from the directory ~jennifer/Mail, on the host daffodil.mit.edu. She wants to encrypt the file transfer. The exchange would look like the following:

shell% ftp daffodil.mit.edu
Connected to daffodil.mit.edu.
220 daffodil.mit.edu FTP server (Version 5.60) ready.
334 Using authentication type GSSAPI; ADAT must follow
GSSAPI accepted as authentication type
GSSAPI authentication succeeded
200 Data channel protection level set to private.
Name (daffodil.mit.edu:jennifer):
232 GSSAPI user jennifer@ATHENA.MIT.EDU is authorized as jennifer
230 User jennifer logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> protect private
200 Protection level set to Private.
ftp> cd ~jennifer/MAIL
250 CWD command successful.
ftp> get RMAIL
227 Entering Passive Mode (128,0,0,5,16,49)
150 Opening BINARY mode data connection for RMAIL (361662 bytes).
226 Transfer complete.
361662 bytes received in 2.5 seconds (1.4e+02 Kbytes/s)
ftp> quit
shell%

The full set of options to Kerberos V5 FTP are discussed in the Reference section of this manual. (see FTP Reference)



--------------------------------------------------------------------------------
Node:rsh, Next:rcp, Previous:FTP, Up:Kerberos V5 Applications

rsh
The Kerberos V5 rsh program works exactly like the standard UNIX rlogin program, with the following Kerberos features added:

-f
forwards a copy of your tickets to the remote host.
-F
forwards a copy of your tickets to the remote host, and marks them re-forwardable from the remote host.
-k realm
requests tickets for the remote host in the specified realm, instead of determining the realm itself.
-x
encrypts the input and output data streams (the command line is not encrypted)
For example, if your Kerberos tickets allowed you to run programs on the host
trillium@example.com as root, you could run the date program as follows:

shell% rsh trillium.example.com -l root -x date
This rsh session is using DES encryption for all data transmissions.
Tue Jul 30 19:34:21 EDT 2002
shell%

If you forwarded your Kerberos tickets, rsh automatically destroys them when it exits. The full set of options to Kerberos V5 rsh are discussed in the Reference section of this manual. (see rsh Reference)



--------------------------------------------------------------------------------
Node:rcp, Next:ksu, Previous:rsh, Up:Kerberos V5 Applications

rcp
The Kerberos V5 rcp program works exactly like the standard UNIX rcp program, with the following Kerberos features added:

-k realm
requests tickets for the remote host in the specified realm, instead of determining the realm itself.
-x
turns on encryption.
For example, if you wanted to copy the file /etc/motd from the host daffodil.mit.edu into the current directory, via an encrypted connection, you would simply type:

shell% rcp -x daffodil.mit.edu:/etc/motd .

The rcp program negotiates authentication and encryption transparently. The full set of options to Kerberos V5 rcp are discussed in the Reference section of this manual. (see rcp Reference)



--------------------------------------------------------------------------------
Node:ksu, Previous:rcp, Up:Kerberos V5 Applications

ksu
The Kerberos V5 ksu program replaces the standard UNIX su program. ksu first authenticates you to Kerberos. Depending on the configuration of your system, ksu may ask for your Kerberos password if authentication fails. Note that you should never type your password if you are remotely logged in using an unencrypted connection.

Once ksu has authenticated you, if your Kerberos principal appears in the target's .k5login file (see Granting Access to Your Account) or in the target's .k5users file (see below), it switches your user ID to the target user ID.

For example, david has put jennifer's Kerberos principal in his .k5login file. If jennifer uses ksu to become david, the exchange would look like this. (To differentiate between the two shells, jennifer's prompt is represented as jennifer% and david's prompt is represented as david%.)

jennifer% ksu david
Account david: authorization for jennifer@ATHENA.MIT.EDU successful
Changing uid to david (3382)
david%

Note that the new shell has a copy of jennifer's tickets. The ticket filename contains david's UID with .1 appended to it:

david% klist
Ticket cache: /tmp/krb5cc_3382.1
Default principal: jennifer@ATHENA.MIT.EDU

Valid starting Expires Service principal
07/31/04 21:53:01 08/01/04 07:52:53 krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
07/31/04 21:53:39 08/01/04 07:52:53 host/daffodil.mit.edu@ATHENA.MIT.EDU
david%

If jennifer had not appeared in david's .k5login file (and the system was configured to ask for a password), the exchange would have looked like this (assuming david has taken appropriate precautions in protecting his password):

jennifer% ksu david
WARNING: Your password may be exposed if you enter it here and are logged
in remotely using an unsecure (non-encrypted) channel.
Kerberos password for david@ATHENA.MIT.EDU: <- jennifer types the wrong password here.
ksu: Password incorrect
Authentication failed.
jennifer%

Now, suppose david did not want to give jennifer full access to his account, but wanted to give her permission to list his files and use the "more" command to view them. He could create a .k5users file giving her permission to run only those specific commands.

The .k5users file is like the .k5login file, except that each principal is optionally followed by a list of commands. ksu will let those principals execute only the commands listed, using the -e option. david's .k5users file might look like the following:

jennifer@ATHENA.MIT.EDU /bin/ls /usr/bin/more
joeadmin@ATHENA.MIT.EDU /bin/ls
joeadmin/admin@ATHENA.MIT.EDU *
david@EXAMPLE.COM

The above .k5users file would let jennifer run only the commands /bin/ls and /usr/bin/more. It would let joeadmin run only the command /bin/ls if he had regular tickets, but if he had tickets for his admin instance, joeadmin/admin@ATHENA.MIT.EDU, he would be able to execute any command. The last line gives david in the realm EXAMPLE.COM permission to execute any command. (I.e., having only a Kerberos principal on a line is equivalent to giving that principal permission to execute *.) This is so that david can allow himself to execute commands when he logs in, using Kerberos, from a machine in the realm EXAMPLE.COM.

Then, when jennifer wanted to list his home directory, she would type:

jennifer% ksu david -e ls ~david
Authenticated jennifer@ATHENA.MIT.EDU
Account david: authorization for jennifer@ATHENA.MIT.EDU for execution of
/bin/ls successful
Changing uid to david (3382)
Mail News Personal misc bin
jennifer%

If jennifer had tried to give a different command to ksu, it would have prompted for a password as with the previous example.

Note that unless the .k5users file gives the target permission to run any command, the user must use ksu with the -e command option.

The ksu options you are most likely to use are:

-n principal
specifies which Kerberos principal you want to use for ksu. (e.g., the user joeadmin might want to use his admin instance. See What is a Ticket?.)
-c
specifies the location of your Kerberos credentials cache (ticket file).
-k
tells ksu not to destroy your Kerberos tickets when ksu is finished.
-f
requests forwardable tickets. (See Obtaining Tickets with kinit.) This is only applicable if ksu needs to obtain tickets.
-l lifetime
sets the ticket lifetime. (See Obtaining Tickets with kinit.) This is only applicable if ksu needs to obtain tickets.
-z
tells ksu to copy your Kerberos tickets only if the UID you are switching is the same as the Kerberos primary (either yours or the one specified by the -n option).
-Z
tells ksu not to copy any Kerberos tickets to the new UID.
-e command
tells ksu to execute command and then exit. See the description of the .k5users file above.
-a text
(at the end of the command line) tells ksu to pass everything after -a to the target shell.
The full set of options to Kerberos V5 ksu are discussed in the Reference section of this manual. (see ksu Reference)



--------------------------------------------------------------------------------
Node:Kerberos V5 Reference, Next:Kerberos Glossary, Previous:Kerberos V5 Tutorial, Up:Top

Kerberos V5 Reference
This section will include copies of the manual pages for the Kerberos V5 client programs. You can read the manual entry for any command by typing man command, where command is the name of the command for which you want to read the manual entry. For example, to read the kinit manual entry, you would type:

shell% man kinit

Note: To be able to view the Kerberos V5 manual pages on line, you may need to add the directory /usr/local/man to your MANPATH environment variable. (Remember to replace /usr/local with the top-level directory in which Kerberos V5 is installed.) For example, if you had the the following line in your .login file2:

setenv MANPATH /usr/local/man:/usr/man

and the Kerberos V5 man pages were in the directory /usr/krb5/man, you would change the line to the following:

setenv MANPATH /usr/krb5/man:/usr/local/man:/usr/man

kinit Reference:
klist Reference:
ksu Reference:
kdestroy Reference:
kpasswd Reference:
telnet Reference:
FTP Reference:
rlogin Reference:
rsh Reference:
rcp Reference:


--------------------------------------------------------------------------------
Node:kinit Reference, Next:klist Reference, Previous:Kerberos V5 Reference, Up:Kerberos V5 Reference

kinit Reference
kinit manpage


--------------------------------------------------------------------------------
Node:klist Reference, Next:ksu Reference, Previous:kinit Reference, Up:Kerberos V5 Reference

klist Reference
klist manpage


--------------------------------------------------------------------------------
Node:ksu Reference, Next:kdestroy Reference, Previous:klist Reference, Up:Kerberos V5 Reference

ksu Reference
ksu manpage


--------------------------------------------------------------------------------
Node:kdestroy Reference, Next:kpasswd Reference, Previous:ksu Reference, Up:Kerberos V5 Reference

kdestroy Reference
kdestroy manpage


--------------------------------------------------------------------------------
Node:kpasswd Reference, Next:telnet Reference, Previous:kdestroy Reference, Up:Kerberos V5 Reference

kpasswd Reference
kpasswd manpage


--------------------------------------------------------------------------------
Node:telnet Reference, Next:FTP Reference, Previous:kpasswd Reference, Up:Kerberos V5 Reference

telnet Reference
telnet manpage


--------------------------------------------------------------------------------
Node:FTP Reference, Next:rlogin Reference, Previous:telnet Reference, Up:Kerberos V5 Reference

FTP Reference
ftp manpage


--------------------------------------------------------------------------------
Node:rlogin Reference, Next:rsh Reference, Previous:FTP Reference, Up:Kerberos V5 Reference

rlogin Reference
rlogin manpage


--------------------------------------------------------------------------------
Node:rsh Reference, Next:rcp Reference, Previous:rlogin Reference, Up:Kerberos V5 Reference

rsh Reference
rsh manpage


--------------------------------------------------------------------------------
Node:rcp Reference, Previous:rsh Reference, Up:Kerberos V5 Reference

rcp Reference
rcp manpage


--------------------------------------------------------------------------------
Node:Kerberos Glossary, Previous:Kerberos V5 Reference, Up:Top

Kerberos Glossary
client
an entity that can obtain a ticket. This entity is usually either a user or a host.

host
a computer that can be accessed over a network.

Kerberos
in Greek mythology, the three-headed dog that guards the entrance to the underworld. In the computing world, Kerberos is a network security package that was developed at MIT.

KDC
Key Distribution Center. A machine that issues Kerberos tickets.

keytab
a key table file containing one or more keys. A host or service uses a keytab file in much the same way as a user uses his/her password.

principal
a string that names a specific entity to which a set of credentials may be assigned. It can have an arbitrary number of components, but generally has three:
primary
the first part of a Kerberos principal. In the case of a user, it is the username. In the case of a service, it is the name of the service.

instance
the second part of a Kerberos principal. It gives information that qualifies the primary. The instance may be null. In the case of a user, the instance is often used to describe the intended use of the corresponding credentials. In the case of a host, the instance is the fully qualified hostname.

realm
the logical network served by a single Kerberos database and a set of Key Distribution Centers. By convention, realm names are generally all uppercase letters, to differentiate the realm from the internet domain.
The typical format of a typical Kerberos principal is primary/instance@REALM.


service
any program or computer you access over a network. Examples of services include "host" (a host, e.g., when you use telnet and rsh), "ftp" (FTP), "krbtgt" (authentication; cf. ticket-granting ticket), and "pop" (email).

ticket
a temporary set of electronic credentials that verify the identity of a client for a particular service.

TGT
Ticket-Granting Ticket. A special Kerberos ticket that permits the client to obtain additional Kerberos tickets within the same Kerberos realm.
Table of Contents
Copyright
Introduction
What is a Ticket?
What is a Kerberos Principal?
Kerberos V5 Tutorial
Setting Up to Use Kerberos V5
Ticket Management
Kerberos Ticket Properties
Obtaining Tickets with kinit
Viewing Your Tickets with klist
Destroying Your Tickets with kdestroy
Password Management
Changing Your Password
Password Advice
Granting Access to Your Account
Kerberos V5 Applications
Overview of Additional Features
telnet
rlogin
FTP
rsh
rcp
ksu
Kerberos V5 Reference
kinit Reference
klist Reference
ksu Reference
kdestroy Reference
kpasswd Reference
telnet Reference
FTP Reference
rlogin Reference
rsh Reference
rcp Reference
Kerberos Glossary

--------------------------------------------------------------------------------

Footnotes
Note: the realm EXAMPLE.COM must be listed in your computer's Kerberos configuration file, /etc/krb5.conf.

The MANPATH variable may be specified in a different initialization file, depending on your operating system. Some of the files in which you might specify environment variables include .login, .profile, or .cshrc.

--------------------------------------------------------------------------------

2006년 4월 24일 월요일

ruby on rails Eclipse 連携

参考サイト
http://www.napcs.com/howto/railsonwindows.html


Setting up a Rails Development Environment on Windows Using EclipseBy Brian Hogan

Last updated on February 10, 2006 10:14 PM

It looks like the current version of RDT works correctly now. I have rebuilt the entire package from scratch once again to ensure that all of the links are up to date. Things are working now with Eclipse 3.1.2 but the Web Tools pieces require more manual work than before.

I also added a Downloads section where I'll be placing some templates and helper files to speed up the process.

Please, as always, provide some feedback. I can't answer emails about issues not directly related to the setup of this plugin.

If you feel so inclined, a small donation would be much appreciated to help cover bandwidth costs. Thanks for the donations so far.


--------------------------------------------------------------------------------

This is a quick yet detailed guide on how to set up a very easy-to-use development environment for Ruby On Rails. This guide is for Windows users but there's no reason that it couldn't be adapted for Linux users as well. The guide assumes that you already have a working database installed or available and that you have Ruby installed to c:
uby.



Lastly, this is not a guide on how to get started with Ruby on Rails! This is simply one method to create a useful IDE for Rails development.

Download and install Ruby and Rails
Install Eclipse
Configure Eclipse for Rails
Install the Ruby Developer Tools package
Configure the RDT plugin
Launching External Rails Scripts within Eclipse (Now with downloadable goodness! )
Configure Eclipse to Create Rails Projects
Configure Eclipse to Launch WEBrick server
Configure Eclipse to Create Rails Models
Configure Eclipse to Create Rails Controllers
Configure Eclipse to Generate Scaffold for Controllers and Views
Setting up the Favorites
Working with Rails Projects in Eclipse
Configure WEBrick's Output for Eclipse
Create a new Rails Project
Show All Files
Install the DBEdit Eclipse plugin
Connect to a Database
Install Web Developer Tools for Eclipse (Updated!)
Configure Eclipse to handle you View files
Add code hints for the views
Debugging within Eclipse
Setting up Breakpointer
Using Breakpointer
Installing SubClipse
Troubleshooting (Updated!)
Downloads (New!)
Screenshots

--------------------------------------------------------------------------------

Download and install Ruby and Rails
I am operating under the assumption that you're going to use the One-Click Ruby Installer created by Curt Hibbs. If you don't, then you're going to have to modify these instructions yourself.

Download and install the One-Click Ruby Installer for Windows
http://rubyforge.org/projects/rubyinstaller/
These instructions assume you have installed this to c:
uby (the default location)
Open a command prompt and type
gem install rails --include-dependencies

--------------------------------------------------------------------------------

Install Eclipse
Download Eclipse 3.1.2 SDK from http://www.eclipse.org/downloads/index.php
Direct Download
Unzip the files to C:javaeclipse
Make a shortcut to C:javaeclipseeclipse.exe
Start Eclipse and set the workspace to C:javaworkspace
One user had trouble with using the default workspace location for Eclipse, and setting it to a simple path with no spaces solved the problem

--------------------------------------------------------------------------------

Configure Eclipse for Rails
Install the Ruby Developer Tools package
The Ruby Developer Tools plugin is a great set of tools that turn Eclipse into a nice Ruby IDE. The current version (0.6.0 as of this writing) now supports Eclipse 3.1. However, I will continue to use the nightly build for this tutorial.

Launch Eclipse
Choose Help->Software Updates->Find and Install
Choose "Search for new features to install" and select Next
Select "New Remote Site",
Use the name “Ruby Developer Tools”
Use http://updatesite.rubypeople.org/release for the URL
You can use http://updatesite.rubypeople.org/nightly if you wish to use the most current nightly build.
Press OK
Check RDT and push Next
Select the feature RDT and push Next. You should confirm any messages relating to installing unsigned plugins. RDT will be installed and be available after restart.
Configure the RDT plugin
Select Windows > Prefrences > Ruby
Select Installed Interpreters
Click Add
Enter Ruby as the interpreter name (You might want to include the version number if you know it)
Enter the path to your ruby.exe file (usually c:
uby?in
ubyw.exe)
Select OK
Configure the rest of your Ruby settings and then select OK to save the settings.



--------------------------------------------------------------------------------

Launching External Rails Scripts Within Eclipse
You should know that hese settings are tied to your workspace. If you change workspaces then you will need to reconfigure these options. Hopefully the fine developers of RDT will build these into the plugin at some point so they appear on the context menus.

At this point, you're going to want to open the Ruby perspective. To do this, go to Window -> Open Perspective -> Other and choose Ruby

If you don't want to go through the trouble of creating these external tools, you can download this file and unzip it to the root of your c: drive. The files should then extact to c:javaworkspace.metadata.pluginsorg.eclipse.debug.core.launches (assuming you've followed along so far). Be sure to set up the favorites once you import these settings!


Configure Eclipse to Create Rails Projects
Select Run -> External Tools -> External Tools
Select "Program" from the configuration tree
Select New to create a new program
Enter “Create Rails Application in Project” as the name
Enter C:
uby?in
ails.cmd for the Location
Enter ${project_loc} for the Working Directory
Enter ../${project_name} for the Arguments
Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply
Configure Eclipse to Launch WEBrick server
Select Run -> External Tools -> External Tools
Select "Program" from the configuration tree
Select New to create a new program
Enter “Start WEBrick” as the name
Enter C:
uby?in
uby.exe for the Location
For the Working Directory, use
${project_loc}
Enter scriptserver for the Arguments
Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply

Configure Eclipse to Create Rails Models
Select Run -> External Tools -> External Tools
Select "Program" from the configuration tree
Select New to create a new program
Enter “Generate Model” as the name
Enter C:
uby?in
uby.exe for the Location
For the Working Directory, use
${project_loc}
Enter for the arguments
script/generate model ${string_prompt:Model name} -f
Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply
Configure Eclipse to Create Rails Controllers
As many have noted, you could simply duplicate the previous entry and simply change the arguments

Select Run -> External Tools -> External Tools
Select "Program" from the configuration tree
Select New to create a new program
Enter “Generate Controller” as the name
Enter C:
uby?in
uby.exe for the Location
For the Working Directory, use
${project_loc}
Enter for the arguments
script/generate controller ${string_prompt:Controller name} -f
Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply
(You could just copy the "generate model" example above and change the argument).
Configure Eclipse to Generate Scaffold for Controllers and Views
As many have noted, you could simply duplicate the previous entry and simply change the arguments

Select Run -> External Tools -> External Tools
Select "Program" from the configuration tree
Select New to create a new program
Enter “Generate Scaffold” as the name
Enter C:
uby?in
uby.exe for the Location
For the Working Directory, use
${project_loc}
Enter for the arguments
script/generate scaffold ${string_prompt:Model name} ${string_prompt:Controller name} ${string_prompt:Actions separated with spaces} -f

Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply
Setting Up the Favorites
Sometimes, all of these external commands won't show up under the External Commands icon. We can fix that by making them "Favorites".

Select Run > External Tools > Organize Favorites
Add each external tool that you want to appear on your menu of External Tools
Select Add...
Select the tools you wish to add to your menu and press OK
Use the Up and Down buttons to change the order of the items in the menu
Select OK to save the items

--------------------------------------------------------------------------------

Working with Rails Projects in Eclipse
Configure WEBrick's Output for Eclipse
For some strange reason, WEBrick's output doesn't always get piped to Eclipse's console. We can hack this a bit to make this work for us. We need to add these two lines to the Rails server script:

Provided that you've installed Ruby to c:
uby as instructed above, you can navigate to

C:
ubylib
ubygems1.8gems
ails-0.13.1?in

and edit the server file with a good text editor (anything except for notepad or wordpad).

Add this to the second line of the script:

$stdout.sync=true
$stderr.sync=true

Alternatively, you could just add these two lines to WEBrick once you've created your Rails project by modifying the server file under /scripts in your Rails project.

Create a new Rails Project
Select File > New > Other : Ruby > Ruby Project
Enter a name for your project.
This name will be the name you'll use for your Rails project name when you generate the Rails application files
Make sure to use the Eclipse Workspace for the project contents!
Select the project in the Ruby Resources view
Go to Run -> External Tools and choose Create Rails Project. A few seconds later, your Eclipse Console should show the results of the file creation and your file project tree should be populated with your ruby files.
At this point, you'll want to edit your config/database.yml file with your database properties.
Show All Files
Under Ruby Resources, select the down arrow icon and deselect Show Ruby Files Only so you can see all the files in your project and not just the .rb files (If you don't see Ruby Resources, it's most likely because you didn't change to the Ruby perspective. (Eclipse defaults to the Java perspective!)


--------------------------------------------------------------------------------

Install the DBEdit Eclipse plugin
The DBEdit plugin for Eclipse will allow you to view and edit your database tables from Eclipse as well as run various SQL statements against your database.

Shut down Eclipse
Download the DBEdit plugin version 1.0.3_1 from http://prdownloads.sourceforge.net/dbedit/dbedit_1.0.3_1.bin.dist_3.X.zip?download
Unzip the file to your c:javaeclipse folder. The file should place new files in your features and plugins folder.
Download and the appropriate driver for your database
MySQL
http://www.mysql.com/products/connector/j/
Microsoft SQL Server
http://www.microsoft.com/downloads/details.aspx?familyid=9F1874B6-F8E1-4BD6-947C-0FC5BF05BF71&displaylang=en

SQLite:
If anyone gets this to work for Windows, please send me instructions!
Extract the contents of this driver to c:javadrivers
Launch Eclipse
Select Window -> Show View -> Other
Select DBEdit and choose Tables
Connect to a Database
Connecting to a database is pretty straight-forward. I'll use MySQL for an example. In this article, I assume you're using MySQL 4.1 and that you have installed the appropriate driver.

Right-click anywhere in the whitespace of the Tables pallette and select Connection -> Configure from the popup menu
Select New
Enter a name for the connection in the Name field
Select the Classpath tab and press Add to Archive. Navigate to your drivers folder and select the appropriate driver jar file.
For MySQL, choose mysql-connector-java-3.1.12-bin.jar
Select the Commom tab
Select com.mysql.jdbc.Driver for the Driver
Enter jdbc:mysql://host/dbname for your database
Enter your database username
For MySql, remove the entry in the Schema field!
Enter your passwod and select Save Password
Press Connect to save and connect to the database.
You can go to Window -> Show View -> Other ->DBEdit ->Instant SQL to bring up a SQL editor panel. Here you can execute statements against your database!

--------------------------------------------------------------------------------

Install Web Developer Tools Plugin for Eclipse
There is a great plugin bundle for JSP development that we can take advantage of for our Rails development. The WTP plugin has a very versatile CSS, XML, and HTML editor

Download the following files:
EMF SDK version 2.1.1 or higher emf-sdo-xsd-SDK-2.1.1.zip
GEF SDK 3.1.1 or higher GEF-SDK-3.1.1.zip
JEM SDK 1.1.0.1 or higher JEM-SDK-1.1.0.1.zip
Download the Web Tools plugin from http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R-1.0-200512210855/wtp-1.0.zip (~24 MB)
Unzip each file to C:java, overwriting any files.
Restart Eclipse.
Now, when you open your CSS or HTML files, you'll be able to use auto complete for elements and attributes, as well as create templates.

Opening the Properties view will let you inspect the attributes and properties of the element you select, and opening the Outline view will show you a representation of your document model.

Configure Eclipse to handle your Rails Presentation files
Eclipse can handle your rhtml files with syntax highlighting! All you have to do is associate the .rhtml extention with the JSP editor. Once you do that, you can add templates for all of the ActionView helper functions to make development even easier.

Select Window -> Preferences
Expand the General section
Select the Content Types option
Expand Text
Select JSP
Select Add
Enter *.rhtml and press OK
Select Add
Enter *.rxml and press OK
Press OK to save the changes
Add Code Hints for the Views
Now, let's add the Rails Link_to tag to the templates library

Selct Window -> Preferences
Expand the Web and XML section
Expand the JSP Files section
Select JSP Templates
Select New
Enter link_to for the name
The context should be ALL JSP
Automatically Insert should be checked
Enter the following for the pattern:
<%= link_to "${url}", :controller=>"${controller}", :action=>"${action}", :id=>"${id}" %>

Create a new .rhtml file and press CTRL+Spacebar

Your Link_to tag should be in that list. When you type the < character, your list of options should appear. Type link to filter the list of results.

When the template is first inserted, the cursor is placed at the url variable, if you hit tab, it will cycle to the next variable in the list.

You can repeat these steps with other helper tags to speed up development. To get you started, I've provided this starter template. Import this into the JSP Templates section via the Import button.



Debugging in Eclipse
Ruby on Rails has some interesting techniques to debug projects. One technique is the Breakpointer script. The Breakpointer connects an IRB session to your running web application.

Setting up Breakpointer
Select Run -> External Tools -> External Tools
Select New to create a new program
Enter “Start Breakpointer ” as the name
Enter C:
uby?in
uby.exe for the Location
For the Working Directory, use
${project_loc}
Enter script?reakpointer for the Arguments
Select the refresh tab and check Refresh Resources Upon Completion
Select the Common tab
Find the section for Display in Favorites Menu
Check the box next to External Tools
Select Apply
Using Breakpointer
In your project, place the following line of code in any method where you want to stop code execution:
breakpoint
Start up WEBrick:
Go to Run -> External Tools ->Start WEBrick
Start up Breakpointer
Go to Run -> External Tools ->Start Breakpointer
Open a browser and navigate to your project (should be at port 3000)
Once you hit your breakpoint, return to Eclipse and you should see an IRB console that you can use to inspect your local variables, objects, request data and session data.
To stop processing the breakpoint and allow the application to continue, type exit in the console. Breakpointer will begin waiting for a new breakpoint.

--------------------------------------------------------------------------------

Installing SubClipse
If you use Subversion (and you should if you're serious about Rails development) then you can install the SubClipse SubVersion client plugin.

Visit http://subclipse.tigris.org/install.html and follow their directions, or simply follow the same process as RDT and use their update site at http://subclipse.tigris.org/update

Choose Help->Software Updates->Find and Install
Choose "Search for new features to install" and select Next
Select "New Remote Site ",
Use the name “SubClipse”
Use the URL: http://subclipse.tigris.org/update
Press OK
Check SubClipse and push Next
Select the feature RDT and push Next. You should confirm any messages relating to installing unsigned plugins. RDT will be installed and be available after restart.

--------------------------------------------------------------------------------



Troubleshooting
DBEdit gives me errors when I attempt to connect to MySQL
"Fetching children of MySQL" is a common error that I've seen. It seems to be related to the version of DBEdit that you use. SourceForge isn't very helpful with the proper version; sometimes you get lucky. If you get this error, uninstall DBEdit and redownload a new version.
I used Cygwin and all the paths in your tutoral arewrong. You should change them or make a note about this.
You're on your own. This guide uses a specific method. It can easily be adapted for other uses, such as Cygwin or even Linux. However, please understand that I can't support all of those configurations. Compared to developing useful web applications, configuring these plugins should be pretty easy.
When I try to run one of the external programs, I get an error stating something about "not valid in prolog"
You probably set up all of your external apps as Ant Buids instead of programs.

The breakpointer hangs up on me... I can't exit out
Just hit the red stop button on the console to kill the breakpointer. Do the same for the console that contains WEBrick.

When I run one of the external programs, the message says "variable references empty selection"
It usually means that the project isn't selected. Just click on the project name before you run one of the programs.

I've set up SubClipse but whenever I try to open one of the SubClipse views, it says my workspace path is invalid and needs to be changed. The suggested path for the change is the same path I'm currently using!
SubClipse is picky. It wants the drive letter to be capitalized. Change your workspace path from c:javaworkspace to C:javaworkspace and restart Eclipse
Downloads
externals.zip
External Programs launchers for
Create Rails Structure in Project
Generate Model
Generate Controller
Generate Scaffold for Model and Controller
Generate Migration
Install Plugin via SVN
Rake
Start Breakpointer
Start Webrick Server
Open Explorer in Project Folder
Command Prompt
Start Console
rails-model-controller.xml
Contains code templates for various Ruby on Rails code methods. Import this into Ruby Templates
rails-rhtml.xml
Contains code templates for various Rails helpers used in views. Import into JSP Templates


--------------------------------------------------------------------------------

That about does it. I'll keep looking for other things to add to this procedure since this is the method I am now using for my development environment. If anyone has any feedback that I should add, please send it to railsdev@napcs.com

Thanks to Tom Davies for his comments regarding project locations and his tips about the Rails templates.

Thanks to Chris Williams for the information about WEBrick's output.

Thanks to everyone on the RDT team for working so hard on a great plugin.


--------------------------------------------------------------------------------

Brian Hogan is the owner of New Auburn Personal Computer Services, a small web design company that specializes in standards-based design and accessibility for the disabled. He has been developing web sites for ten years. He also works at the University of Wisconsin-Eau Claire where he oversees development of various web-based applications.


Site design and content copyright © 2003 New Auburn Personal Computer Services, All rights reserved. Unauthorized duplication or republication in any form is not allowed.

2006년 4월 17일 월요일

eclipse external Tool

Eclipse 에서 포커스가 잡혀 있는 파일 업로드시
포커스가 잡힌 파일명을 돌려주는 Arguments
${file_prompt}

2006년 4월 4일 화요일

L2,L3,L4

http://cafe.naver.com/yjk017654/221 님의 글을 퍼왔습니다.


L2스위치, L3스위치,L4스위치 |

http://cafe.naver.com/yjk017654/221

예를 들어 A에서 보낸 팻킷이 포트 1로 들어왔다고 합시다.

그러면 L2 스위치는 포트 1에 A가 붙어있다는 정보를 얻게 됩니다.

그래서 나중에 A로 보내져야할 팻킷이 들어오게 되면 포트 1로 내보내게 됩니다.

L3의 경우는 L2와 달리 매우 넓은 범위까지 다루게 됩니다.

그래서 오가는 팻킷을 관찰해서는 충분한 정보를 얻을 수가 없습니다.

그래서 L3 스위치끼리 통신을 하면서 정보를 축적하게 됩니다.

예를 들어 포트 1에 연결되어 있는 스위치가 여기에는 팻킷이 많이 몰린다는

내용을 보낸다면, 그 내용을 받은 스위치는 팻킷을 포트 1 대신 다른 포트로

보내게 됩니다.



L4스위치

여러대의 서버에 똑같은 컨텐츠를 탑재하는 경우는 L4에서 서버의 부하를 체크해서 가장

여유있다고 판단되는 쪽으로 보내게 됩니다.(정책이 여러개 있는데, 이방식을 가장 많이 사용합니다.)

일반 기업에서 ERP서버나 업무용서버를 운영할 때 많이 사용하는 방식입니다.

서버별로 컨텐츠가 다르다면, L4에서 정책을 세워서 해당 서비스에 대한 요청이 오면 등록된 서비스로

보내주어서 전체 부하를 분산시키는 방식을 사용합니다. 대형 포탈의 경우 이런 방식을 사용하겠죠.

그리고 대부분 DB서버는 L4를 거치지 않고 웹서버와 직접 연결시켜서 사용합니다. DB서버 분산하는게 쉽지 않기 때문에 DB를 L4에 물리는 경우는 드물죠.


세그먼트(segment)에 대해 설명드리면, 한 컴퓨터에서 발생한 신호가 수신자에 상관없이 전달되는 범위를 말합니다. 즉, 내 컴퓨터에서 자료를 보내려고 신호를 내보내면 이 신호가 일정 지역내의 모든 컴퓨터에게 전달이 되는데 그 범위를 말합니다. 그런데, 하나의 세그먼트에서는 동시에 2개의 신호가 전달될 수 없습니다. 예를 들면, 두사람이 동시에 자기 얘기만 하면 무슨소린지 모르고 충돌이 발생하듯이 하나의 세그먼트 내에서 동시에 2개 이상의 전기적인 신호가 발생하면 충돌이 발생합니다.
그럼, 여기서 한가지 생각해 보시면, 하나의 세그먼트가 컴퓨터 1000대로 구성이 되어 있다고 보면 1000대중에서 내 컴퓨터가 자료를 보내려고 하면 많은 시간을 기다려야 할 수도 있고, 충돌이 자주 발생할 수도 있습니다. 그래서~ 세그먼트를 분리시키고자 등장한 장비가 브리지(스위치는 브리지를 개량한 장비)입니다.
브리지(bridge)는 한마디로 요약하면 세그먼트를 분리시켜주는 장비입니다. 예를 들면 1000대의 컴퓨터를 100대씩 묶어서 10개의 세그먼트을 만들어 주는 장비 입니다. 이렇게 분리된 세그먼트에서 자료 교환을 중재하는 역할을 브리지가 하게 됩니다.
예를 들어 세그먼트1에 있는 컴퓨터가 세그먼트1에 있는 컴퓨터로(즉, 같은 세그먼트)데이터를 전송하면 이 신호가 다른 세그먼트에 전송이 되지 못하도록 신호를 차단하구요, 세그먼트1에서 세그먼트2로 데이터를 보내면 브리지가 이 신호를 받아서 세그먼트2로 보내줍니다. 이렇게 하면 세그먼트가 분리되어서 컴퓨터끼리 자료 교환하는데에 충돌이나 기다림(병목현상?)이 줄어들겠지요.
이제, 스위치와 라우터에 차이점을 설명 드리면.. 세그먼트를 분리시킨다는 의미에서는 같다고 보시면 됩니다. 차이점은.. 어떤걸 기준으로 분리를 시키느냐 입니다.
스위치에 여러가지 포트(하나의 포트를 하나의 세그먼트로 보셔도 될겁니다.)가 있는데, 각 포트에 어떤 컴퓨터가 연결이 되어 있는지 판단하는 것은 MAC(Media Access Control)주소 입니다. 간단히 말하면 LAN카드 번호 입니다. 이 번호는 공장에서 나올때부터 고유하게 지정된 번호로써 전세게 LAN카드가 다 다른 번호를 가지고 있습니다. 스위치는 이 번호를 가지고 스위치 장비 내부에 '표'를 하나 만들어 놓고, 포트1에는 어떤 MAC주소가 있으며, 포트2에는 어떤 MAC주소가 있는지 적어 놓습니다. 그래서, 이 표를 기준으로, 스위치로 들어오는 신호를 읽어 들여서 같은 포트의 MAC주소를 목적지로 하고 있으면 다른 포트로 데이터를 보내지 않고, 다른 포트의 MAC주소를 목적지 주소로 가지고 있으면 그곳으로 연결 시켜 줍니다.
라우터는 세그먼트를 구분하는 기준이 IP입니다. 라우터도 내부적으로 표를 만들어 놓는데 기준이 IP입니다. 따라서, 라우터로 들어오는 신호를 읽어들여서 목적지가 같은 포트(즉, 같은 세그먼트)의 IP이면 다른 포트로 신호를 보내지 않으며 다른 포트의 세그먼트의 컴퓨터가 목적지 IP이면 그 포트로 연결시켜 주는 역활을 합니다.
라우터의 역할을 보시면 알겠지만, IP를 기준으로 세그먼트를 나눕니다. 그래서, 인터넷과 독립적으로 LAN을 구축할 경우 라우터는 필요 없습니다. 하지만, 인터넷과 연결시켜서 LAN을 구축할 경우 반드시 필요한 장비가 라우터 입니다

2006년 3월 22일 수요일

REF CURSOR

http://www.atmarkit.co.jp/fdb/rensai/odpdotnet01/odpdotnet04.html

REF CURSOR

 REF CURSORは、OracleDataReader、DataSetまたはOracleRefCursorとして取得できます。OracleRefCursorオブジェクトとして取得されたREF CURSORは、OracleDataReaderの作成またはREF CURSORからDataSetへの移入に使用できます。REF CURSORにアクセスする際は、必ずOracleDbType.RefCursorとしてバインドします。以下にストアドプロシージャからREF CURSORを取得する方法、および DataGridオブジェクトに情報を表示する方法を説明します。

REF CURSORを使用したパッケージの作成

CREATE OR REPLACE PACKAGE SCOTT.pkg_ref AS
CURSOR c1 IS SELECT * FROM emp;
CURSOR c2 IS SELECT * FROM dept;
TYPE empCur IS REF CURSOR RETURN c1%ROWTYPE;
TYPE deptCur IS REF CURSOR RETURN c2%ROWTYPE;
PROCEDURE GetEmpDeptData(
EmpCursor in out empCur,
DeptCursor in out deptCur
);
END;
リスト18 REF CURSORを使用したパッケージ

CREATE OR REPLACE PACKAGE BODY SCOTT.pkg_ref AS
PROCEDURE GetEmpDeptData(
EmpCursor in out empCur,
DeptCursor in out deptCur) IS
BEGIN
OPEN EmpCursor FOR SELECT * FROM emp;
OPEN DeptCursor FOR SELECT * FROM dept;
END GetEmpDeptData;
END pkg_ref;
リスト19 REF CURSORを使用したパッケージ本体


ストアドプロシージャからREF CURSORを取得しDataGridオブジェクトに結果を表示するコードは以下のようになります。

Dim cmd As New OracleCommand("pkg_ref.GetEmpDeptData", cnn)
cmd.CommandType = CommandType.StoredProcedure

'REF CURSORパラメータのバインド
cmd.Parameters.Add("EmpCursor", _
OracleDbType.RefCursor, ParameterDirection.Output)
cmd.Parameters.Add("DeptCursor", _
OracleDbType.RefCursor, ParameterDirection.Output)

'SQL文の実行とRef Cursorの使用
Dim dsData As New DataSet
Dim da As New OracleDataAdapter(cmd)
da.Fill(dsData, "data")

'DataGridへ表示
DataGridEmp.SetDataBinding(dsData, "data")
DataGridDept.SetDataBinding(dsData, "data1")
リスト20 REF CURSORを取得しDataGridオブジェクトに結果を表示(VB.NET)

OracleCommand cmd =
new OracleCommand("pkg_ref.GetEmpDeptData", cnn);
cmd.CommandType = CommandType.StoredProcedure;

//REF CURSORパラメータのバインド
cmd.Parameters.Add("EmpCursor",
OracleDbType.RefCursor, ParameterDirection.Output);
cmd.Parameters.Add("DeptCursor",
OracleDbType.RefCursor, ParameterDirection.Output);

//SQL文の実行とRef Cursorの使用
DataSet dsData = new DataSet();
OracleDataAdapter da = new OracleDataAdapter(cmd);
da.Fill(dsData, "data");

//DataGridへ表示
dataGridEmp.SetDataBinding(dsData, "data");
dataGridDept.SetDataBinding(dsData, "data1");
リスト21 REF CURSORを取得しDataGridオブジェクトに結果を表示(C#)

 上記のサンプルコードでは、REF CURSORからDataSetへデータを格納していますが、OracleRefCursorオブジェクトからOracleDataReaderオブジェクトへ格納することも可能です。

Dim cmd As New OracleCommand("pkg_ref.GetEmpDeptData", cnn)
cmd.CommandType = CommandType.StoredProcedure

'REF CURSORパラメータのバインド
cmd.Parameters.Add("EmpCursor", OracleDbType.RefCursor, _
ParameterDirection.Output)
cmd.Parameters.Add("DeptCursor", OracleDbType.RefCursor, _
ParameterDirection.Output)
cmd.ExecuteNonQuery()

'SQL文の実行とREF CURSORの使用
Dim dr1 As OracleDataReader = _
CType(cmd.Parameters(0).Value, OracleRefCursor).GetDataReader
Dim dr2 As OracleDataReader = _
CType(cmd.Parameters(1).Value, OracleRefCursor).GetDataReader
リスト22 REF CURSORを取得しOracleDataReaderへ結果を格納(VB.NET)

OracleCommand cmd =
new OracleCommand("pkg_ref.GetEmpDeptData", cnn);
cmd.CommandType = CommandType.StoredProcedure;

//REF CURSORパラメータのバインド
cmd.Parameters.Add("EmpCursor", OracleDbType.RefCursor,
ParameterDirection.Output);
cmd.Parameters.Add("DeptCursor", OracleDbType.RefCursor,
ParameterDirection.Output);
cmd.ExecuteNonQuery();

//SQL文の実行とREF CURSORの使用
OracleRefCursor cur1 =
(OracleRefCursor)cmd.Parameters[0].Value;
OracleRefCursor cur2 =
(OracleRefCursor)cmd.Parameters[1].Value;
OracleDataReader dr1 = cur1.GetDataReader();
OracleDataReader dr2 = cur2.GetDataReader();
リスト23 REF CURSORを取得しOracleDataReaderへ結果を格納(C#)

2006년 3월 13일 월요일

DWR

http://cafe.naver.com/ArticleRead.nhn?clubid=10068252&menuid=&listtype=A&boardtype=L&page=&articleid=1588

code generator

http://www.codegeneration.net/
에서 괜찬은 내용 발견.
sql2java는 적용해 보고 있는중.
DB에 PK설정이 없으면 문제가 됨

유니크 키 설정을 PK설정으로 바꿔서 ant실행시 DB에 적용 코드생성
PK삭제