本文整理汇总了Java中org.xdi.oxauth.model.util.Util.isNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Util.isNullOrEmpty方法的具体用法?Java Util.isNullOrEmpty怎么用?Java Util.isNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xdi.oxauth.model.util.Util
的用法示例。
在下文中一共展示了Util.isNullOrEmpty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OxAuthCryptoProvider
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public OxAuthCryptoProvider(String keyStoreFile, String keyStoreSecret, String dnName) throws Exception {
if (!Util.isNullOrEmpty(keyStoreFile) && !Util.isNullOrEmpty(keyStoreSecret) /* && !Util.isNullOrEmpty(dnName) */) {
this.keyStoreFile = keyStoreFile;
this.keyStoreSecret = keyStoreSecret;
this.dnName = dnName;
keyStore = KeyStore.getInstance("JKS");
try {
File f = new File(keyStoreFile);
if (!f.exists()) {
keyStore.load(null, keyStoreSecret.toCharArray());
FileOutputStream fos = new FileOutputStream(keyStoreFile);
keyStore.store(fos, keyStoreSecret.toCharArray());
fos.close();
}
final InputStream is = new FileInputStream(keyStoreFile);
keyStore.load(is, keyStoreSecret.toCharArray());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
示例2: getPublicKey
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public PublicKey getPublicKey(String alias) {
PublicKey publicKey = null;
try {
if (Util.isNullOrEmpty(alias)) {
return null;
}
java.security.cert.Certificate certificate = keyStore.getCertificate(alias);
if (certificate == null) {
return null;
}
publicKey = certificate.getPublicKey();
} catch (KeyStoreException e) {
e.printStackTrace();
}
return publicKey;
}
示例3: constructPage
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
private String constructPage(Set<String> logoutUris, String postLogoutUrl, String state) {
String iframes = "";
for (String logoutUri : logoutUris) {
iframes = iframes + String.format("<iframe height=\"0\" width=\"0\" src=\"%s\"></iframe>", logoutUri);
}
String html = "<!DOCTYPE html>" +
"<html>" +
"<head>";
if (!Util.isNullOrEmpty(postLogoutUrl)) {
if (!Util.isNullOrEmpty(state)) {
if (postLogoutUrl.contains("?")) {
postLogoutUrl += "&state=" + state;
} else {
postLogoutUrl += "?state=" + state;
}
}
html += "<script>" +
"window.onload=function() {" +
"window.location='" + postLogoutUrl + "'" +
"}" +
"</script>";
}
html += "<title>Gluu Generated logout page</title>" +
"</head>" +
"<body>" +
"Logout requests sent.<br/>" +
iframes +
"</body>" +
"</html>";
return html;
}
示例4: validateLogoutUri
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public void validateLogoutUri(String logoutUri, List<String> redirectUris, ErrorResponseFactory errorResponseFactory) {
if (Util.isNullOrEmpty(logoutUri)) { // logout uri is optional so null or empty string is valid
return;
}
// preconditions
if (redirectUris == null || redirectUris.isEmpty()) {
log.error("Preconditions of logout uri validation are failed.");
throwInvalidLogoutUri(errorResponseFactory);
return;
}
try {
Set<String> redirectUriHosts = collectUriHosts(redirectUris);
URI uri = new URI(logoutUri);
if (!redirectUriHosts.contains(uri.getHost())) {
log.error("logout uri host is not within redirect_uris, logout_uri: {}, redirect_uris: {}", logoutUri, redirectUris);
throwInvalidLogoutUri(errorResponseFactory);
return;
}
if (!HTTPS.equalsIgnoreCase(uri.getScheme())) {
log.error("logout uri schema is not https, logout_uri: {}", logoutUri);
throwInvalidLogoutUri(errorResponseFactory);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throwInvalidLogoutUri(errorResponseFactory);
}
}
示例5: validatePostLogoutRedirectUri
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public String validatePostLogoutRedirectUri(String clientId, String postLogoutRedirectUri) {
boolean isBlank = Util.isNullOrEmpty(postLogoutRedirectUri);
Client client = clientService.getClient(clientId);
if (client != null) {
String[] postLogoutRedirectUris = client.getPostLogoutRedirectUris();
if (postLogoutRedirectUris != null && StringUtils.isNotBlank(postLogoutRedirectUri)) {
log.debug("Validating post logout redirect URI: clientId = {}, postLogoutRedirectUri = {}",
clientId, postLogoutRedirectUri);
for (String uri : postLogoutRedirectUris) {
log.debug("Comparing {} == {}", uri, postLogoutRedirectUri);
if (uri.equals(postLogoutRedirectUri)) {
return postLogoutRedirectUri;
}
}
} else {
// Accept Request Without post_logout_redirect_uri when One Registered
if (postLogoutRedirectUris != null && postLogoutRedirectUris.length == 1) {
return postLogoutRedirectUris[0];
}
}
}
if (!isBlank) {
errorResponseFactory.throwBadRequestException(EndSessionErrorResponseType.POST_LOGOUT_URI_NOT_ASSOCIATED_WITH_CLIENT);
}
return null;
}
示例6: getUserByDn
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
/**
* returns User by Dn
*
* @return User
*/
@Nullable
public User getUserByDn(String dn, String... returnAttributes) {
if (Util.isNullOrEmpty(dn)) {
return null;
}
return ldapEntryManager.find(User.class, dn, returnAttributes);
}
示例7: toJSONObject
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public JSONObject toJSONObject() throws JSONException {
JSONObject jsonObj = new JSONObject();
jsonObj.put(KEY_ID, kid);
jsonObj.put(KEY_TYPE, kty);
jsonObj.put(KEY_USE, use);
jsonObj.put(ALGORITHM, alg);
jsonObj.put(EXPIRATION_TIME, exp);
jsonObj.put(CURVE, crv);
if (!Util.isNullOrEmpty(n)) {
jsonObj.put(MODULUS, n);
}
if (!Util.isNullOrEmpty(e)) {
jsonObj.put(EXPONENT, e);
}
if (!Util.isNullOrEmpty(x)) {
jsonObj.put(X, x);
}
if (!Util.isNullOrEmpty(y)) {
jsonObj.put(Y, y);
}
if (x5c != null && !x5c.isEmpty()) {
jsonObj.put(CERTIFICATE_CHAIN, StringUtils.toJSONArray(x5c));
}
return jsonObj;
}
示例8: getPrivateKey
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
public PrivateKey getPrivateKey(String alias)
throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException {
if (Util.isNullOrEmpty(alias)) {
return null;
}
Key key = keyStore.getKey(alias, keyStoreSecret.toCharArray());
if (key == null) {
return null;
}
PrivateKey privateKey = (PrivateKey) key;
return privateKey;
}
示例9: getRpFrontchannelLogoutUris
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
private Set<String> getRpFrontchannelLogoutUris(Pair<SessionId, AuthorizationGrant> pair) {
final Set<String> result = Sets.newHashSet();
SessionId sessionId = pair.getFirst();
AuthorizationGrant authorizationGrant = pair.getSecond();
if (sessionId == null) {
log.error("session_id is not passed to endpoint (as cookie or manually). Therefore unable to match clients for session_id." +
"Http based html will contain no iframes.");
return result;
}
final Set<Client> clientsByDns = sessionId.getPermissionGrantedMap() != null ?
clientService.getClient(sessionId.getPermissionGrantedMap().getClientIds(true), true) :
Sets.<Client>newHashSet();
if (authorizationGrant != null) {
clientsByDns.add(authorizationGrant.getClient());
}
for (Client client : clientsByDns) {
String[] logoutUris = client.getFrontChannelLogoutUri();
if (logoutUris == null) {
continue;
}
for (String logoutUri : logoutUris) {
if (Util.isNullOrEmpty(logoutUri)) {
continue; // skip client if logout_uri is blank
}
if (client.getFrontChannelLogoutSessionRequired() != null && client.getFrontChannelLogoutSessionRequired()) {
if (logoutUri.contains("?")) {
logoutUri = logoutUri + "&sid=" + sessionId.getId();
} else {
logoutUri = logoutUri + "?sid=" + sessionId.getId();
}
}
result.add(logoutUri);
}
}
return result;
}
示例10: getJSONObject
import org.xdi.oxauth.model.util.Util; //导入方法依赖的package包/类
private JSONObject getJSONObject(Client client, boolean authorizationRequestCustomAllowedParameters) throws JSONException, StringEncrypter.EncryptionException {
JSONObject responseJsonObject = new JSONObject();
Util.addToJSONObjectIfNotNull(responseJsonObject, RegisterResponseParam.CLIENT_ID.toString(), client.getClientId());
Util.addToJSONObjectIfNotNull(responseJsonObject, CLIENT_SECRET.toString(), clientService.decryptSecret(client.getClientSecret()));
Util.addToJSONObjectIfNotNull(responseJsonObject, RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString(), client.getRegistrationAccessToken());
Util.addToJSONObjectIfNotNull(responseJsonObject, REGISTRATION_CLIENT_URI.toString(),
appConfiguration.getRegistrationEndpoint() + "?" +
RegisterResponseParam.CLIENT_ID.toString() + "=" + client.getClientId());
responseJsonObject.put(CLIENT_ID_ISSUED_AT.toString(), client.getClientIdIssuedAt().getTime() / 1000);
responseJsonObject.put(CLIENT_SECRET_EXPIRES_AT.toString(), client.getClientSecretExpiresAt() != null && client.getClientSecretExpiresAt().getTime() > 0 ?
client.getClientSecretExpiresAt().getTime() / 1000 : 0);
Util.addToJSONObjectIfNotNull(responseJsonObject, REDIRECT_URIS.toString(), client.getRedirectUris());
Util.addToJSONObjectIfNotNull(responseJsonObject, CLAIMS_REDIRECT_URIS.toString(), client.getClaimRedirectUris());
Util.addToJSONObjectIfNotNull(responseJsonObject, RESPONSE_TYPES.toString(), ResponseType.toStringArray(client.getResponseTypes()));
Util.addToJSONObjectIfNotNull(responseJsonObject, GRANT_TYPES.toString(), GrantType.toStringArray(client.getGrantTypes()));
Util.addToJSONObjectIfNotNull(responseJsonObject, APPLICATION_TYPE.toString(), client.getApplicationType());
Util.addToJSONObjectIfNotNull(responseJsonObject, CONTACTS.toString(), client.getContacts());
Util.addToJSONObjectIfNotNull(responseJsonObject, CLIENT_NAME.toString(), client.getClientName());
Util.addToJSONObjectIfNotNull(responseJsonObject, LOGO_URI.toString(), client.getLogoUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, CLIENT_URI.toString(), client.getClientUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, POLICY_URI.toString(), client.getPolicyUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, TOS_URI.toString(), client.getTosUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, JWKS_URI.toString(), client.getJwksUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, SECTOR_IDENTIFIER_URI.toString(), client.getSectorIdentifierUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, SUBJECT_TYPE.toString(), client.getSubjectType());
Util.addToJSONObjectIfNotNull(responseJsonObject, ID_TOKEN_SIGNED_RESPONSE_ALG.toString(), client.getIdTokenSignedResponseAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, ID_TOKEN_ENCRYPTED_RESPONSE_ALG.toString(), client.getIdTokenEncryptedResponseAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, ID_TOKEN_ENCRYPTED_RESPONSE_ENC.toString(), client.getIdTokenEncryptedResponseEnc());
Util.addToJSONObjectIfNotNull(responseJsonObject, USERINFO_SIGNED_RESPONSE_ALG.toString(), client.getUserInfoSignedResponseAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, USERINFO_ENCRYPTED_RESPONSE_ALG.toString(), client.getUserInfoEncryptedResponseAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, USERINFO_ENCRYPTED_RESPONSE_ENC.toString(), client.getUserInfoEncryptedResponseEnc());
Util.addToJSONObjectIfNotNull(responseJsonObject, REQUEST_OBJECT_SIGNING_ALG.toString(), client.getRequestObjectSigningAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, REQUEST_OBJECT_ENCRYPTION_ALG.toString(), client.getRequestObjectEncryptionAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, REQUEST_OBJECT_ENCRYPTION_ENC.toString(), client.getRequestObjectEncryptionEnc());
Util.addToJSONObjectIfNotNull(responseJsonObject, TOKEN_ENDPOINT_AUTH_METHOD.toString(), client.getTokenEndpointAuthMethod());
Util.addToJSONObjectIfNotNull(responseJsonObject, TOKEN_ENDPOINT_AUTH_SIGNING_ALG.toString(), client.getTokenEndpointAuthSigningAlg());
Util.addToJSONObjectIfNotNull(responseJsonObject, DEFAULT_MAX_AGE.toString(), client.getDefaultMaxAge());
Util.addToJSONObjectIfNotNull(responseJsonObject, REQUIRE_AUTH_TIME.toString(), client.getRequireAuthTime());
Util.addToJSONObjectIfNotNull(responseJsonObject, DEFAULT_ACR_VALUES.toString(), client.getDefaultAcrValues());
Util.addToJSONObjectIfNotNull(responseJsonObject, INITIATE_LOGIN_URI.toString(), client.getInitiateLoginUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, POST_LOGOUT_REDIRECT_URIS.toString(), client.getPostLogoutRedirectUris());
Util.addToJSONObjectIfNotNull(responseJsonObject, REQUEST_URIS.toString(), client.getRequestUris());
if (!Util.isNullOrEmpty(client.getJwks())) {
Util.addToJSONObjectIfNotNull(responseJsonObject, JWKS.toString(), new JSONObject(client.getJwks()));
}
// Logout params
Util.addToJSONObjectIfNotNull(responseJsonObject, FRONT_CHANNEL_LOGOUT_URI.toString(), client.getFrontChannelLogoutUri());
Util.addToJSONObjectIfNotNull(responseJsonObject, FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString(), client.getFrontChannelLogoutSessionRequired());
// Custom Params
String[] scopeNames = null;
String[] scopeDns = client.getScopes();
if (scopeDns != null) {
scopeNames = new String[scopeDns.length];
for (int i = 0; i < scopeDns.length; i++) {
Scope scope = scopeService.getScopeByDn(scopeDns[i]);
scopeNames[i] = scope.getDisplayName();
}
}
if (authorizationRequestCustomAllowedParameters) {
Util.addToJSONObjectIfNotNull(responseJsonObject, SCOPES.toString(), scopeNames);
} else {
Util.addToJSONObjectIfNotNull(responseJsonObject, SCOPE.toString(), implode(scopeNames, " "));
}
return responseJsonObject;
}