use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class RealmTest method createRealmTwice.
/**
* Test case for Issue #181. When a realm is deleted and created
* again, it fails with "Realm already exists".
*/
//, expectedExceptions={SMSException.class})
@Test(groups = { "api" })
public void createRealmTwice() throws SMSException, SSOException {
SSOToken adminToken = getAdminSSOToken();
OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
String realm = "sm-issue181-create-realm-twice";
ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
ocm.deleteSubOrganization(realm, true);
ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
ocm.deleteSubOrganization(realm, true);
ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
ocm.deleteSubOrganization(realm, true);
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class UmaPolicyServiceImpl method getLoggedInUserId.
private String getLoggedInUserId(Context context) throws InternalServerErrorException {
try {
SubjectContext subjectContext = context.asContext(SubjectContext.class);
SSOToken token = subjectContext.getCallerSSOToken();
return token.getPrincipal().getName();
} catch (SSOException e) {
throw new InternalServerErrorException(e);
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class RemoveRedundantDefaultApplicationTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
initMocks(this);
System.setProperty("com.iplanet.am.version", "12.0.0");
SSOToken token = mock(SSOToken.class);
given(token.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("abc");
given(ssoTokenAction.run()).willReturn(token);
upgradeStep = new RemoveRedundantDefaultApplication(asSet("app1", "app2"), applicationService, ssoTokenAction, connectionFactory);
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class TokenCleanupRunnable method run.
public void run() {
if (!runCleanup()) {
// no need to run cleanup on this instance
return;
}
CoreTokenUtils.debug.message("TokenCleanupRunnable.run : START");
Set<String> tokenSet = getAllTokens();
Iterator<String> tokens = tokenSet.iterator();
if (CoreTokenUtils.debug.messageEnabled()) {
CoreTokenUtils.debug.message("TokenCleanupRunnable.run : found " + tokenSet.size() + " tokens");
}
while (tokens.hasNext()) {
String token = tokens.next();
String dn = OpenSSOCoreTokenStore.getCoreTokenDN(token);
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
if (SMSEntry.checkIfEntryExists(dn, adminToken)) {
try {
SMSEntry s = new SMSEntry(adminToken, dn);
String tokenExpiry = getTokenExpiry(s);
if (CoreTokenUtils.isTokenExpired(tokenExpiry)) {
s.delete();
// add logging
TokenLogUtils.access(Level.INFO, TokenLogUtils.EXPIRED_TOKEN_DELETE_SUCCESS, null, null, token);
if (CoreTokenUtils.debug.messageEnabled()) {
CoreTokenUtils.debug.message("TokenCleanupRunnable" + ".run: removed expired token " + token);
}
}
} catch (SMSException ex) {
CoreTokenUtils.debug.error("TokenCleanupRunnable.run", ex);
} catch (SSOException ex) {
CoreTokenUtils.debug.error("TokenCleanupRunnable.run", ex);
} catch (CoreTokenException ce) {
CoreTokenUtils.debug.error("TokenCleanupRunnable.run", ce);
}
}
}
CoreTokenUtils.debug.message("TokenCleanupRunnable.run : END");
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class OpenSSOCoreTokenStore method updateToken.
/**
* Updates a token.
* @param subject caller subject.
* @param tokenId token.id of the token to be updated.
* @param eTag
* @param newVals
* @throws CoreTokenException
* @throws JSONException
*/
public void updateToken(Subject subject, String tokenId, String eTag, JSONObject newVals) throws CoreTokenException, JSONException {
SSOToken token = SubjectUtils.getSSOToken(subject);
if (token == null) {
throw new CoreTokenException(210, null, 401);
}
String dn = null;
try {
dn = getCoreTokenDN(tokenId);
if (SMSEntry.checkIfEntryExists(dn, token)) {
SMSEntry s = new SMSEntry(token, dn);
String tokenAttrs = getTokenAttributeValueFromSM(s, JSON_ATTR);
JSONObject json = new JSONObject(tokenAttrs);
checkETag(eTag, json, tokenId);
// validate attribute names and convert to lower case
newVals = validateAndToLowerCase(newVals);
// token.id attribute can't be modified
if (newVals.has(CoreTokenConstants.TOKEN_ID)) {
throw new CoreTokenException(221, null, 409);
}
// token.type attribute can't be modified
if (newVals.has(CoreTokenConstants.TOKEN_TYPE)) {
throw new CoreTokenException(224, null, 409);
}
json = updateAttributeValues(json, newVals);
Map<String, Set<String>> map = validateAndCreateMap(tokenId, json);
s.setAttributes(map);
s.save();
} else {
throw new CoreTokenException(203, null, 404);
}
} catch (SMSException e) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.updateToken", e);
throw new CoreTokenException(206, null, e);
} catch (SSOException e) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.updateToken", e);
throw new CoreTokenException(301, null, e);
}
}
Aggregations