Search in sources :

Example 46 with UnsupportedEncodingException

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);
    }
}
Also used : TokenIdGenerationException(org.forgerock.openam.sts.TokenIdGenerationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) Token(org.forgerock.openam.cts.api.tokens.Token) PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) CTSTokenPersistenceException(org.forgerock.openam.sts.CTSTokenPersistenceException)

Example 47 with UnsupportedEncodingException

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;
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 48 with UnsupportedEncodingException

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);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException)

Example 49 with UnsupportedEncodingException

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);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

Example 50 with UnsupportedEncodingException

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);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Iterator(java.util.Iterator) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)3108 IOException (java.io.IOException)878 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)284 InputStream (java.io.InputStream)275 ArrayList (java.util.ArrayList)268 InputStreamReader (java.io.InputStreamReader)243 File (java.io.File)234 ByteArrayInputStream (java.io.ByteArrayInputStream)209 ByteArrayOutputStream (java.io.ByteArrayOutputStream)201 FileNotFoundException (java.io.FileNotFoundException)198 HashMap (java.util.HashMap)182 MessageDigest (java.security.MessageDigest)180 BufferedReader (java.io.BufferedReader)150 URL (java.net.URL)150 Map (java.util.Map)148 OutputStreamWriter (java.io.OutputStreamWriter)145 FileOutputStream (java.io.FileOutputStream)120 MalformedURLException (java.net.MalformedURLException)110 FileInputStream (java.io.FileInputStream)107 List (java.util.List)105