FileDocCategorySizeDatePackage
SecurityContextTokenInfoImpl.javaAPI DocExample7581Tue May 29 16:56:52 BST 2007com.sun.xml.ws.security.secconv.impl

SecurityContextTokenInfoImpl

public class SecurityContextTokenInfoImpl extends Object implements com.sun.xml.ws.security.SecurityContextTokenInfo
The SecurityContextTokenInfo class represents security parameters which will be saved in the Session object so that whenever the endpoint crashes the security negotiations can be resumed from its original state and no new negotiations need to be done.
author
Manveen Kaur (manveen.kaur@sun.com)

Fields Summary
String
identifier
String
extId
byte[]
secret
Map
secretMap
Date
creationTime
Date
expirationTime
private static com.sun.xml.ws.security.secconv.WSSCElementFactory
factory
Constructors Summary
public SecurityContextTokenInfoImpl()

    
    // default constructor
      
        //empty constructor
    
Methods Summary
public voidaddInstance(java.lang.String instance, byte[] key)

        byte [] newKey = new byte[key.length];
        System.arraycopy(key,0,newKey,0,key.length);
        if (instance == null) {
            this.secret = newKey;
        } else {
            secretMap.put(instance, newKey);
        }
    
private com.sun.xml.ws.security.trust.elements.str.SecurityTokenReferencecreateSecurityTokenReference(java.lang.String id, boolean unattached)

        final String uri = (unattached?id:"#"+id);
        final Reference ref = factory.createDirectReference(WSSCConstants.SECURITY_CONTEXT_TOKEN_TYPE, uri);
        return factory.createSecurityTokenReference(ref);
    
public java.util.DategetCreationTime()

        return new Date(creationTime.getTime());
    
public java.util.DategetExpirationTime()

        return new Date(expirationTime.getTime());
    
public java.lang.StringgetExternalId()

        return extId;
    
public java.lang.StringgetIdentifier()

        return identifier;
    
public java.util.SetgetInstanceKeys()

      return null;
// TBD   
      //return secretMap.keySet();
    
public byte[]getInstanceSecret(java.lang.String instance)

        return secretMap.get(instance);
    
public com.sun.xml.ws.security.IssuedTokenContextgetIssuedTokenContext()

        
        final IssuedTokenContext itc = new IssuedTokenContextImpl();
        itc.setCreationTime(this.getCreationTime());
        itc.setExpirationTime(this.getExpirationTime());
        itc.setProofKey(this.getSecret());
        itc.setSecurityContextTokenInfo(this);
        
        // create security token based on id and extId
        URI uri = URI.create(this.getIdentifier());
        
        final SecurityContextToken token = factory.createSecurityContextToken(
                uri, null , this.getExternalId());
        itc.setSecurityToken(token);
        
        // Create references
        final SecurityTokenReference attachedReference = createSecurityTokenReference(token.getWsuId(),false);
        //RequestedAttachedReference rar = factory.createRequestedAttachedReference(attachedReference);
        final SecurityTokenReference unattachedRef = createSecurityTokenReference(token.getIdentifier().toString(), true);
        //RequestedUnattachedReference rur = factory.createRequestedUnattachedReference(unattachedRef);
        
        itc.setAttachedSecurityTokenReference(attachedReference);
        itc.setUnAttachedSecurityTokenReference(unattachedRef);
        
        return itc;
    
public com.sun.xml.ws.security.IssuedTokenContextgetIssuedTokenContext(com.sun.xml.ws.security.SecurityTokenReference reference)

        // get str id -> get Session corresponding to id
        // from session get corresponding SCTInfo ->
        // return sctinfo's IssuedTokenContext.
        final String id = reference.getId();
        final Session session =
                SessionManager.getSessionManager().getSession(id);
        return session.getSecurityInfo().getIssuedTokenContext();
    
public byte[]getSecret()

        byte [] newSecret = new byte[secret.length];
        System.arraycopy(secret,0,newSecret,0,secret.length);
        return newSecret;
    
public voidsetCreationTime(java.util.Date creationTime)

        this.creationTime = new Date(creationTime.getTime());
    
public voidsetExpirationTime(java.util.Date expirationTime)

        this.expirationTime = new Date(expirationTime.getTime());
    
public voidsetExternalId(java.lang.String externalId)

        this.extId = externalId;
    
public voidsetIdentifier(java.lang.String identifier)

        this.identifier = identifier;