use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.
the class CTSTokenPersistenceImpl method persistToken.
@Override
public void persistToken(String stsId, TokenType tokenType, String tokenString, String subjectId, long issueInstantMillis, long tokenLifetimeSeconds) throws CTSTokenPersistenceException {
try {
final String tokenId = ctsTokenIdGenerator.generateTokenId(tokenType, tokenString);
final Token ctsToken = generateToken(stsId, tokenString.getBytes(AMSTSConstants.UTF_8_CHARSET_ID), tokenId, subjectId, issueInstantMillis, tokenLifetimeSeconds, tokenType);
ctsPersistentStore.create(ctsToken);
} catch (TokenIdGenerationException e) {
throw new CTSTokenPersistenceException(e.getCode(), "Exception caught generating id for CTS-persisted " + tokenType + " token: " + e.getMessage(), e);
} catch (UnsupportedEncodingException e) {
throw new CTSTokenPersistenceException(ResourceException.INTERNAL_ERROR, "Exception caught getting byte[] " + "representation of issued " + tokenType + " token for CTS persistence: " + e, e);
} catch (CoreTokenException e) {
throw new CTSTokenPersistenceException(ResourceException.INTERNAL_ERROR, "Exception caught persisting issued " + tokenType + " token in the CTS: " + e.getMessage(), e);
}
}
use of java.io.UnsupportedEncodingException in project opensmpp by OpenSmpp.
the class ByteBuffer method removeString.
public String removeString(int size, String encoding) throws NotEnoughDataInByteBufferException, UnsupportedEncodingException {
int len = length();
if (len < size) {
throw new NotEnoughDataInByteBufferException(len, size);
}
UnsupportedEncodingException encodingException = null;
String result = null;
if (len > 0) {
try {
if (encoding != null) {
result = new String(buffer, 0, size, encoding);
} else {
result = new String(buffer, 0, size);
}
} catch (UnsupportedEncodingException e) {
debug.write("Unsupported encoding exception " + e);
event.write(e, null);
encodingException = e;
}
removeBytes0(size);
} else {
result = new String("");
}
if (encodingException != null) {
throw encodingException;
}
return result;
}
use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.
the class Notifier method run.
public void run() {
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
Set<String> serverURLs = ServerConfiguration.getServerInfo(adminToken);
for (String url : serverURLs) {
int idx = url.indexOf("|");
if (idx != -1) {
url = url.substring(0, idx);
}
if (sitemonitorDisabled || !url.equals(currentServerInstance)) {
String strURL = url + NotificationServlet.CONTEXT_PATH + "/" + action;
StringBuilder buff = new StringBuilder();
boolean bFirst = true;
for (String k : params.keySet()) {
if (bFirst) {
bFirst = false;
} else {
buff.append("&");
}
buff.append(URLEncoder.encode(k, "UTF-8")).append("=").append(URLEncoder.encode(params.get(k), "UTF-8"));
}
for (int i = 0; i < NUM_RETRY; i++) {
if (postRequest(strURL, buff.toString())) {
break;
} else {
try {
Thread.sleep(WAIT_BETWEEN_RETRY);
} catch (InterruptedException ex) {
//DO NOTHING
}
}
}
}
}
} catch (UnsupportedEncodingException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (IOException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("Notifier.notifyChanges", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("DataStore.notifyChanges", ex);
}
}
use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.
the class FilesRepo method getBinaryAttributes.
/*
* (non-Javadoc)
*
* @see com.sun.identity.idm.IdRepo#getBinaryAttributes(
* com.iplanet.sso.SSOToken, com.sun.identity.idm.IdType,
* java.lang.String, java.util.Set)
*/
public Map getBinaryAttributes(SSOToken token, IdType type, String name, Set attrNames) throws IdRepoException, SSOException {
Map stringAttributes = getAttributes(token, type, name, attrNames);
Map binaryAttributes = new HashMap();
for (Iterator items = stringAttributes.keySet().iterator(); items.hasNext(); ) {
String attrName = (String) items.next();
Set values = (Set) stringAttributes.get(attrName);
byte[][] binValues = new byte[values.size()][];
int i = 0;
try {
for (Iterator it = values.iterator(); it.hasNext(); i++) {
binValues[i] = ((String) it.next()).getBytes("UTF-8");
}
} catch (UnsupportedEncodingException e) {
// Ignore the exception
}
binaryAttributes.put(attrName, binValues);
}
return (binaryAttributes);
}
use of java.io.UnsupportedEncodingException in project OpenAM by OpenRock.
the class FilesRepo method setBinaryAttributes.
/*
* (non-Javadoc)
*
* @see com.sun.identity.idm.IdRepo#setBinaryAttributes(
* com.iplanet.sso.SSOToken, com.sun.identity.idm.IdType,
* java.lang.String, java.util.Map, boolean)
*/
public void setBinaryAttributes(SSOToken token, IdType type, String name, Map attributes, boolean isAdd) throws IdRepoException, SSOException {
if (attributes == null) {
return;
}
// Convert byte[][] attributes values to Set and save it
Map attrs = new HashMap();
for (Iterator items = attributes.keySet().iterator(); items.hasNext(); ) {
String attrName = (String) items.next();
byte[][] attrBytes = (byte[][]) attributes.get(attrName);
Set attrValues = new HashSet();
int size = attrBytes.length;
try {
for (int i = 0; i < size; i++) {
attrValues.add(new String(attrBytes[i], "UTF-8"));
}
} catch (UnsupportedEncodingException e) {
// Ignore the exception
}
attrs.put(attrName, attrValues);
}
setAttributes(token, type, name, attrs, isAdd);
}
Aggregations