use of com.ibm.websphere.security.WSSecurityException in project iaf by ibissource.
the class SsoUtil method getSsoToken.
public static String getSsoToken() throws WSSecurityException, CredentialDestroyedException, CredentialExpiredException {
String result = null;
Subject subj = WSSubject.getCallerSubject();
if (subj == null) {
throw new WSSecurityException("could not find Subject");
}
Set pubs = subj.getPublicCredentials();
if (pubs == null) {
throw new WSSecurityException("could not find PublicCredentials");
}
for (Iterator it = pubs.iterator(); result == null && it.hasNext(); ) {
Object pc = it.next();
if (pc instanceof WSCredentialImpl) {
WSCredentialImpl wsci = (WSCredentialImpl) pc;
byte[] token = wsci.getCredentialToken();
if (token != null && token.length > 0) {
result = Base64.encodeBase64String(token);
}
}
}
return result;
}
Aggregations