![JAR search and dependency download from the Maven repository](/logo.png)
com.hp.autonomy.hod.sso.SpringSecurityTokenProxyService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hod-sso-spring-security Show documentation
Show all versions of hod-sso-spring-security Show documentation
Library to assist with using Micro Focus Haven OnDemand SSO with Spring Security
/*
* Copyright 2015 Hewlett-Packard Development Company, L.P.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
*/
package com.hp.autonomy.hod.sso;
import com.hp.autonomy.hod.client.api.authentication.EntityType;
import com.hp.autonomy.hod.client.api.authentication.TokenType;
import com.hp.autonomy.hod.client.token.TokenProxy;
import com.hp.autonomy.hod.client.token.TokenProxyService;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
/**
* {@link TokenProxyService} which retrieves the token proxy from the Spring Security Context if the stored
* authentication is a {@link HodAuthentication}.
*/
public class SpringSecurityTokenProxyService implements TokenProxyService {
@Override
public TokenProxy getTokenProxy() {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (!(authentication instanceof HodAuthentication)) {
return null;
}
// Usage of this class requires that the application is using HodAuthentications
//noinspection unchecked
return ((HodAuthentication) authentication).getTokenProxy();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy