/** * Constructs a PasswordCredential with the specified password. * @param password the specified password */ public PasswordCredential(char[] password) { _password = password; _mask = mask(); }
private boolean isClientAuthenticationProvided(SecurityContext securityContext) { Set<PrincipalCredential> creds = securityContext.getCredentials(PrincipalCredential.class); for (PrincipalCredential cred : creds) { if (cred.getPrincipal() != null && cred.isTrusted()) { return true; } } return false; }
private boolean isConfidentialityProvided(SecurityContext securityContext) { Set<ConfidentialityCredential> creds = securityContext.getCredentials(ConfidentialityCredential.class); for (ConfidentialityCredential cred : creds) { if (cred.isConfidential()) { return true; } } return false; }
if (source != null) { if (source.isSecure()) { credentials.add(new ConfidentialityCredential(true)); Principal userPrincipal = request.getUserPrincipal(); if (userPrincipal != null) { credentials.add(new PrincipalCredential(userPrincipal, true)); credentials.add(new PrincipalCredential(new UserPrincipal(remoteUser), true)); ahce = new AuthorizationHeaderCredentialExtractor(charsetName); } else { ahce = new AuthorizationHeaderCredentialExtractor(); credentials.addAll(ahce.extract(request.getHeader("Authorization"))); X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate"); if (certs != null) { credentials.add(new CertificateCredential(certs[0]));
/** * {@inheritDoc} */ @Override public Set<Credential> extract(SSLSession source) { Set<Credential> credentials = new HashSet<Credential>(); try { credentials.add(new ConfidentialityCredential(source.isValid())); credentials.add(new PrincipalCredential(source.getPeerPrincipal())); credentials.add(new CertificateCredential(source.getPeerCertificates()[0])); } catch (SSLPeerUnverifiedException e) { throw BaseSecurityMessages.MESSAGES.unableToExtractCredentials(e.getMessage(), e); } return credentials; }
/** * {@inheritDoc} */ @Override public Set<Credential> extract(WebServiceContext source) { Set<Credential> credentials = new HashSet<Credential>(); if (source != null) { Principal userPrincipal = source.getUserPrincipal(); if (userPrincipal != null) { credentials.add(new PrincipalCredential(userPrincipal, true)); } } return credentials; }
/** * {@inheritDoc} */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { Set<Credential> credentials = getCredentials(); if (credentials == null) { throw BaseSecurityMessages.MESSAGES.credentialsNotSet(); } for (Callback cb : callbacks) { if (cb instanceof NameCallback) { for (Credential cred : credentials) { if (cred instanceof NameCredential) { ((NameCallback)cb).setName(((NameCredential)cred).getName()); } } } else if (cb instanceof PasswordCallback) { for (Credential cred : credentials) { if (cred instanceof PasswordCredential) { ((PasswordCallback)cb).setPassword(((PasswordCredential)cred).getPassword()); } } } } }
private void extractBasic(String source, Set<Credential> credentials) { String encoded = source.substring(6, source.length()); String decoded = Base64.decodeToString(encoded, _charset); if (decoded.indexOf(':') != -1) { String[] split = decoded.split(":", 2); String name = split.length > 0 ? split[0] : null; if (name != null) { credentials.add(new NameCredential(name)); } String password = split.length > 1 ? split[1] : null; if (password != null) { credentials.add(new PasswordCredential(password)); } } }
/** * {@inheritDoc} */ @Override public void populate(ServiceSecurity serviceSecurity, SecurityContext securityContext) { String securityDomain = serviceSecurity.getSecurityDomain(); Subject toSubject = securityContext.getSubject(securityDomain); Set<SubjectCredential> subjectCredentials = securityContext.getCredentials(SubjectCredential.class); for (SubjectCredential subjectCredential : subjectCredentials) { Subject fromSubject = subjectCredential.getSubject(); transfer(fromSubject, toSubject); } }
private void extractAuthorizationToken(String source, Set<Credential> credentials) { source = source.trim(); int space = source.indexOf(' '); if (space != -1) { String schema = source.substring(0, space); String token = source.substring(space+1, source.length()); credentials.add(new AuthorizationTokenCredential(schema, token)); } } }
/** * {@inheritDoc} */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { Set<Credential> credentials = getCredentials(); if (credentials == null) { throw JBossSecurityMessages.MESSAGES.credentialsNotSet(); } for (Callback cb : callbacks) { if (cb instanceof TokenCallback) { for (Credential cred : credentials) { if (cred instanceof AssertionCredential) { ((TokenCallback)cb).setToken(((AssertionCredential)cred).getAssertion()); } } } } }
/** * {@inheritDoc} */ @Override public Set<Credential> extract(SSLSession source) { Set<Credential> credentials = new HashSet<Credential>(); try { credentials.add(new ConfidentialityCredential(source.isValid())); credentials.add(new PrincipalCredential(source.getPeerPrincipal())); credentials.add(new CertificateCredential(source.getPeerCertificates()[0])); } catch (SSLPeerUnverifiedException e) { throw BaseSecurityMessages.MESSAGES.unableToExtractCredentials(e.getMessage(), e); } return credentials; }
/** * {@inheritDoc} */ @Override public Set<Credential> extract(WebServiceContext source) { Set<Credential> credentials = new HashSet<Credential>(); if (source != null) { Principal userPrincipal = source.getUserPrincipal(); if (userPrincipal != null) { credentials.add(new PrincipalCredential(userPrincipal, true)); } } return credentials; }
private boolean isClientAuthenticationProvided(SecurityContext securityContext) { Set<PrincipalCredential> creds = securityContext.getCredentials(PrincipalCredential.class); for (PrincipalCredential cred : creds) { if (cred.getPrincipal() != null && cred.isTrusted()) { return true; } } return false; }
/** * {@inheritDoc} */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { Set<Credential> credentials = getCredentials(); if (credentials == null) { throw BaseSecurityMessages.MESSAGES.credentialsNotSet(); } for (Callback cb : callbacks) { if (cb instanceof NameCallback) { for (Credential cred : credentials) { if (cred instanceof NameCredential) { ((NameCallback)cb).setName(((NameCredential)cred).getName()); } } } else if (cb instanceof PasswordCallback) { for (Credential cred : credentials) { if (cred instanceof PasswordCredential) { ((PasswordCallback)cb).setPassword(((PasswordCredential)cred).getPassword()); } } } } }
/** * Constructs a PasswordCredential with the specified password. * @param password the specified password */ public PasswordCredential(char[] password) { _password = password; _mask = mask(); }
private boolean isConfidentialityProvided(SecurityContext securityContext) { Set<ConfidentialityCredential> creds = securityContext.getCredentials(ConfidentialityCredential.class); for (ConfidentialityCredential cred : creds) { if (cred.isConfidential()) { return true; } } return false; }
/** * {@inheritDoc} */ @Override public void populate(ServiceSecurity serviceSecurity, SecurityContext securityContext) { String securityDomain = serviceSecurity.getSecurityDomain(); Subject toSubject = securityContext.getSubject(securityDomain); Set<SubjectCredential> subjectCredentials = securityContext.getCredentials(SubjectCredential.class); for (SubjectCredential subjectCredential : subjectCredentials) { Subject fromSubject = subjectCredential.getSubject(); transfer(fromSubject, toSubject); } }
/** * Constructs a PasswordCredential with the specified password. * @param password the specified password */ public PasswordCredential(String password) { _password = password != null ? password.toCharArray() : null; _mask = mask(); }
/** * Constructs a PasswordCredential with the specified password. * @param password the specified password */ public PasswordCredential(String password) { _password = password != null ? password.toCharArray() : null; _mask = mask(); }