All Downloads are FREE. Search and download functionalities are using the official Maven repository.

burp.msl.tokens.EchoingTokenFactory Maven / Gradle / Ivy

There is a newer version: 1.2226.0
Show newest version
/**
 * Copyright (c) 2014-2017 Netflix, Inc.  All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package burp.msl.tokens;

import java.util.Date;

import javax.crypto.SecretKey;

import com.netflix.msl.MslCryptoException;
import com.netflix.msl.MslEncodingException;
import com.netflix.msl.MslError;
import com.netflix.msl.MslException;
import com.netflix.msl.entityauth.EntityAuthenticationData;
import com.netflix.msl.io.MslObject;
import com.netflix.msl.tokens.MasterToken;
import com.netflix.msl.tokens.MockMslUser;
import com.netflix.msl.tokens.MslUser;
import com.netflix.msl.tokens.TokenFactory;
import com.netflix.msl.tokens.UserIdToken;
import com.netflix.msl.util.MslContext;

/**
 * 

This token factory accepts all tokens, creates dummy tokens, and echoes * back tokens for renewal. We must return dummy tokens even though they won't * be used because it is not acceptable to return {@code null} and response * messages will be automatically generated when responding to handshake * requests.

* * @author Wesley Miaw */ public class EchoingTokenFactory implements TokenFactory { /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#isMasterTokenRevoked(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MasterToken) */ @Override public MslError isMasterTokenRevoked(final MslContext ctx, final MasterToken masterToken) { return null; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#acceptNonReplayableId(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MasterToken, long) */ @Override public MslError acceptNonReplayableId(final MslContext ctx, final MasterToken masterToken, final long nonReplayableId) { return null; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#createMasterToken(com.netflix.msl.util.MslContext, com.netflix.msl.entityauth.EntityAuthenticationData, javax.crypto.SecretKey, javax.crypto.SecretKey, com.netflix.msl.io.MslObject) */ @Override public MasterToken createMasterToken(final MslContext ctx, final EntityAuthenticationData entityAuthData, final SecretKey encryptionKey, final SecretKey hmacKey, final MslObject issuerData) throws MslEncodingException, MslCryptoException { final Date renewalWindow = new Date(); final Date expiration = renewalWindow; final String identity = entityAuthData.getIdentity(); return new MasterToken(ctx, renewalWindow, expiration, 0, 0, issuerData, identity, hmacKey, hmacKey); } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#isMasterTokenRenewable(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MasterToken) */ @Override public MslError isMasterTokenRenewable(final MslContext ctx, final MasterToken masterToken) { return null; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#renewMasterToken(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MasterToken, javax.crypto.SecretKey, javax.crypto.SecretKey, com.netflix.msl.io.MslObject) */ @Override public MasterToken renewMasterToken(final MslContext ctx, final MasterToken masterToken, final SecretKey encryptionKey, final SecretKey hmacKey, final MslObject issuerData) { return masterToken; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#isUserIdTokenRevoked(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MasterToken, com.netflix.msl.tokens.UserIdToken) */ @Override public MslError isUserIdTokenRevoked(final MslContext ctx, final MasterToken masterToken, final UserIdToken userIdToken) { return null; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#createUserIdToken(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.MslUser, com.netflix.msl.tokens.MasterToken) */ @Override public UserIdToken createUserIdToken(final MslContext ctx, final MslUser user, final MasterToken masterToken) throws MslEncodingException, MslCryptoException { final Date renewalWindow = new Date(); final Date expiration = renewalWindow; return new UserIdToken(ctx, renewalWindow, expiration, masterToken, 0, null, user); } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#renewUserIdToken(com.netflix.msl.util.MslContext, com.netflix.msl.tokens.UserIdToken, com.netflix.msl.tokens.MasterToken) */ @Override public UserIdToken renewUserIdToken(final MslContext ctx, final UserIdToken userIdToken, final MasterToken masterToken) { return userIdToken; } /* (non-Javadoc) * @see com.netflix.msl.tokens.TokenFactory#createUser(com.netflix.msl.util.MslContext, java.lang.String) */ @Override public MslUser createUser(final MslContext ctx, final String userdata) throws MslException { try { return new MockMslUser(userdata); } catch (final Throwable t) { throw new MslException(MslError.USERIDTOKEN_USERDATA_INVALID, userdata, t); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy