KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > security > sas > GSSUPMechFactory


1 package org.jacorb.security.sas;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 2002-2004 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.security.Provider JavaDoc;
24
25 import org.ietf.jgss.GSSException JavaDoc;
26 import org.ietf.jgss.GSSName JavaDoc;
27 import org.ietf.jgss.Oid JavaDoc;
28
29 import sun.security.jgss.spi.GSSContextSpi;
30 import sun.security.jgss.spi.GSSCredentialSpi;
31 import sun.security.jgss.spi.GSSNameSpi;
32 import sun.security.jgss.spi.MechanismFactory;
33
34 /**
35  * This is the GSS-API Sercurity Provider Interface (SPI) Facotry GSSUP GSSManager
36  *
37  * @author David Robison
38  * @version $Id: GSSUPMechFactory.java,v 1.10 2004/05/07 13:08:29 david.robison Exp $
39  */

40
41 public final class GSSUPMechFactory
42     implements MechanismFactory
43 {
44
45     protected static Provider JavaDoc myProvider;
46
47     private Oid JavaDoc myMechOid;
48     private Oid JavaDoc[] nameTypes =
49        new Oid JavaDoc[] {GSSName.NT_EXPORT_NAME};
50
51     public GSSUPMechFactory ()
52     {
53         try
54         {
55             myMechOid = new Oid JavaDoc("2.23.130.1.1.1");
56         }
57         catch (GSSException JavaDoc e)
58         {
59             // logger.error("GSSUPMechanism: " + e);
60
}
61     }
62
63     public Oid JavaDoc getMechanismOid()
64     {
65         return myMechOid;
66     }
67
68     public Provider JavaDoc getProvider()
69     {
70         return myProvider;
71     }
72
73     public Oid JavaDoc[] getNameTypes()
74     {
75         return nameTypes;
76     }
77
78     public GSSCredentialSpi getCredentialElement(GSSNameSpi name, int initLifetime, int acceptLifetime, int usage) throws GSSException JavaDoc
79     {
80         return new GSSUPCredentialSpi(myProvider, myMechOid, name, initLifetime, acceptLifetime, usage);
81     }
82
83     public GSSNameSpi getNameElement(String JavaDoc name, Oid JavaDoc nameTypeOid) throws GSSException JavaDoc
84     {
85         return getNameElement(name.getBytes(), nameTypeOid);
86     }
87
88     public GSSNameSpi getNameElement(byte[] name ,Oid JavaDoc nameTypeOid) throws GSSException JavaDoc
89     {
90         return new GSSUPNameSpi(myProvider, myMechOid, name, nameTypeOid);
91     }
92
93     public GSSContextSpi getMechanismContext(GSSNameSpi nameSpi, GSSCredentialSpi credSpi, int lifetime) throws GSSException JavaDoc
94     {
95         return new GSSUPContextSpi(myProvider, myMechOid, nameSpi, credSpi, lifetime);
96     }
97
98     public GSSContextSpi getMechanismContext(GSSCredentialSpi credSpi) throws GSSException JavaDoc
99     {
100         return new GSSUPContextSpi(credSpi.getProvider(), credSpi.getMechanism(), credSpi.getName(), credSpi, credSpi.getInitLifetime());
101     }
102
103     public GSSContextSpi getMechanismContext(byte[] b1) throws GSSException JavaDoc
104     {
105         return null;
106     }
107 }
108
Popular Tags