|
SAP NetWeaver 7.20 (SP01) Composition Environment | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sap.security.api.ticket.TicketVerifier
public abstract class TicketVerifier
This abstract base class supplies an interface to handle and verify SAP Logon Tickets in standalone Java applications that do not use the UME or Enterprise portal integrated authentication services. Within SAP AS Java there is usually no need to use this class.
DISCLAIMER:
This class requires the "IAIK Java Cryptography Extension (IAIK-JCE)" by "Institute for Applied Information Processing and Communication" (IAIK) of the Technical University Graz.
The version delivered by SAP AG is RESTRICTED to usage inside of SAP software. If you plan to use this class in standalone applications outside of SAP software, you MUST make sure to have a respective license by IAIK. For details see http://jce.iaik.tugraz.at/products/01_jce/index.php .
In order to use it, you need the following:
Here's the minimum set of properties from the sapum.properties file:
################## # configuration ################## ##use the internal ume trace ume.trace.internal_trace=false ################################################### # new parameter. Valid as of SAP NetWeaver 2004 SP8 ################################################### login.ticket_standalone=true ############################################################################### # security parameters ############################################################################### # path of your IAIK keystore login.ticket_keystore = ticketKeyStore login.ticket_keystore_pw=<your keystore password> # Initialize Factory logonAuthenticationFactory =empty authenticationFactory =empty userMapping =empty groupFactory =empty roleFactory =empty userAccountFactory =empty objectFactory =empty principalFactory =empty userFactory =empty serviceUserFactory =empty ume.acl.manager =emptyHere's a small code snippet that demonstrates how to use this class:
// Make sure the IAIK provider is ready
IAIK.addAsProvider ();
// Get a ticketverifier object
// see information to UMFactory.getInstance() on about how to currectly
// configure the UMFactory singleton
TicketVerifier tv = UMFactory.getInstance ().getTicketVerifier ();
// read ticket (this function is only a place holder...)
// get the ticket from the http request in a servlet or something like
// this. make sure it is unescaped (replace %XX sequences by the
// corresponding ASCII character)
String ticket = getTicketAndUnescapeIt ();
// set ticket
tv.setTicket (ticket);
// use call tv.setCertificates () if you don't want
// to trust certificates in the keystore. In this
// case, you have to provide a list of certificate objects.
// Get R/3 user
String user = tv.getUser ();
// Get issuer
String issuer = tv.getSystemID ();
// Get client
String client = tv.getSystemClient ();
String portal_user=null;
String issue_instant;
int iValHours=0;
int iValMin =0;
// Get portal user
InfoUnit iu = tv.getInfoUnit (0x20);
if (iu!=null) {
// portal user is in UTF8 encoding
portal_user = iu.getString ("UTF8");
if (0!=portal_user.indexOf ("portal:"))
System.out.println ("Invalid info unit.");
else {
portal_user = portal_user.substring (7);
}
}
// Get validity stuff
iu = tv.getInfoUnit (InfoUnit.ID_CREATE_TIME);
if (iu==null) {
// This can really be handled as a serious error
throw new IllegalStateException ("Ticket doesn't contain a time stamp!!");
}
issue_instant = iu.getString (tv.getCodepage());
// Get validity
iu = tv.getInfoUnit (InfoUnit.ID_VALID_TIME);
if (iu!=null)
iValHours = iu.getInt();
// get minute validity ...
iu = tv.getInfoUnit (InfoUnit.ID_VALID_TIME_MIN);
// ... which might not be there!
if (iu!=null)
iValMin = iu.getInt();
System.out.println ("Ticket issued for R/3 user:\t" + user);
System.out.println (" issued by:\t\t" + issuer + " (" + client + ")");
if (portal_user!=null)
System.out.println(" issued for portal user:\t" + portal_user);
System.out.println (" issued at:\t\t" + issue_instant);
System.out.println (" validity period ([H..]H:MM):\t"
+ iValHours + (iValMin/10==0?":0":":") + iValMin);
| Field Summary | |
|---|---|
static int |
KEYTYPE_DER
id for a DER encoded certificate. |
static int |
KEYTYPE_IKS
id for IAIK keystore. |
static int |
KEYTYPE_P12
id for a P12 file storing certificates and keys. |
static int |
KEYTYPE_P7C
id for a pkcs\#7 encoded list of certificates. |
static int |
KEYTYPE_PSE
Currently not used. |
static int |
KEYTYPE_SUN
id for the standard SUN JKS keystore. |
protected int |
state
State of the Ticket. |
protected static int |
STATE_INITIALIZED
|
protected static int |
STATE_START
|
protected static int |
STATE_VERIFIED
|
| Constructor Summary | |
|---|---|
TicketVerifier()
|
|
| Method Summary | |
|---|---|
static X509Certificate |
findCertificate(X509Certificate[] certs,
String issuer,
BigInteger serial)
Deprecated. This method will be removed in the next release. Use findCertificates(java.security.cert.X509Certificate[], String, BigInteger)
as replacement. |
static X509Certificate[] |
findCertificates(X509Certificate[] certificates,
String issuer,
BigInteger serial)
Utility method. |
protected X509Certificate[] |
getCertsFromKeyStore(KeyStore store)
For internal use only. |
abstract String |
getCodepage()
Gets the SAP codepage used within this ticket. |
abstract InfoUnit |
getInfoUnit(int id)
Get the content of the InfoUnit id
(or null if no such Unit exists). |
abstract Enumeration |
getInfoUnits()
Get an Enumeration of all (unidentified) InfoUnits. |
abstract X509Certificate |
getSignerCert()
Get the Certificate used to verify the Signature. |
abstract iaik.x509.X509Certificate |
getSignerCertificate()
Deprecated. This method will be removed in the next release. Use getSignerCert() instead. |
abstract String |
getSystemClient()
Get the client of the Ticket-issuing System. |
abstract String |
getSystemID()
Get the ID of the Ticket-issuing System. |
abstract String |
getTicket()
Returns the ticket string this object has been fed with. |
abstract String |
getUser()
Get the name of the User. |
boolean |
isEnforceVerify()
|
boolean |
isValid()
Test if Ticket is valid This method verifies the ticket (using the certificates supplied by setCertificates(String, char[]) or
setCertificates(java.security.cert.X509Certificate[])) and checks
whether it is expired or not. |
abstract void |
setCertificates(String keyStoreName,
char[] pass)
Set the Certificates used to verify the Signatures. |
abstract void |
setCertificates(X509Certificate[] certs)
Set a list of X.509 certificates as trusted ticket issuers. |
void |
setEnforceVerify(boolean val)
If set to true, the Ticket MUST be verfied before
the attributes User, System and InfoUnits can be accessed
(default=true). |
abstract void |
setTicket(byte[] ticket)
Set the raw ticket. |
abstract void |
setTicket(String base64string)
Initialize the Ticket with a base64 encoded String. |
String |
toString()
Returns a string representation of this ticket. |
abstract void |
verify()
Verify the ticket. |
static boolean |
verifyCertificate(X509Certificate[] certs,
X509Certificate test,
boolean verifyChain)
Deprecated. The method is not used any more. The chain of the ticket signing certificate must not be verified. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int STATE_START
protected static final int STATE_INITIALIZED
protected static final int STATE_VERIFIED
public static final int KEYTYPE_IKS
public static final int KEYTYPE_SUN
public static final int KEYTYPE_PSE
public static final int KEYTYPE_P12
public static final int KEYTYPE_DER
public static final int KEYTYPE_P7C
protected int state
The TicketVerifier has three possible states:
STATE_START
setTicket(byte[]) or
setTicket(String),
the state changes to STATE_INITIALIZED
STATE_VERIFIED.
| Constructor Detail |
|---|
public TicketVerifier()
| Method Detail |
|---|
public abstract void setTicket(String base64string)
throws Exception
base64string - Ticket string. Can be retrieved from
a servlet request, for instance.
Exception - in case of a parsing error.
public abstract void setTicket(byte[] ticket)
throws Exception
ticket - is the ticket after applying the base64 decode
Exception - in case a parsing error occurs.public abstract String getCodepage()
public abstract String getTicket()
throws TicketException
TicketException - thrown in case the state is not at least
initialized (by a call to setTicket(String), for instance).
public abstract String getUser()
throws TicketException
TicketException - in one of the two cases:
setTicket(String) has
not been called before).
verify()) and setEnforceVerify(boolean)
has been called before (this requires successful verification prior to
this call)
t.setEnforceVerify(true);
and t.verify() throws an exception.
public abstract String getSystemID()
throws TicketException
login.ticket_issuer.
TicketException - - as in getTicket().
public abstract String getSystemClient()
throws TicketException
login.ticket_client.
TicketException - - as in getTicket().
public abstract InfoUnit getInfoUnit(int id)
throws TicketException
id
(or null if no such Unit exists). A list of possible ids is
available at InfoUnit
id or null
if this info unit does not exist in the ticket.
TicketException - - as in getTicket().
public abstract Enumeration getInfoUnits()
throws TicketException
TicketException - - as in getTicket().public String toString()
toString in class Objectpublic abstract void setCertificates(X509Certificate[] certs)
certs - list of certificates that is trusted for the verification. For
an example how to get such a list, see
the example.
public abstract void setCertificates(String keyStoreName,
char[] pass)
throws Exception
keyStoreName - The Name of the KeyStore file.pass - The Password used to access the Keystore.
Exception
public abstract iaik.x509.X509Certificate getSignerCertificate()
throws TicketException
getSignerCert() instead.
TicketException - - same as in getTicket().
public abstract X509Certificate getSignerCert()
throws TicketException
TicketException - - same as in getTicket().
protected X509Certificate[] getCertsFromKeyStore(KeyStore store)
throws KeyStoreException
KeyStoreExceptionpublic boolean isValid()
setCertificates(String, char[]) or
setCertificates(java.security.cert.X509Certificate[])) and checks
whether it is expired or not. To get more specific information in the case of failure,
call verify().
true if all checks are ok.verify()
public abstract void verify()
throws CertificateException,
NoSuchAlgorithmException,
InvalidKeyException,
NoSuchProviderException,
SignatureException,
CertificateExpiredException,
CertificateNotYetValidException,
TicketException,
Exception
state = STATE_VERIFIED.
NoSuchAlgorithmException
NoSuchProviderException - Improper Provider configuration. All used
algorithms (per default SHA1 and DSA) need
to be available.
SignatureException - A problem with the signature
InvalidKeyException - The keys are not ok, wrong algorithm, for instance.
TicketException - can be caused by various errors.
CertificateNotYetValid
CertificateExpiredException - Only there for backward compatibility reasons.
CertificateException
CertificateNotYetValidException
Exceptionpublic void setEnforceVerify(boolean val)
true, the Ticket MUST be verfied before
the attributes User, System and InfoUnits can be accessed
(default=true).
public boolean isEnforceVerify()
public static X509Certificate findCertificate(X509Certificate[] certs,
String issuer,
BigInteger serial)
findCertificates(java.security.cert.X509Certificate[], String, BigInteger)
as replacement.
public static X509Certificate[] findCertificates(X509Certificate[] certificates,
String issuer,
BigInteger serial)
public static boolean verifyCertificate(X509Certificate[] certs,
X509Certificate test,
boolean verifyChain)
certs - Array of trusted certificates.test - Certificate to be verified.verifyChain - If this parameter is true the method
continues verifing until a self-signed Certificate is found
as root.
true if verification is successful.| Access Rights |
|---|
| SC | DC |
|---|---|
[sap.com] ENGINEAPI
|
[sap.com] com.sap.security.api.sda
|
[sap.com] ENGFACADE
|
[sap.com] tc/je/usermanagement/api
|
[sap.com] CORE-TOOLS
|
[sap.com] com.sap.engine.client.lib
|
|
SAP NetWeaver 7.20 (SP01) Composition Environment | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||