@Override protected boolean validateCredential(IdentityContext context, CredentialStorage credentialStorage, V credentials, S store) { Token token = credentials.getToken(); if (getTokenConsumer(token) != null) { return getTokenConsumer(token).validate(token); } if (credentialStorage != null) { TokenCredentialStorage tokenCredentialStorage = (TokenCredentialStorage) credentialStorage; if (tokenCredentialStorage.getToken().equals(token.getToken()) && tokenCredentialStorage.getType().equals(token.getType())) { return true; } } return false; }
/** * <p>Issues a token for a previously authenticated {@link org.picketlink.idm.model.Account} using the * configured {@link org.picketlink.idm.credential.Token.Provider}.</p> * * @param request * @param response */ protected String issueToken(HttpServletRequest request, HttpServletResponse response) { Provider tokenProvider = getTokenProvider(); if (tokenProvider == null) { throw new AuthenticationException("No " + Provider.class.getName() + " was found."); } return tokenProvider.issue(getIdentity().getAccount()).getToken(); }
@Override protected Account getAccount(IdentityContext context, V credentials) { Token token = credentials.getToken(); if (token != null) { String subject = token.getSubject(); if (subject == null) { throw new IdentityManagementException("No subject returned from token [" + token + "]."); } Account account = getAccount(context, subject); if (account == null) { account = getAccountById(context, subject); } return account; } return null; }
/** * <p>Issues a token for a previously authenticated {@link org.picketlink.idm.model.Account} using the * configured {@link org.picketlink.idm.credential.Token.Provider}.</p> * * @param request * @param response */ protected String issueToken(HttpServletRequest request, HttpServletResponse response) { Provider tokenProvider = getTokenProvider(); if (tokenProvider == null) { throw new AuthenticationException("No " + Provider.class.getName() + " was found."); } return tokenProvider.issue(getIdentity().getAccount()).getToken(); }
@Override protected Account getAccount(IdentityContext context, V credentials) { Token token = credentials.getToken(); if (token != null) { String subject = token.getSubject(); if (subject == null) { throw new IdentityManagementException("No subject returned from token [" + token + "]."); } Account account = getAccount(context, subject); if (account == null) { account = getAccountById(context, subject); } return account; } return null; }
@Override protected boolean validateCredential(IdentityContext context, CredentialStorage credentialStorage, V credentials, S store) { Token token = credentials.getToken(); if (getTokenConsumer(token) != null) { return getTokenConsumer(token).validate(token); } if (credentialStorage != null) { TokenCredentialStorage tokenCredentialStorage = (TokenCredentialStorage) credentialStorage; if (tokenCredentialStorage.getToken().equals(token.getToken()) && tokenCredentialStorage.getType().equals(token.getType())) { return true; } } return false; }
/** * <p>Issues a token for a previously authenticated {@link org.picketlink.idm.model.Account} using the * configured {@link org.picketlink.idm.credential.Token.Provider}.</p> * * @param request * @param response */ protected String issueToken(HttpServletRequest request, HttpServletResponse response) { Provider tokenProvider = getTokenProvider(); if (tokenProvider == null) { throw new AuthenticationException("No " + Provider.class.getName() + " was found."); } return tokenProvider.issue(getIdentity().getAccount()).getToken(); }
@Override public CredentialStorage createCredentialStorage(IdentityContext context, Account account, U credential, S store, Date effectiveDate, Date expiryDate) { TokenCredentialStorage tokenStorage = createCredentialStorageInstance(); tokenStorage.setType(credential.getType()); tokenStorage.setToken(credential.getToken()); if (effectiveDate != null) { tokenStorage.setEffectiveDate(effectiveDate); } if (tokenStorage.getExpiryDate() == null) { tokenStorage.setExpiryDate(expiryDate); } if (tokenStorage.getType() == null) { throw new IdentityManagementException("TokenCredentialStorage can not have a null type."); } return tokenStorage; }
@Override public <I extends IdentityType> I extractIdentity(T token, Class<I> identityType, StereotypeProperty.Property stereotypeProperty, Object identifier) { if (token == null || token.getToken() == null) { throw MESSAGES.nullArgument("Token"); } if (identityType == null) { throw MESSAGES.nullArgument("IdentityType"); } if (stereotypeProperty == null) { throw MESSAGES.nullArgument("Identifier value"); } if (identifier == null) { throw MESSAGES.nullArgument("Identifier value"); } return extractIdentityTypeFromToken(token, identityType, stereotypeProperty, identifier); }
@Override public CredentialStorage createCredentialStorage(IdentityContext context, Account account, U credential, S store, Date effectiveDate, Date expiryDate) { TokenCredentialStorage tokenStorage = createCredentialStorageInstance(); tokenStorage.setType(credential.getType()); tokenStorage.setToken(credential.getToken()); if (effectiveDate != null) { tokenStorage.setEffectiveDate(effectiveDate); } if (tokenStorage.getExpiryDate() == null) { tokenStorage.setExpiryDate(expiryDate); } if (tokenStorage.getType() == null) { throw new IdentityManagementException("TokenCredentialStorage can not have a null type."); } return tokenStorage; }
@Override public <I extends IdentityType> I extractIdentity(T token, Class<I> identityType, StereotypeProperty.Property stereotypeProperty, Object identifier) { if (token == null || token.getToken() == null) { throw MESSAGES.nullArgument("Token"); } if (identityType == null) { throw MESSAGES.nullArgument("IdentityType"); } if (stereotypeProperty == null) { throw MESSAGES.nullArgument("Identifier value"); } if (identifier == null) { throw MESSAGES.nullArgument("Identifier value"); } return extractIdentityTypeFromToken(token, identityType, stereotypeProperty, identifier); }